BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
tofcalgsec Class Reference

#include <tofcalgsec.h>

+ Inheritance diagram for tofcalgsec:

Public Member Functions

 tofcalgsec (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~tofcalgsec ()
 
StatusCode initialize ()
 
StatusCode beginRun ()
 
StatusCode execute ()
 
StatusCode endRun ()
 
StatusCode finalize ()
 
 tofcalgsec (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~tofcalgsec ()
 
StatusCode initialize ()
 
StatusCode beginRun ()
 
StatusCode execute ()
 
StatusCode endRun ()
 
StatusCode finalize ()
 

Protected Member Functions

bool testbit (unsigned int n)
 
bool testbit (unsigned int n)
 

Detailed Description

Constructor & Destructor Documentation

◆ tofcalgsec() [1/2]

tofcalgsec::tofcalgsec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 68 of file tofcalgsec.cxx.

68 :Algorithm(name,pSvcLocator){
69 //set default values
70 m_calibItem="111111111";
71 //declares
72 declareProperty("Online", m_online );
73 declareProperty("Calibration", m_calibration );
74 declareProperty("WorkDir", m_workdir );
75 declareProperty("InputDataDir", m_datafile_dir );
76 declareProperty("InputDataFiles_Barrel", m_datafile_barrel );
77 declareProperty("InputDataFiles_Endcap", m_datafile_endcap );
78 declareProperty("InputDataFiles_Etf", m_datafile_etf );
79 declareProperty("CalibItem", m_calibItem );
80 declareProperty("TimeCorrelationZBin", m_tcorrzbin = 23 );
81 declareProperty("BarrelSigmaZBin", m_barrelzbin = 5 );
82 declareProperty("EndcapSigmaRBin", m_endcaprbin = 5 );
83 declareProperty("EndcapQRBin", m_endcapQrbin = 5 );
84}

◆ ~tofcalgsec() [1/2]

tofcalgsec::~tofcalgsec ( )

Definition at line 430 of file tofcalgsec.cxx.

430{}

◆ tofcalgsec() [2/2]

tofcalgsec::tofcalgsec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

◆ ~tofcalgsec() [2/2]

tofcalgsec::~tofcalgsec ( )

Member Function Documentation

◆ beginRun() [1/2]

StatusCode tofcalgsec::beginRun ( )

Definition at line 231 of file tofcalgsec.cxx.

231 {
232 MsgStream log(msgSvc(), name());
233 log << MSG::INFO << "tofcalgsec::beginRun()" << endreq;
234 return StatusCode::SUCCESS;
235}

◆ beginRun() [2/2]

StatusCode tofcalgsec::beginRun ( )

◆ endRun() [1/2]

StatusCode tofcalgsec::endRun ( )

Definition at line 286 of file tofcalgsec.cxx.

286 {
287 MsgStream log(msgSvc(), name());
288 log << MSG::INFO << "tofcalgsec::endRun()" << endreq;
289 return StatusCode::SUCCESS;
290}

◆ endRun() [2/2]

StatusCode tofcalgsec::endRun ( )

◆ execute() [1/2]

StatusCode tofcalgsec::execute ( )

Definition at line 238 of file tofcalgsec.cxx.

238 {
239 MsgStream log(msgSvc(), name());
240 log << MSG::INFO << "start "<<"tofcalgsec::execute()" << endreq;
241
242 if( m_online ) {
243 SmartDataPtr<RecBTofCalHitCol> bhitcol(eventSvc(),"/Event/Recon/RecBTofCalHitCol");
244 if( bhitcol ) {
245 m_checkbarrel->FillBarrelCol( bhitcol );
246 if( m_calibration ) {
248 manager->dataSet()->setBarrelData( bhitcol );
249 }
250 }
251 else{
252 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq;
253 // return StatusCode::SUCCESS;
254 }
255
256 SmartDataPtr<RecETofCalHitCol> ehitcol(eventSvc(),"/Event/Recon/RecETofCalHitCol");
257 if( ehitcol ) {
258 m_checkendcap->FillEndcapCol( ehitcol );
259 if( m_calibration ) {
261 }
262 }
263 else{
264 // log << MSG::ERROR << " Can't get /Event/Recon/RecETofCalHitCol in TDS!" <<endreq;
265 // return StatusCode::SUCCESS;
266 }
267
268 if( bhitcol ) {
269 m_checketf->FillEtfCol( bhitcol );
270 if( m_calibration ) {
272 }
273 }
274 else{
275 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" << endreq;
276 // return StatusCode::SUCCESS;
277 }
278
279 }
280
281 log << MSG::INFO << "end "<<"tofcalgsec::execute()" << endreq;
282 return StatusCode::SUCCESS;
283}
void FillEndcapCol(RecETofCalHitCol &)
void FillBarrelCol(RecBTofCalHitCol &)
void FillEtfCol(RecBTofCalHitCol &)
static TofCalibManager * getManager()
void setEtfData(RecBTofCalHitCol &)
Definition: TofDataSet.cxx:311
void setBarrelData(RecBTofCalHitCol &)
Definition: TofDataSet.cxx:274
void setEndcapData(RecETofCalHitCol &)
Definition: TofDataSet.cxx:293

◆ execute() [2/2]

StatusCode tofcalgsec::execute ( )

◆ finalize() [1/2]

StatusCode tofcalgsec::finalize ( )

Definition at line 293 of file tofcalgsec.cxx.

293 {
294
295 MsgStream log(msgSvc(), name());
296 log << MSG::INFO << "tofcalgsec::finalize()" << endreq;
297
298 if( m_online && !m_calibration ) {
299 if( m_checkbarrel ) { delete m_checkbarrel; }
300 if( m_checkendcap ) { delete m_checkendcap; }
301 if( m_checketf ) { delete m_checketf; }
302 return StatusCode::SUCCESS;
303 }
304
306 if( !m_online ) {
307 if( m_barrelfile.empty() ) {
308 std::cout << " No barrle data files are valid, exit " << std::endl;
309 exit(0);
310 }
311 else {
312 manager->dataSet()->setBarrelDataFiles( m_barrelfile );
313 }
314 if( m_endcapfile.empty() ) {
315 std::cout << " No endcap data files are valid, exit " << std::endl;
316 exit(0);
317 }
318 else {
319 manager->dataSet()->setEndcapDataFiles( m_endcapfile );
320 }
321 if( m_etffile.empty() ) {
322 std::cout << " No etf data files are valid, exit " << std::endl;
323 exit(0);
324 }
325 else {
326 manager->dataSet()->setEtfDataFiles( m_etffile );
327 }
328 }
329
330 // barrel attenuation length calibration
331 if( testbit(5) ) {
332 manager->addCalib( new calib_barrel_atten(), 1 );
333 manager->addCalib( new calib_barrel_q0(), 1 );
334 }
335 // barrel effective velocity calibration
336 if( testbit(4) ) {
337 manager->addCalib( new calib_barrel_veff(), 1 );
338 }
339 // barrel time calibration
340 if( testbit(7) ) {
341 manager->addCalib( new calib_barrel_left(), 1 );
342 if (testbit(8)){
343 manager->addCalib( new calib_barrel_left_offset1_bunch0_4(), true );
344 manager->addCalib( new calib_barrel_left_offset1_bunch1_4(), true );
345 manager->addCalib( new calib_barrel_left_offset1_bunch2_4(), true );
346 manager->addCalib( new calib_barrel_left_offset1_bunch3_4(), true );
347 manager->addCalib( new calib_barrel_left_offset2_bunch0_4(), true );
348 manager->addCalib( new calib_barrel_left_offset2_bunch1_4(), true );
349 manager->addCalib( new calib_barrel_left_offset2_bunch2_4(), true );
350 manager->addCalib( new calib_barrel_left_offset2_bunch3_4(), true );
351 }
352 if (!testbit(8)){
353 manager->addCalib( new calib_barrel_left_offset1_bunch0_3(), true );
354 manager->addCalib( new calib_barrel_left_offset1_bunch1_3(), true );
355 manager->addCalib( new calib_barrel_left_offset1_bunch2_3(), true );
356 manager->addCalib( new calib_barrel_left_offset1_bunch3_3(), true );
357 manager->addCalib( new calib_barrel_left_offset2_bunch0_3(), true );
358 manager->addCalib( new calib_barrel_left_offset2_bunch1_3(), true );
359 manager->addCalib( new calib_barrel_left_offset2_bunch2_3(), true );
360 manager->addCalib( new calib_barrel_left_offset2_bunch3_3(), true );
361 }
362 manager->addCalib( new calib_barrel_right(), 1 );
363 if (testbit(8)){
364 manager->addCalib( new calib_barrel_right_offset1_bunch0_4(), true );
365 manager->addCalib( new calib_barrel_right_offset1_bunch1_4(), true );
366 manager->addCalib( new calib_barrel_right_offset1_bunch2_4(), true );
367 manager->addCalib( new calib_barrel_right_offset1_bunch3_4(), true );
368 manager->addCalib( new calib_barrel_right_offset2_bunch0_4(), true );
369 manager->addCalib( new calib_barrel_right_offset2_bunch1_4(), true );
370 manager->addCalib( new calib_barrel_right_offset2_bunch2_4(), true );
371 manager->addCalib( new calib_barrel_right_offset2_bunch3_4(), true );
372 }
373 if (!testbit(8)){
374 manager->addCalib( new calib_barrel_right_offset1_bunch0_3(), true );
375 manager->addCalib( new calib_barrel_right_offset1_bunch1_3(), true );
376 manager->addCalib( new calib_barrel_right_offset1_bunch2_3(), true );
377 manager->addCalib( new calib_barrel_right_offset1_bunch3_3(), true );
378 manager->addCalib( new calib_barrel_right_offset2_bunch0_3(), true );
379 manager->addCalib( new calib_barrel_right_offset2_bunch1_3(), true );
380 manager->addCalib( new calib_barrel_right_offset2_bunch2_3(), true );
381 manager->addCalib( new calib_barrel_right_offset2_bunch3_3(), true );
382 }
383 }
384 // barrel sigma calibration
385 if( testbit(6) ) {
386 manager->addCalib( new calib_barrel_common(m_tcorrzbin), true );
387 manager->addCalib( new calib_barrel_sigma(m_barrelzbin), true );
388 }
389
390 // endcap attenuation length calibration
391 if( testbit(1) ) {
392 manager->addCalib( new calib_endcap_atten(m_endcapQrbin), false );
393 }
394 // endcap effective velocity calibration
395 if( testbit(0) ) {
396 manager->addCalib( new calib_endcap_veff(), false );
397 }
398 // endcap time calibration
399 if( testbit(3) ) {
400 manager->addCalib( new calib_endcap_left(), 0 );
401 }
402 // endcap sigma calibration
403 if( testbit(2) ) {
404 manager->addCalib( new calib_endcap_sigma(m_endcaprbin), false );
405 }
406 // etf effective velocity calibration
407 if( testbit(10) ) {
408 manager->addCalib( new calib_etf_veff(), 2 );
409 }
410 // etf time calibration
411 if( testbit(11) ) {
412 manager->addCalib( new calib_etf_combine(), 2 );
413 manager->addCalib( new calib_etf_left(), 2 );
414 manager->addCalib( new calib_etf_right(), 2 );
415 }
416 // etf bunch offset
417 if( testbit(12) ) {
418 manager->addCalib( new calib_etf_bunch(4), false );
419 }
420
421 manager->doCalibration();
422
423 manager->fillTxt( m_workdir );
424 manager->fillRoot( m_workdir );
425
426 return StatusCode::SUCCESS;
427}
void addCalib(TofCalib *cal_item1, int isbarrel)
void fillRoot(string &dir)
void fillTxt(string &dir)
void setEtfDataFiles(std::vector< std::string > &)
Definition: TofDataSet.cxx:251
void setEndcapDataFiles(std::vector< std::string > &)
Definition: TofDataSet.cxx:228
void setBarrelDataFiles(std::vector< std::string > &)
Definition: TofDataSet.cxx:205

◆ finalize() [2/2]

StatusCode tofcalgsec::finalize ( )

◆ initialize() [1/2]

StatusCode tofcalgsec::initialize ( )

Definition at line 87 of file tofcalgsec.cxx.

87 {
88
89 MsgStream log(msgSvc(), name());
90 log<<MSG::INFO<< "tofcalgsec::initialize()!" <<endreq;
91
92 if( m_online ) {
93 NTuplePtr nt1(ntupleSvc(),"TofCalib/btrk");
94 NTuplePtr nt2(ntupleSvc(),"TofCalib/etrk");
95 NTuplePtr nt3(ntupleSvc(),"TofCalib/etf");
96 if ( nt1 || nt2 || nt3 ) {
97 mtuple_barrel = nt1;
98 mtuple_endcap = nt2;
99 mtuple_etf = nt3;
100 }
101 else {
102 mtuple_barrel = ntupleSvc()->book("TofCalib/btrk",CLID_ColumnWiseTuple,"TofCalib");
103 mtuple_endcap = ntupleSvc()->book("TofCalib/etrk",CLID_ColumnWiseTuple,"TofCalib");
104 mtuple_etf = ntupleSvc()->book("TofCalib/etf", CLID_ColumnWiseTuple,"TofCalib");
105
106 if( mtuple_barrel ) {
107 m_checkbarrel = new TofCalibCheck( mtuple_barrel );
108 }
109 else{
110 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_barrel) <<endmsg;
111 return StatusCode::FAILURE;
112 }
113 if( mtuple_endcap ) {
114 m_checkendcap = new TofCalibCheck( mtuple_endcap );
115 }
116 else{
117 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_endcap) <<endmsg;
118 return StatusCode::FAILURE;
119 }
120 if( mtuple_etf ) {
121 m_checketf = new TofCalibCheck( mtuple_etf );
122 }
123 else{
124 log << MSG::ERROR <<"Cannot book N-tuple:" << long(mtuple_etf) <<endmsg;
125 return StatusCode::FAILURE;
126 }
127 }
128 }
129 else {
130 m_calibration = true; // offline
131 }
132
133 if( !m_online || m_calibration ) {
134 // check workdir
135 std::cout<<" tofcalgsec checks your configurations ..."<<std::endl;
136 void *pdir=0;
137 if((pdir=gSystem->OpenDirectory(m_workdir.c_str()))==0){//dir exists?
138 std::cerr<<"WorkDir "<<m_workdir<<" doesn't exist "<<std::endl;
139 if(gSystem->MakeDirectory(m_workdir.c_str())==-1){//mkdir,fail to create?
140 std::cerr<<" Fail to create directory : "<<m_workdir
141 <<" Specify ./ as current work directory"<<std::endl;
142 m_workdir="./";
143 }
144 }
145 else{
146 gSystem->FreeDirectory(pdir);
147 pdir=0;
148 }
149 }
150
151 if( !m_online ) {
152 void *pdir=0;
153 if( (pdir=gSystem->OpenDirectory(m_datafile_dir.c_str())) ) {
154 FileStat_t fs;
155 std::vector<string>::iterator it = m_datafile_barrel.begin();
156 for( ; it!=m_datafile_barrel.end(); it++ ) {
157 if( (*it).size()>0 ) {
158 std::string thefile = (m_datafile_dir+"/"+(*it));
159 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) {
160 m_barrelfile.push_back(thefile);
161 }
162 else{
163 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl;
164 }
165 }
166 }
167 it = m_datafile_endcap.begin();
168 for( ; it!=m_datafile_endcap.end(); it++ ) {
169 if( (*it).size()>0 ) {
170 std::string thefile=(m_datafile_dir+"/"+(*it));
171 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) {
172 m_endcapfile.push_back(thefile);
173 }
174 else{
175 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl;
176 }
177 }
178 }
179 it = m_datafile_etf.begin();
180 for( ; it!=m_datafile_etf.end(); it++ ) {
181 if( (*it).size()>0 ) {
182 std::string thefile=(m_datafile_dir+"/"+(*it));
183 if( gSystem->GetPathInfo(thefile.c_str(),fs)==0 ) {
184 m_etffile.push_back(thefile);
185 }
186 else{
187 std::cerr<<" File "<<thefile<<" doesn't exist! "<<std::endl;
188 }
189 }
190 }
191 gSystem->FreeDirectory(pdir);
192 pdir=0;
193 }
194 else {
195 std::cerr<<" Error : Please specify the InputDataDir which contains input data files for calibration "<<std::endl;
196 exit(0);
197 }
198 }
199
200 if( !m_online || m_calibration ) {
201 std::cout<<"******************* Report of before Calibration ********************"<<std::endl
202 <<"* WorkDir = "<<m_workdir<<" [ results are save in this directory ] "<<std::endl
203 <<"* WorkMode = "<<(m_online?"OnLine":"OffLine")<<" [ run alone or with other algorithms ] "<<std::endl
204 <<"* CalibItem = "<<m_calibItem<<" [ which calibraions you perform ]"<<std::endl;
205 }
206
207 if( !m_online ) {
208 std::cout <<"* ==> InputDataDir : "<<m_datafile_dir<<std::endl
209 <<"* ===>Files of Barrel : ";
210 for( std::vector<std::string>::iterator it=m_barrelfile.begin(); it!=m_barrelfile.end(); it++ ) {
211 std::cout << "'" << (*it) << "' ";
212 }
213 std::cout << std::endl
214 <<"* ===>Files of Endcap : ";
215 for( std::vector<std::string>::iterator it=m_endcapfile.begin(); it!=m_endcapfile.end(); it++ ) {
216 std::cout << "'" << (*it) << "' ";
217 }
218 std::cout << std::endl
219 <<"* ===>Files of Etf : ";
220 for( std::vector<std::string>::iterator it=m_etffile.begin(); it!=m_etffile.end(); it++ ) {
221 std::cout << "'" << (*it) << "' ";
222 }
223 std::cout << std::endl;
224 }
225 std::cout<<"*********************************************************************"<<std::endl;
226
227 return StatusCode::SUCCESS;
228}

◆ initialize() [2/2]

StatusCode tofcalgsec::initialize ( )

◆ testbit() [1/2]

bool tofcalgsec::testbit ( unsigned int  n)
inlineprotected

Definition at line 21 of file InstallArea/include/tofcalgsec/tofcalgsec/tofcalgsec.h.

21 {
22 if( n>m_calibItem.size() ) return false;
23 return m_calibItem[n]=='0'?false:true;
24 }
const Int_t n

Referenced by finalize().

◆ testbit() [2/2]

bool tofcalgsec::testbit ( unsigned int  n)
inlineprotected

Definition at line 21 of file Tof/tofcalgsec/tofcalgsec-00-02-20/tofcalgsec/tofcalgsec.h.

21 {
22 if( n>m_calibItem.size() ) return false;
23 return m_calibItem[n]=='0'?false:true;
24 }

The documentation for this class was generated from the following files: