BOSS 8.0.0
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 finalize ()

Protected Member Functions

bool testbit (unsigned int n)

Detailed Description

Definition at line 9 of file tofcalgsec.h.

Constructor & Destructor Documentation

◆ tofcalgsec()

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

Definition at line 70 of file tofcalgsec.cxx.

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

Referenced by tofcalgsec().

◆ ~tofcalgsec()

tofcalgsec::~tofcalgsec ( )

Definition at line 443 of file tofcalgsec.cxx.

443{}

Member Function Documentation

◆ beginRun()

StatusCode tofcalgsec::beginRun ( )

Definition at line 244 of file tofcalgsec.cxx.

244 {
245 MsgStream log( msgSvc(), name() );
246 log << MSG::INFO << "tofcalgsec::beginRun()" << endmsg;
247 return StatusCode::SUCCESS;
248}
IMessageSvc * msgSvc()

◆ execute()

StatusCode tofcalgsec::execute ( )

Definition at line 250 of file tofcalgsec.cxx.

250 {
251 MsgStream log( msgSvc(), name() );
252 log << MSG::INFO << "start "
253 << "tofcalgsec::execute()" << endmsg;
254
255 if ( m_online )
256 {
257 SmartDataPtr<RecBTofCalHitCol> bhitcol( eventSvc(), "/Event/Recon/RecBTofCalHitCol" );
258 if ( bhitcol )
259 {
260 m_checkbarrel->FillBarrelCol( bhitcol );
261 if ( m_calibration )
262 {
263 TofCalibManager* manager = TofCalibManager::getManager();
264 manager->dataSet()->setBarrelData( bhitcol );
265 }
266 }
267 else
268 {
269 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" <<
270 // endmsg; return StatusCode::SUCCESS;
271 }
272
273 SmartDataPtr<RecETofCalHitCol> ehitcol( eventSvc(), "/Event/Recon/RecETofCalHitCol" );
274 if ( ehitcol )
275 {
276 m_checkendcap->FillEndcapCol( ehitcol );
277 if ( m_calibration )
279 }
280 else
281 {
282 // log << MSG::ERROR << " Can't get /Event/Recon/RecETofCalHitCol in TDS!" <<endmsg;
283 // return StatusCode::SUCCESS;
284 }
285
286 if ( bhitcol )
287 {
288 m_checketf->FillEtfCol( bhitcol );
289 if ( m_calibration ) { TofCalibManager::getManager()->dataSet()->setEtfData( bhitcol ); }
290 }
291 else
292 {
293 // log << MSG::ERROR << " Can't get /Event/Recon/RecBTofCalHitCol in TDS!" <<
294 // endmsg; return StatusCode::SUCCESS;
295 }
296 }
297
298 log << MSG::INFO << "end "
299 << "tofcalgsec::execute()" << endmsg;
300 return StatusCode::SUCCESS;
301}
static TofCalibManager * getManager()
TofDataSet * dataSet()
void setEtfData(RecBTofCalHitCol &)
void setBarrelData(RecBTofCalHitCol &)
void setEndcapData(RecETofCalHitCol &)

◆ finalize()

StatusCode tofcalgsec::finalize ( )

Definition at line 303 of file tofcalgsec.cxx.

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

◆ initialize()

StatusCode tofcalgsec::initialize ( )

Definition at line 89 of file tofcalgsec.cxx.

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

◆ testbit()

bool tofcalgsec::testbit ( unsigned int n)
inlineprotected

Definition at line 20 of file tofcalgsec.h.

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

Referenced by finalize().


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