BOSS 7.0.6
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 queryInterface (const InterfaceID &riid, void **ppvUnknown)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
StatusCode chooseConstants (int run, int number)
 
BTofCalBTof (unsigned id) const
 
BTofCommonCalBTofCommon () const
 
ETofCalETof (unsigned id) const
 
EtfCalEtfTof (unsigned int id) const
 
TofInfoCalTofInfo () const
 
const double BTCorr1 (double ADC, double zHit, unsigned int id)
 
const double BTCorr2 (double ADC, double zHit, unsigned int 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 int id)
 
const double EtfTime (double ADC1, double ADC2, double TDC1, double TDC2, unsigned int id, unsigned int strip)
 
const double EtfTime1 (double ADC, double TDC, double zHit, unsigned int id, unsigned int strip)
 
const double EtfTime2 (double ADC, double TDC, double zHit, unsigned int id, unsigned int strip)
 
const double EtfTime (double TDC1, double TDC2, unsigned int id, unsigned int strip)
 
const bool ValidInfo ()
 
void Dump ()
 
- Public Member Functions inherited from IEstTofCaliSvc
virtual StatusCode chooseConstants (int run, int event)=0
 
virtual BTofCalBTof (unsigned id) const =0
 
virtual BTofCommonCalBTofCommon () const =0
 
virtual ETofCalETof (unsigned id) const =0
 
virtual EtfCalEtfTof (unsigned id) const =0
 
virtual TofInfoCalTofInfo () const =0
 
virtual const double BTCorr1 (double ADC, double zHit, unsigned int id)=0
 
virtual const double BTCorr2 (double ADC, double zHit, unsigned int id)=0
 
virtual const double TOffset ()=0
 
virtual const double BTime1 (double ADC, double TDC, double zHit, unsigned id)=0
 
virtual const double BTime2 (double ADC, double TDC, double zHit, unsigned id)=0
 
virtual const double ETime (double ADC, double TDC, double rHit, unsigned id)=0
 
virtual const double EtfTime (double ADC1, double ADC2, double TDC1, double TDC2, unsigned int id, unsigned int strip)=0
 
virtual const double EtfTime1 (double ADC, double TDC, double zHit, unsigned id, unsigned strip)=0
 
virtual const double EtfTime2 (double ADC, double TDC, double zHit, unsigned id, unsigned strip)=0
 
virtual const double EtfTime (double TDC1, double TDC2, unsigned int id, unsigned int strip)=0
 
virtual const bool ValidInfo ()=0
 
virtual void Dump ()=0
 

Additional Inherited Members

- Static Public Member Functions inherited from IEstTofCaliSvc
static const InterfaceID & interfaceID ()
 

Detailed Description

Definition at line 23 of file EstTofCaliSvc.h.

Constructor & Destructor Documentation

◆ EstTofCaliSvc()

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

Definition at line 43 of file EstTofCaliSvc.cxx.

43 : Service(name, svcloc) {
44 declareProperty("Run",m_run=1);
45}

◆ ~EstTofCaliSvc()

EstTofCaliSvc::~EstTofCaliSvc ( )

Definition at line 96 of file EstTofCaliSvc.cxx.

96 {
97 for(vector<BTofCal*>::iterator it1 = fBTofCal.begin(); it1 != fBTofCal.end(); it1++) { delete (*it1); }
98 fBTofCal.clear();
99 for(vector<ETofCal*>::iterator it2 = fETofCal.begin(); it2 != fETofCal.end(); it2++) { delete (*it2); }
100 fETofCal.clear();
101 if( fEtfCal.size()!=0 ) {
102 for(vector<EtfCal*>::iterator it5 = fEtfCal.begin(); it5 != fEtfCal.end(); it5++) { delete (*it5); }
103 fEtfCal.clear();
104 }
105 for(vector<BTofCommonCal*>::iterator it3 = fBTofCommonCal.begin(); it3 != fBTofCommonCal.end(); it3++) { delete (*it3); }
106 fBTofCommonCal.clear();
107 for(vector<TofInfoCal*>::iterator it4 = fTofInfoCal.begin(); it4 != fTofInfoCal.end(); it4++) { delete (*it4); }
108 fTofInfoCal.clear();
109 return;
110}

Member Function Documentation

◆ BTCorr1()

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

Implements IEstTofCaliSvc.

Definition at line 260 of file EstTofCaliSvc.cxx.

260 {
261 MsgStream log(msgSvc(), name());
262
263 double p1[nBarPar];
264 for( int i=0; i<static_cast<int>(nBarPar); i++ ) {
265 p1[i]=fBTofCal[176*m_sequence+id]->getP1(i);
266 }
267
268 log << MSG::DEBUG << "BTCorr1 id =" << id << " 1=" << p1[0] << " 2=" << p1[1] << " 3=" << p1[2] << " 4=" << p1[3] << " 5=" << p1[4] << " 6=" << p1[5] << " 7=" << p1[6] << " 8=" << p1[7] << " 9=" << p1[8] << endreq;
269
270 double tcorr1 = p1[0] + p1[1]/TMath::Sqrt(ADC) + p1[2]*z/TMath::Sqrt(ADC) + p1[3]/ADC + p1[4]*z + p1[5]*z*z + p1[6]*z*z*z;
271
272 return tcorr1;
273}
const unsigned int nBarPar
IMessageSvc * msgSvc()

Referenced by BTime1().

◆ BTCorr2()

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

Implements IEstTofCaliSvc.

Definition at line 276 of file EstTofCaliSvc.cxx.

276 {
277 MsgStream log(msgSvc(), name());
278
279 double p2[nBarPar];
280 for( int i=0; i<static_cast<int>(nBarPar); i++ ) {
281 p2[i]=fBTofCal[176*m_sequence+id]->getP2(i);
282 }
283
284 log << MSG::DEBUG << "BTCorr2 id =" << id << " 1=" << p2[0] << " 2=" << p2[1] << " 3=" << p2[2] << " 4=" << p2[3] << " 5=" << p2[4] << " 6=" << p2[5] << " 7=" << p2[6] << " 8=" << p2[7] << " 9=" << p2[8] << endreq;
285
286 double tcorr2 = p2[0] + p2[1]/TMath::Sqrt(ADC) + p2[2]*z/TMath::Sqrt(ADC) + p2[3]/ADC + p2[4]*z + p2[5]*z*z + p2[6]*z*z*z;
287
288 return tcorr2;
289}

Referenced by BTime2().

◆ BTime1()

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

Implements IEstTofCaliSvc.

Definition at line 298 of file EstTofCaliSvc.cxx.

298 {
299 MsgStream log(msgSvc(), name());
300
301 double tcorr1 = BTCorr1( ADC, z, id );
302 double tcorr3 = fBTofCommonCal[m_sequence]->getOffset(0);
303
304 log << MSG::DEBUG << "BTime1 id =" << id << " tcorr=" << tcorr1 << " total offset=" << tcorr3 << endreq;
305
306 double time = TDC - tcorr1 - tcorr3;
307
308 if(time<0.) {
309 log<<MSG::WARNING<<"TofCaliSvc::BTime1() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<endreq;
310 }
311 return time;
312}
const double BTCorr1(double ADC, double zHit, unsigned int id)

◆ BTime2()

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

Implements IEstTofCaliSvc.

Definition at line 315 of file EstTofCaliSvc.cxx.

315 {
316 MsgStream log(msgSvc(), name());
317
318 double tcorr1 = BTCorr2( ADC, z, id );
319 double tcorr3 = fBTofCommonCal[m_sequence]->getOffset(0);
320
321 log << MSG::DEBUG << "BTime2 id =" << id << " tcorr=" << tcorr1 << " total offset=" << tcorr3 << endreq;
322
323 double time = TDC - tcorr1 - tcorr3;
324
325 if(time<0.) {
326 log<<MSG::WARNING<<"TofCaliSvc::BTime2() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<endreq;
327 }
328 return time;
329}
const double BTCorr2(double ADC, double zHit, unsigned int id)

◆ BTof()

BTofCal * EstTofCaliSvc::BTof ( unsigned  id) const
virtual

Implements IEstTofCaliSvc.

Definition at line 478 of file EstTofCaliSvc.cxx.

478 {
479 return fBTofCal[176*m_sequence+id];
480}

Referenced by Dump().

◆ BTofCommon()

BTofCommonCal * EstTofCaliSvc::BTofCommon ( ) const
virtual

Implements IEstTofCaliSvc.

Definition at line 490 of file EstTofCaliSvc.cxx.

490 {
491 return fBTofCommonCal[m_sequence];
492}

◆ chooseConstants()

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

Implements IEstTofCaliSvc.

Definition at line 196 of file EstTofCaliSvc.cxx.

196 {
197
198 MsgStream log(msgSvc(), name());
199
200 m_sequence = 0;
201 bool filled = false;
202 unsigned int inumber = 0;
203 std::vector<TofInfoCal*>::iterator it = fTofInfoCal.begin();
204 if( (*it)->getRunFrom() == -1 ) {
205 if( fTofInfoCal.size() == 1 ) {
206 log << MSG::INFO << "EstTofCaliSvc::chooseConstants() -- Run From is equal to -1! The ONLY TOF calibration constants are used!" << endreq;
207 return StatusCode::SUCCESS;
208 }
209 else {
210 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- Run From is equal to -1! The NUMBER of calibration constants are NOT equal to 1!" << endreq;
211 return StatusCode::FAILURE;
212 }
213 }
214
215 for( ; it!= fTofInfoCal.end(); it++, inumber++ ) {
216 if( ( (*it)->getRunTo() != -1 ) && ( (*it)->getRunTo() < (*it)->getRunFrom() ) ) {
217 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The " << inumber << "th calibration constatns is ABNORMAL! Run From is LARGER than RUN To!" << endreq;
218 return StatusCode::FAILURE;
219 }
220 if( ( (*it)->getRunFrom() == (*it)->getRunTo() ) && ( (*it)->getEventFrom() != -1 ) && ( (*it)->getEventTo() != -1 ) && ( (*it)->getEventFrom() > (*it)->getEventTo() ) ) {
221 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The " << inumber << "th calibration constatns is ABNORMAL! Event From is LARGER than Event To!" << endreq;
222 return StatusCode::FAILURE;
223 }
224 }
225
226 it = fTofInfoCal.begin();
227 inumber = 0;
228 for( ; it!= fTofInfoCal.end(); it++, inumber++ ) {
229 int runFrom = (*it)->getRunFrom();
230 int runTo = (*it)->getRunTo();
231 int eventFrom = (*it)->getEventFrom();
232 int eventTo = (*it)->getEventTo();
233 if( ( run == runFrom ) && ( ( eventFrom == -1 ) || ( event >= eventFrom ) ) ) {
234 if( ( run < runTo ) || ( ( run == runTo ) && ( ( eventTo == -1 ) || ( event <= eventTo ) ) ) ) {
235 filled = true;
236 break;
237 }
238 }
239 if( run > runFrom ) {
240 if( ( run < runTo ) || ( ( run == runTo ) && ( ( eventTo == -1 ) || ( event <= eventTo ) ) ) ) {
241 filled = true;
242 break;
243 }
244 }
245 }
246
247 if( filled ) {
248 m_sequence = inumber;
249 }
250 else {
251 log << MSG::ERROR << "EstTofCaliSvc::chooseConstants() -- The event with run number " << run << " and event number " << event << " is NOT suitable for this group of calibration constants"
252 << endreq;
253 return StatusCode::FAILURE;
254 }
255
256 return StatusCode::SUCCESS;
257}

◆ Dump()

void EstTofCaliSvc::Dump ( )
virtual

Implements IEstTofCaliSvc.

Definition at line 500 of file EstTofCaliSvc.cxx.

500 {
501 std::cout<<"Now We can get the TOF Calibtration Service"<<std::endl;
502 std::cout<<"Barrel TOF Counter Number = "<<fBTofCal.size()<<std::endl;
503 std::cout<<"Endcap TOF Counter Number = "<<fETofCal.size()<<std::endl;
504
505 cout<<"The O Barrel TOF PMT1 p1[0] is"<<" "<<BTof(0)->getP1(0)<<endl;
506 cout<<"The 0 Barrel TOF PMT1 p1[1] is"<<" "<<BTof(0)->getP1(1)<<endl;
507}
BTofCal * BTof(unsigned id) const

Referenced by main().

◆ EtfTime() [1/2]

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

Implements IEstTofCaliSvc.

◆ EtfTime() [2/2]

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

Implements IEstTofCaliSvc.

◆ EtfTime1()

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

Definition at line 381 of file EstTofCaliSvc.cxx.

381 {
382 MsgStream log(msgSvc(), name());
383
384 double p1[nEtfPar];
385 for( int i=0; i<static_cast<int>(nEtfPar); i++ ) {
386 p1[i]=fEtfCal[72*12*m_sequence+12*id+strip]->getP1(i);
387 }
388
389 double tcorr1 = p1[0]
390 + p1[1]/TMath::Sqrt(ADC)
391 + p1[2]*ADC
392 + p1[3]*ADC*ADC
393 + p1[4]*ADC*ADC*ADC
394 + p1[5]*ADC*ADC*ADC*ADC
395 + p1[6]*z/TMath::Sqrt(ADC)
396 + p1[7]/ADC
397 + p1[8]*z/ADC
398 + p1[9]*z*ADC
399 + p1[10]*z
400 + p1[11]*z*z
401 + p1[12]*z*z*z;
402 double time1 = TDC - tcorr1;
403
404 log << MSG::DEBUG << "EtfTime1 module =" << id << " strip=" << strip << " 1=" << p1[0] << " 2=" << p1[1] << " 3=" << p1[2] << " 4=" << p1[3] << " 5=" << p1[4] << " 6=" << p1[5] << " 7=" << p1[6] << " 8=" << p1[7] << " 9=" << p1[8] << " tcorr=" << tcorr1 << " time1=" << time1 << endreq;
405 if( time1<0.) {
406 log<<MSG::WARNING<<"TofCaliSvc::EtfTime1() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<" Strip = "<<strip<<endreq;
407 }
408
409 return time1;
410}
const unsigned int nEtfPar

◆ EtfTime2()

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

Definition at line 413 of file EstTofCaliSvc.cxx.

413 {
414 MsgStream log(msgSvc(), name());
415
416 double p2[nEtfPar];
417 for( int i=0; i<static_cast<int>(nEtfPar); i++ ) {
418 p2[i]=fEtfCal[72*12*m_sequence+12*id+strip]->getP2(i);
419 }
420
421 double tcorr2 = p2[0]
422 + p2[1]/TMath::Sqrt(ADC)
423 + p2[2]*ADC
424 + p2[3]*ADC*ADC
425 + p2[4]*ADC*ADC*ADC
426 + p2[5]*ADC*ADC*ADC*ADC
427 + p2[6]*z/TMath::Sqrt(ADC)
428 + p2[7]/ADC
429 + p2[8]*z/ADC
430 + p2[9]*z*ADC
431 + p2[10]*z
432 + p2[11]*z*z
433 + p2[12]*z*z*z;
434 double time2 = TDC - tcorr2;
435
436 log << MSG::DEBUG << "EtfTime2 module =" << id << " strip=" << strip << " 1=" << p2[0] << " 2=" << p2[1] << " 3=" << p2[2] << " 4=" << p2[3] << " 5=" << p2[4] << " 6=" << p2[5] << " 7=" << p2[6] << " 8=" << p2[7] << " 9=" << p2[8] << " tcorr=" << tcorr2 << " time2=" << time2 << endreq;
437 if( time2<0.) {
438 log<<MSG::WARNING<<"TofCaliSvc::EtfTime2() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<" Strip = "<<strip<<endreq;
439 }
440
441 return time2;
442}

◆ EtfTof()

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

Definition at line 486 of file EstTofCaliSvc.cxx.

486 {
487 return fEtfCal[72*12*m_sequence+id];
488}

◆ ETime()

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

Definition at line 332 of file EstTofCaliSvc.cxx.

332 {
333 MsgStream log(msgSvc(), name());
334
335 double p[nEndPar];
336 for( int i=0; i<static_cast<int>(nEndPar); i++ ) {
337 p[i]=fETofCal[96*m_sequence+id]->getP(i);
338 }
339
340 log << MSG::DEBUG << "ETime id =" << id << " 1=" << p[0] << " 2=" << p[1] << " 3=" << p[2] << " 4=" << p[3] << " 5=" << p[4] << " 6=" << p[5] << " 7=" << p[6] << endreq;
341
342 double time=TDC-(p[0]+p[1]/TMath::Sqrt(ADC)+p[2]/ADC+p[3]*ADC+p[4]*rHit+p[5]*rHit*rHit+p[6]*rHit*rHit*rHit);
343
344 if(time<0.) {
345 log<<MSG::WARNING<<"TofCaliSvc::ETime() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" r = "<< rHit <<" ID = "<<id<<endreq;
346 }
347
348 return time;
349}
const unsigned int nEndPar

◆ ETof()

ETofCal * EstTofCaliSvc::ETof ( unsigned  id) const
virtual

Implements IEstTofCaliSvc.

Definition at line 482 of file EstTofCaliSvc.cxx.

482 {
483 return fETofCal[96*m_sequence+id];
484}

◆ finalize()

StatusCode EstTofCaliSvc::finalize ( )
virtual

Definition at line 90 of file EstTofCaliSvc.cxx.

90 {
91 MsgStream log(msgSvc(), name());
92 log << MSG::INFO << name() << ": End of Run" << endreq;
93 return StatusCode::SUCCESS;
94}

◆ handle()

void EstTofCaliSvc::handle ( const Incident &  inc)

Definition at line 509 of file EstTofCaliSvc.cxx.

509 {
510 MsgStream log( messageService(), name() );
511 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
512
513 if ( inc.type() == "NewRun" ){
514 log << MSG::DEBUG << "New Run" << endreq;
515 // if(!m_hasbeeninitialized){
516 StatusCode sc= FillfromDatabase();
517 if(sc.isSuccess()){
518 m_hasbeeninitialized=true;
519 }
520 // }
521 }
522}

◆ initialize()

StatusCode EstTofCaliSvc::initialize ( )
virtual

Definition at line 57 of file EstTofCaliSvc.cxx.

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

Referenced by main().

◆ queryInterface()

StatusCode EstTofCaliSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
)
virtual

Definition at line 47 of file EstTofCaliSvc.cxx.

47 {
48
49 if ( IID_IEstTofCaliSvc.versionMatch(riid) ) {
50 *ppvInterface = static_cast<IEstTofCaliSvc*> (this);
51 } else {
52 return Service::queryInterface(riid, ppvInterface) ;
53 }
54 return StatusCode::SUCCESS;
55}

◆ TOffset()

const double EstTofCaliSvc::TOffset ( )
virtual

Implements IEstTofCaliSvc.

Definition at line 292 of file EstTofCaliSvc.cxx.

292 {
293 double toffset = fBTofCommonCal[m_sequence]->getOffset(0);
294 return toffset;
295}

◆ TofInfo()

TofInfoCal * EstTofCaliSvc::TofInfo ( ) const
virtual

Implements IEstTofCaliSvc.

Definition at line 495 of file EstTofCaliSvc.cxx.

495 {
496 return fTofInfoCal[m_sequence];
497}

◆ ValidInfo()

const bool EstTofCaliSvc::ValidInfo ( )
inlinevirtual

Implements IEstTofCaliSvc.

Definition at line 56 of file EstTofCaliSvc.h.

56{return m_st;};

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