BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EstTofCaliSvc Class Reference

#include <EstTofCaliSvc.h>

Inheritance diagram for EstTofCaliSvc:

Public Member Functions

 EstTofCaliSvc (const std::string &name, ISvcLocator *svcloc)
 ~EstTofCaliSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
StatusCode chooseConstants (int run, int number)
EstBTofCalBTof (unsigned id) const
EstBTofCommonCalBTofCommon () const
EstETofCalETof (unsigned id) const
EstEtfCalEtfTof (unsigned int id) const
EstTofInfoCalTofInfo () const
const double BTCorr1 (double ADC, double zHit, unsigned id)
const double BTCorr2 (double ADC, double zHit, unsigned id)
const double TOffset ()
const double BTime1 (double ADC, double TDC, double zHit, unsigned id)
const double BTime2 (double ADC, double TDC, double zHit, unsigned id)
const double ETime (double ADC, double TDC, double rHit, unsigned id)
const double EtfTime (double ADC1, double ADC2, double TDC1, double TDC2, unsigned id, unsigned int strip)
const double EtfTime1 (double ADC, double TDC, double zHit, unsigned id, unsigned int strip)
const double EtfTime2 (double ADC, double TDC, double zHit, unsigned id, unsigned int strip)
const double EtfTime (double TDC1, double TDC2, unsigned id, unsigned int strip)
const bool ValidInfo ()
void Dump ()

Detailed Description

Definition at line 17 of file EstTofCaliSvc.h.

Constructor & Destructor Documentation

◆ EstTofCaliSvc()

EstTofCaliSvc::EstTofCaliSvc ( const std::string & name,
ISvcLocator * svcloc )

Definition at line 44 of file EstTofCaliSvc.cxx.

45 : base_class( name, svcloc ) {
46 declareProperty( "Run", m_run = 1 );
47}

Referenced by EstTofCaliSvc().

◆ ~EstTofCaliSvc()

EstTofCaliSvc::~EstTofCaliSvc ( )

Definition at line 88 of file EstTofCaliSvc.cxx.

88 {
89 for ( auto it : fBTofCal )
90 {
91 if ( it ) delete it;
92 };
93 fBTofCal.clear();
94
95 for ( auto it : fETofCal )
96 {
97 if ( it ) delete it;
98 };
99 fETofCal.clear();
100
101 if ( fEtfCal.size() != 0 )
102 {
103 for ( auto it : fEtfCal )
104 {
105 if ( it ) delete it;
106 };
107 fEtfCal.clear();
108 }
109
110 for ( auto it : fBTofCommonCal )
111 {
112 if ( it ) delete it;
113 };
114 fBTofCommonCal.clear();
115
116 for ( auto it : fTofInfoCal )
117 {
118 if ( it ) delete it;
119 };
120 fTofInfoCal.clear();
121 return;
122}

Member Function Documentation

◆ BTCorr1()

const double EstTofCaliSvc::BTCorr1 ( double ADC,
double zHit,
unsigned id )

Definition at line 321 of file EstTofCaliSvc.cxx.

321 {
322 MsgStream log( msgSvc(), name() );
323
324 double p1[EstNBarPar];
325 for ( int i = 0; i < static_cast<int>( EstNBarPar ); i++ )
326 { p1[i] = fBTofCal[176 * m_sequence + id]->getP1( i ); }
327
328 log << MSG::DEBUG << "BTCorr1 id =" << id << " 1=" << p1[0] << " 2=" << p1[1]
329 << " 3=" << p1[2] << " 4=" << p1[3] << " 5=" << p1[4] << " 6=" << p1[5] << " 7=" << p1[6]
330 << " 8=" << p1[7] << " 9=" << p1[8] << endmsg;
331
332 double tcorr1 = p1[0] + p1[1] / TMath::Sqrt( ADC ) + p1[2] * z / TMath::Sqrt( ADC ) +
333 p1[3] / ADC + p1[4] * z + p1[5] * z * z + p1[6] * z * z * z;
334
335 return tcorr1;
336}
double p1[4]
IMessageSvc * msgSvc()

Referenced by BTime1().

◆ BTCorr2()

const double EstTofCaliSvc::BTCorr2 ( double ADC,
double zHit,
unsigned id )

Definition at line 338 of file EstTofCaliSvc.cxx.

338 {
339 MsgStream log( msgSvc(), name() );
340
341 double p2[EstNBarPar];
342 for ( int i = 0; i < static_cast<int>( EstNBarPar ); i++ )
343 { p2[i] = fBTofCal[176 * m_sequence + id]->getP2( i ); }
344
345 log << MSG::DEBUG << "BTCorr2 id =" << id << " 1=" << p2[0] << " 2=" << p2[1]
346 << " 3=" << p2[2] << " 4=" << p2[3] << " 5=" << p2[4] << " 6=" << p2[5] << " 7=" << p2[6]
347 << " 8=" << p2[7] << " 9=" << p2[8] << endmsg;
348
349 double tcorr2 = p2[0] + p2[1] / TMath::Sqrt( ADC ) + p2[2] * z / TMath::Sqrt( ADC ) +
350 p2[3] / ADC + p2[4] * z + p2[5] * z * z + p2[6] * z * z * z;
351
352 return tcorr2;
353}
double p2[4]

Referenced by BTime2().

◆ BTime1()

const double EstTofCaliSvc::BTime1 ( double ADC,
double TDC,
double zHit,
unsigned id )

Definition at line 360 of file EstTofCaliSvc.cxx.

360 {
361 MsgStream log( msgSvc(), name() );
362
363 double tcorr1 = BTCorr1( ADC, z, id );
364
365 double tcorr3 = fBTofCommonCal[m_sequence]->getOffset( 0 );
366
367 log << MSG::DEBUG << "BTime1 id =" << id << " tcorr=" << tcorr1
368 << " total offset=" << tcorr3 << endmsg;
369
370 double time = TDC - tcorr1 - tcorr3;
371
372 if ( time < 0. )
373 {
374 log << MSG::WARNING << "TofCaliSvc::BTime1() -- A minus time is given : " << time
375 << " [Input] ADC = " << ADC << " TDC = " << TDC << " z = " << z << " ID = " << id
376 << endmsg;
377 }
378 return time;
379}
Double_t time
const double BTCorr1(double ADC, double zHit, unsigned id)

◆ BTime2()

const double EstTofCaliSvc::BTime2 ( double ADC,
double TDC,
double zHit,
unsigned id )

Definition at line 381 of file EstTofCaliSvc.cxx.

381 {
382 MsgStream log( msgSvc(), name() );
383
384 double tcorr1 = BTCorr2( ADC, z, id );
385
386 double tcorr3 = fBTofCommonCal[m_sequence]->getOffset( 0 );
387
388 log << MSG::DEBUG << "BTime2 id =" << id << " tcorr=" << tcorr1
389 << " total offset=" << tcorr3 << endmsg;
390
391 double time = TDC - tcorr1 - tcorr3;
392
393 if ( time < 0. )
394 {
395 log << MSG::WARNING << "TofCaliSvc::BTime2() -- A minus time is given : " << time
396 << " [Input] ADC = " << ADC << " TDC = " << TDC << " z = " << z << " ID = " << id
397 << endmsg;
398 }
399 return time;
400}
const double BTCorr2(double ADC, double zHit, unsigned id)

◆ BTof()

EstBTofCal * EstTofCaliSvc::BTof ( unsigned id) const

Definition at line 552 of file EstTofCaliSvc.cxx.

552 {
553 return fBTofCal[176 * m_sequence + id];
554}

Referenced by Dump().

◆ BTofCommon()

EstBTofCommonCal * EstTofCaliSvc::BTofCommon ( ) const

Definition at line 562 of file EstTofCaliSvc.cxx.

562{ return fBTofCommonCal[m_sequence]; }

◆ chooseConstants()

StatusCode EstTofCaliSvc::chooseConstants ( int run,
int number )

Definition at line 233 of file EstTofCaliSvc.cxx.

233 {
234
235 MsgStream log( msgSvc(), name() );
236
237 m_sequence = 0;
238 bool filled = false;
239
240 if ( fTofInfoCal[0]->getRunFrom() == -1 )
241 {
242 if ( fTofInfoCal.size() == 1 )
243 {
244 log << MSG::INFO
245 << "EstTofCaliSvc::chooseConstants() -- Run From is equal to -1! The ONLY TOF "
246 "calibration constants are used!"
247 << endmsg;
248 return StatusCode::SUCCESS;
249 }
250 else
251 {
252 log << MSG::ERROR
253 << "EstTofCaliSvc::chooseConstants() -- Run From is equal to -1! The NUMBER of "
254 "calibration constants are NOT "
255 "equal to 1!"
256 << endmsg;
257 return StatusCode::FAILURE;
258 }
259 }
260
261 for ( int i = 0; i < fTofInfoCal.size(); i++ )
262 {
263 auto element = fTofInfoCal[i];
264 if ( element->getRunTo() != -1 && element->getRunTo() < element->getRunFrom() )
265 {
266 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The " << i
267 << "th calibration constatns is ABNORMAL! Run From is LARGER than RUN To!" << endmsg;
268 return StatusCode::FAILURE;
269 }
270
271 if ( element->getRunFrom() == element->getRunTo() && element->getEventFrom() != -1 &&
272 element->getEventTo() != -1 && element->getEventFrom() > element->getEventTo() )
273 {
274 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The " << i
275 << "th calibration constatns is ABNORMAL! Event From is LARGER than Event To!"
276 << endmsg;
277 return StatusCode::FAILURE;
278 }
279 }
280
281 unsigned int inumber = 0;
282 for ( ; inumber < fTofInfoCal.size(); inumber++ )
283 {
284 auto element = fTofInfoCal[inumber];
285 int runFrom = element->getRunFrom();
286 int runTo = element->getRunTo();
287 int eventFrom = element->getEventFrom();
288 int eventTo = element->getEventTo();
289 if ( ( run == runFrom ) && ( ( eventFrom == -1 ) || ( event >= eventFrom ) ) )
290 {
291 if ( ( run < runTo ) ||
292 ( ( run == runTo ) && ( ( eventTo == -1 ) || ( event <= eventTo ) ) ) )
293 {
294 filled = true;
295 break;
296 }
297 }
298 if ( run > runFrom )
299 {
300 if ( ( run < runTo ) ||
301 ( ( run == runTo ) && ( ( eventTo == -1 ) || ( event <= eventTo ) ) ) )
302 {
303 filled = true;
304 break;
305 }
306 }
307 }
308
309 if ( filled ) { m_sequence = inumber; }
310 else
311 {
312 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The event with run number "
313 << run << " and event number " << event
314 << " is NOT suitable for this group of calibration constants" << endmsg;
315 return StatusCode::FAILURE;
316 }
317
318 return StatusCode::SUCCESS;
319}

◆ Dump()

void EstTofCaliSvc::Dump ( )

Definition at line 566 of file EstTofCaliSvc.cxx.

566 {
567 std::cout << "Now We can get the TOF Calibtration Service" << std::endl;
568 std::cout << "Barrel TOF Counter Number = " << fBTofCal.size() << std::endl;
569 std::cout << "Endcap TOF Counter Number = " << fETofCal.size() << std::endl;
570
571 cout << "The O Barrel TOF PMT1 p1[0] is"
572 << " " << BTof( 0 )->getP1( 0 ) << endl;
573 cout << "The 0 Barrel TOF PMT1 p1[1] is"
574 << " " << BTof( 0 )->getP1( 1 ) << endl;
575}
EstBTofCal * BTof(unsigned id) const

Referenced by main().

◆ EtfTime() [1/2]

const double EstTofCaliSvc::EtfTime ( double ADC1,
double ADC2,
double TDC1,
double TDC2,
unsigned id,
unsigned int strip )

Definition at line 425 of file EstTofCaliSvc.cxx.

426 {
427 MsgStream log( msgSvc(), name() );
428
429 double q = ( ADC1 + ADC2 ) / 2.0;
430 double t = ( TDC1 + TDC2 ) / 2.0;
431
432 double p[EstNEtfPar];
433 for ( int i = 0; i < static_cast<int>( EstNEtfPar ); i++ )
434 { p[i] = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP( i ); }
435
436 double tcorr = p[0] + p[1] / TMath::Sqrt( q ) + p[2] / q + p[3] * q + p[4] * q * q +
437 p[5] * q * q * q + p[6] * q * q * q * q;
438 double time = t - tcorr;
439
440 log << MSG::DEBUG << "EtfTime module =" << id << " strip=" << strip << " 1=" << p[0]
441 << " 2=" << p[1] << " 3=" << p[2] << " 4=" << p[3] << " 5=" << p[4] << " 6=" << p[5]
442 << " 7=" << p[6] << " 8=" << p[7] << " 9=" << p[8] << " tcorr=" << tcorr
443 << " time=" << time << endmsg;
444 if ( time < 0. )
445 {
446 log << MSG::WARNING << "TofCaliSvc::EtfTime() -- A minus time is given : " << time
447 << " [Input] ADC1 = " << ADC1 << " ADC2 = " << ADC2 << " TDC1 = " << TDC1
448 << " TDC2 = " << TDC2 << " ID = " << id << " Strip = " << strip << endmsg;
449 }
450
451 return time;
452}
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition KKsem.h:33
int t()
Definition t.c:1

◆ EtfTime() [2/2]

const double EstTofCaliSvc::EtfTime ( double TDC1,
double TDC2,
unsigned id,
unsigned int strip )

Definition at line 510 of file EstTofCaliSvc.cxx.

511 {
512 MsgStream log( msgSvc(), name() );
513
514 double time = -99;
515 double t, tcorr;
516
517 if ( TDC1 > 0 && TDC2 > 0 )
518 {
519 t = ( TDC1 + TDC2 ) / 2.0;
520 tcorr = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP( 0 );
521 time = t - tcorr;
522 log << MSG::DEBUG << "EtfTime module =" << id << " strip=" << strip << " t1=" << TDC1
523 << " t2=" << TDC2 << " combine const=" << tcorr << " time=" << time << endmsg;
524 }
525 else if ( TDC1 > 0 && TDC2 < 0 )
526 {
527 t = TDC1;
528 tcorr = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP1( 0 );
529 time = t - tcorr;
530 log << MSG::DEBUG << "EtfTime module =" << id << " strip=" << strip << " t1=" << TDC1
531 << " left const=" << tcorr << " time=" << time << endmsg;
532 }
533 else if ( TDC1 < 0 && TDC2 > 0 )
534 {
535 t = TDC2;
536 tcorr = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP2( 0 );
537 time = t - tcorr;
538 log << MSG::DEBUG << "EtfTime module =" << id << " strip=" << strip << " t2=" << TDC2
539 << " right const=" << tcorr << " time=" << time << endmsg;
540 }
541
542 if ( time < 0. )
543 {
544 log << MSG::WARNING << "TofCaliSvc::EtfTime() -- A minus time is given : " << time
545 << " [Input] TDC1 = " << TDC1 << " TDC2 = " << TDC2 << " ID = " << id
546 << " Strip = " << strip << endmsg;
547 }
548
549 return time;
550}

◆ EtfTime1()

const double EstTofCaliSvc::EtfTime1 ( double ADC,
double TDC,
double zHit,
unsigned id,
unsigned int strip )

Definition at line 454 of file EstTofCaliSvc.cxx.

455 {
456 MsgStream log( msgSvc(), name() );
457
458 double p1[EstNEtfPar];
459 for ( int i = 0; i < static_cast<int>( EstNEtfPar ); i++ )
460 { p1[i] = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP1( i ); }
461
462 double tcorr1 = p1[0] + p1[1] / TMath::Sqrt( ADC ) + p1[2] * ADC + p1[3] * ADC * ADC +
463 p1[4] * ADC * ADC * ADC + p1[5] * ADC * ADC * ADC * ADC +
464 p1[6] * z / TMath::Sqrt( ADC ) + p1[7] / ADC + p1[8] * z / ADC +
465 p1[9] * z * ADC + p1[10] * z + p1[11] * z * z + p1[12] * z * z * z;
466 double time1 = TDC - tcorr1;
467
468 log << MSG::DEBUG << "EtfTime1 module =" << id << " strip=" << strip << " 1=" << p1[0]
469 << " 2=" << p1[1] << " 3=" << p1[2] << " 4=" << p1[3] << " 5=" << p1[4] << " 6=" << p1[5]
470 << " 7=" << p1[6] << " 8=" << p1[7] << " 9=" << p1[8] << " tcorr=" << tcorr1
471 << " time1=" << time1 << endmsg;
472 if ( time1 < 0. )
473 {
474 log << MSG::WARNING << "TofCaliSvc::EtfTime1() -- A minus time is given : " << time
475 << " [Input] ADC = " << ADC << " TDC = " << TDC << " z = " << z << " ID = " << id
476 << " Strip = " << strip << endmsg;
477 }
478
479 return time1;
480}

◆ EtfTime2()

const double EstTofCaliSvc::EtfTime2 ( double ADC,
double TDC,
double zHit,
unsigned id,
unsigned int strip )

Definition at line 482 of file EstTofCaliSvc.cxx.

483 {
484 MsgStream log( msgSvc(), name() );
485
486 double p2[EstNEtfPar];
487 for ( int i = 0; i < static_cast<int>( EstNEtfPar ); i++ )
488 { p2[i] = fEtfCal[72 * 12 * m_sequence + 12 * id + strip]->getP2( i ); }
489
490 double tcorr2 = p2[0] + p2[1] / TMath::Sqrt( ADC ) + p2[2] * ADC + p2[3] * ADC * ADC +
491 p2[4] * ADC * ADC * ADC + p2[5] * ADC * ADC * ADC * ADC +
492 p2[6] * z / TMath::Sqrt( ADC ) + p2[7] / ADC + p2[8] * z / ADC +
493 p2[9] * z * ADC + p2[10] * z + p2[11] * z * z + p2[12] * z * z * z;
494 double time2 = TDC - tcorr2;
495
496 log << MSG::DEBUG << "EtfTime2 module =" << id << " strip=" << strip << " 1=" << p2[0]
497 << " 2=" << p2[1] << " 3=" << p2[2] << " 4=" << p2[3] << " 5=" << p2[4] << " 6=" << p2[5]
498 << " 7=" << p2[6] << " 8=" << p2[7] << " 9=" << p2[8] << " tcorr=" << tcorr2
499 << " time2=" << time2 << endmsg;
500 if ( time2 < 0. )
501 {
502 log << MSG::WARNING << "TofCaliSvc::EtfTime2() -- A minus time is given : " << time
503 << " [Input] ADC = " << ADC << " TDC = " << TDC << " z = " << z << " ID = " << id
504 << " Strip = " << strip << endmsg;
505 }
506
507 return time2;
508}

◆ EtfTof()

EstEtfCal * EstTofCaliSvc::EtfTof ( unsigned int id) const

Definition at line 558 of file EstTofCaliSvc.cxx.

558 {
559 return fEtfCal[72 * 12 * m_sequence + id];
560}

◆ ETime()

const double EstTofCaliSvc::ETime ( double ADC,
double TDC,
double rHit,
unsigned id )

Definition at line 402 of file EstTofCaliSvc.cxx.

402 {
403 MsgStream log( msgSvc(), name() );
404
405 double p[EstNEndPar];
406 for ( int i = 0; i < static_cast<int>( EstNEndPar ); i++ )
407 { p[i] = fETofCal[96 * m_sequence + id]->getP( i ); }
408
409 log << MSG::DEBUG << "ETime id =" << id << " 1=" << p[0] << " 2=" << p[1] << " 3=" << p[2]
410 << " 4=" << p[3] << " 5=" << p[4] << " 6=" << p[5] << " 7=" << p[6] << endmsg;
411
412 double time = TDC - ( p[0] + p[1] / TMath::Sqrt( ADC ) + p[2] / ADC + p[3] * ADC +
413 p[4] * rHit + p[5] * rHit * rHit + p[6] * rHit * rHit * rHit );
414
415 if ( time < 0. )
416 {
417 log << MSG::WARNING << "TofCaliSvc::ETime() -- A minus time is given : " << time
418 << " [Input] ADC = " << ADC << " TDC = " << TDC << " r = " << rHit << " ID = " << id
419 << endmsg;
420 }
421
422 return time;
423}

◆ ETof()

EstETofCal * EstTofCaliSvc::ETof ( unsigned id) const

Definition at line 556 of file EstTofCaliSvc.cxx.

556{ return fETofCal[96 * m_sequence + id]; }

◆ finalize()

StatusCode EstTofCaliSvc::finalize ( )
virtual

Definition at line 82 of file EstTofCaliSvc.cxx.

82 {
83 MsgStream log( msgSvc(), name() );
84 log << MSG::INFO << name() << ": End of Run" << endmsg;
85 return StatusCode::SUCCESS;
86}

◆ handle()

void EstTofCaliSvc::handle ( const Incident & inc)

Definition at line 577 of file EstTofCaliSvc.cxx.

577 {
578 MsgStream log( msgSvc(), name() );
579 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
580
581 if ( inc.type() == "NewRun" )
582 {
583 log << MSG::DEBUG << "New Run" << endmsg;
584 StatusCode sc = FillfromDatabase();
585 if ( sc.isSuccess() ) { m_hasbeeninitialized = true; }
586 }
587}

◆ initialize()

StatusCode EstTofCaliSvc::initialize ( )
virtual

Definition at line 49 of file EstTofCaliSvc.cxx.

49 {
50 m_hasbeeninitialized = false;
51 m_st = false;
52
53 MsgStream log( msgSvc(), name() );
54 log << MSG::INFO << name() << ": Start of run initialisation" << endmsg;
55
56 StatusCode sc = Service::initialize();
57 if ( sc.isFailure() ) return sc;
58
59 IIncidentSvc* incsvc;
60 sc = service( "IncidentSvc", incsvc );
61 int priority = 100;
62 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
63
64 StatusCode scc;
65
66 log << MSG::INFO << "setProperties()" << endmsg;
67 scc = service( "CalibDataSvc", m_pCalibDataSvc, true );
68 if ( !scc.isSuccess() )
69 {
70 log << MSG::ERROR << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
71 << endmsg;
72 return scc;
73 }
74 else
75 { log << MSG::DEBUG << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc" << endmsg; }
76 // Get properties from the JobOptionsSvc
77 // scc = setProperties();
78
79 return sc;
80}

Referenced by main().

◆ TOffset()

const double EstTofCaliSvc::TOffset ( )

Definition at line 355 of file EstTofCaliSvc.cxx.

355 {
356 double toffset = fBTofCommonCal[m_sequence]->getOffset( 0 );
357 return toffset;
358}

◆ TofInfo()

EstTofInfoCal * EstTofCaliSvc::TofInfo ( ) const

Definition at line 564 of file EstTofCaliSvc.cxx.

564{ return fTofInfoCal[m_sequence]; }

◆ ValidInfo()

const bool EstTofCaliSvc::ValidInfo ( )
inline

Definition at line 54 of file EstTofCaliSvc.h.

54{ return m_st; };

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