EstTofCaliSvc Class Reference

#include <EstTofCaliSvc.h>

Inheritance diagram for EstTofCaliSvc:

IEstTofCaliSvc List of all members.

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 &)
BTofCalBTof (unsigned id) const
BTofCommonCalBTofCommon () const
ETofCalETof (unsigned id) const
EtfCalEtfTof (unsigned int id) 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 ()
virtual EtfCalEtfTof (unsigned id) const =0
virtual const double ETime (double ADC, double TDC, double rHit, unsigned id)=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

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

StatusCode FillfromDatabase ()

Private Attributes

bool m_hasbeeninitialized
IDataProviderSvc * m_pCalibDataSvc
IntegerProperty m_run
std::vector< BTofCal * > fBTofCal
std::vector< ETofCal * > fETofCal
std::vector< EtfCal * > fEtfCal
std::vector< BTofCommonCal * > fBTofCommonCal
bool m_st

Detailed Description

Definition at line 22 of file EstTofCaliSvc.h.


Constructor & Destructor Documentation

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

Definition at line 42 of file EstTofCaliSvc.cxx.

References m_run.

00042                                                                          : Service(name, svcloc) {
00043   declareProperty("Run",m_run=1);
00044 }

EstTofCaliSvc::~EstTofCaliSvc (  ) 

Definition at line 95 of file EstTofCaliSvc.cxx.

References fBTofCal, fBTofCommonCal, fEtfCal, and fETofCal.

00095                              {
00096   for(vector<BTofCal*>::iterator it1 = fBTofCal.begin(); it1 != fBTofCal.end(); it1++) { delete (*it1); }
00097   fBTofCal.clear();
00098   for(vector<ETofCal*>::iterator it2 = fETofCal.begin(); it2 != fETofCal.end(); it2++) { delete (*it2); }
00099   fETofCal.clear();
00100   if( fEtfCal.size()!=0 ) {
00101     for(vector<EtfCal*>::iterator it5 = fEtfCal.begin(); it5 != fEtfCal.end(); it5++) { delete (*it5); }
00102     fEtfCal.clear();
00103   }
00104   for(vector<BTofCommonCal*>::iterator it3 = fBTofCommonCal.begin(); it3 != fBTofCommonCal.end(); it3++) { delete (*it3); }
00105   fBTofCommonCal.clear();
00106   return;
00107 }


Member Function Documentation

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

Implements IEstTofCaliSvc.

Referenced by BTime1().

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

Implements IEstTofCaliSvc.

Referenced by BTime2().

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

Implements IEstTofCaliSvc.

Definition at line 211 of file EstTofCaliSvc.cxx.

References BTCorr1(), Bes_Common::DEBUG, fBTofCommonCal, msgSvc(), and Bes_Common::WARNING.

00211                                                                             {
00212   MsgStream log(msgSvc(), name());    
00213 
00214   double tcorr1 = BTCorr1( ADC, z, id );
00215   double tcorr3 = fBTofCommonCal[0]->getOffset(0);
00216 
00217   log << MSG::DEBUG << "BTime1   id =" << id  << "  tcorr=" << tcorr1 << "  total offset=" << tcorr3 << endreq;
00218 
00219   double time = TDC - tcorr1 - tcorr3;
00220 
00221   if(time<0.) {
00222     log<<MSG::WARNING<<"TofCaliSvc::BTime1() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<endreq;
00223   }
00224   return time;     
00225 }

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

Implements IEstTofCaliSvc.

Definition at line 228 of file EstTofCaliSvc.cxx.

References BTCorr2(), Bes_Common::DEBUG, fBTofCommonCal, msgSvc(), and Bes_Common::WARNING.

00228                                                                             {
00229   MsgStream log(msgSvc(), name());    
00230 
00231   double tcorr1 = BTCorr2( ADC, z, id );
00232   double tcorr3 = fBTofCommonCal[0]->getOffset(0);
00233 
00234   log << MSG::DEBUG << "BTime2   id =" << id  << "  tcorr=" << tcorr1 << "  total offset=" << tcorr3 << endreq;
00235 
00236   double time = TDC - tcorr1 - tcorr3;
00237 
00238   if(time<0.) {
00239     log<<MSG::WARNING<<"TofCaliSvc::BTime2() -- A minus time is given : "<< time <<" [Input] ADC = "<<ADC<<" TDC = "<<TDC<<" z = "<<z<<" ID = "<<id<<endreq;
00240   }
00241   return time;     
00242 }

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

Implements IEstTofCaliSvc.

Definition at line 391 of file EstTofCaliSvc.cxx.

References fBTofCal.

Referenced by Dump().

00391                                              {
00392   return  fBTofCal[id];
00393 }

BTofCommonCal * EstTofCaliSvc::BTofCommon (  )  const [virtual]

Implements IEstTofCaliSvc.

Definition at line 403 of file EstTofCaliSvc.cxx.

References fBTofCommonCal.

00403                                               {
00404   return  fBTofCommonCal[0];
00405 }

void EstTofCaliSvc::Dump (  )  [virtual]

Implements IEstTofCaliSvc.

Definition at line 407 of file EstTofCaliSvc.cxx.

References BTof(), fBTofCal, fETofCal, and BTofCal::getP1().

Referenced by main().

00407                         {
00408   std::cout<<"Now We can get the TOF Calibtration Service"<<std::endl;
00409   std::cout<<"Barrel TOF Counter Number = "<<fBTofCal.size()<<std::endl;
00410   std::cout<<"Endcap TOF Counter Number = "<<fETofCal.size()<<std::endl;
00411 
00412   cout<<"The O  Barrel TOF PMT1 p1[0]  is"<<" "<<BTof(0)->getP1(0)<<endl; 
00413   cout<<"The 0  Barrel TOF PMT1 p1[1]  is"<<" "<<BTof(0)->getP1(1)<<endl; 
00414 }

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

Implements IEstTofCaliSvc.

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

Implements IEstTofCaliSvc.

virtual const double IEstTofCaliSvc::EtfTime1 ( double  ADC,
double  TDC,
double  zHit,
unsigned  id,
unsigned  strip 
) [pure virtual, inherited]

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

virtual const double IEstTofCaliSvc::EtfTime2 ( double  ADC,
double  TDC,
double  zHit,
unsigned  id,
unsigned  strip 
) [pure virtual, inherited]

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

virtual EtfCal* IEstTofCaliSvc::EtfTof ( unsigned  id  )  const [pure virtual, inherited]

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

virtual const double IEstTofCaliSvc::ETime ( double  ADC,
double  TDC,
double  rHit,
unsigned  id 
) [pure virtual, inherited]

Referenced by EsTimeAlg::execute().

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

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

Implements IEstTofCaliSvc.

Definition at line 395 of file EstTofCaliSvc.cxx.

References fETofCal.

00395                                              {
00396   return  fETofCal[id];
00397 }    

StatusCode EstTofCaliSvc::FillfromDatabase (  )  [private]

Definition at line 108 of file EstTofCaliSvc.cxx.

References Bes_Common::FATAL, fBTofCal, fBTofCommonCal, fEtfCal, fETofCal, genRecEmupikp::i, Bes_Common::INFO, m_pCalibDataSvc, m_st, msgSvc(), nBarOffset, nBarPar, nEndPar, nEtfPar, BTofCommonCal::setOffset(), deljobs::string, and test.

Referenced by handle().

00108                                           {
00109 
00110   MsgStream log(msgSvc(), name());    
00111   std::string fullPath = "/Calib/EstTofCal";
00112   log << MSG::INFO<<" Tof calib fullPath = "<<fullPath<< endreq;
00113   SmartDataPtr<CalibData::TofCalibData> test(m_pCalibDataSvc, fullPath);
00114   if(!test){
00115     log << MSG::FATAL << "EstTofCaliSvc could not find TofCalibData in TCDS!!" << endreq;
00116     m_st=false;    
00117     return StatusCode::FAILURE;
00118   }       
00119 
00120   m_st=true;
00121 
00122   for(vector<BTofCal*>::iterator it1 = fBTofCal.begin(); it1 != fBTofCal.end(); it1++) { delete (*it1); }
00123   fBTofCal.clear();
00124   for(vector<ETofCal*>::iterator it2 = fETofCal.begin(); it2 != fETofCal.end(); it2++) { delete (*it2); }
00125   fETofCal.clear();
00126   if( fEtfCal.size()!=0 ) {
00127     for(vector<EtfCal*>::iterator it5 = fEtfCal.begin(); it5 != fEtfCal.end(); it5++) { delete (*it5); }
00128     fEtfCal.clear();
00129   }
00130   for(vector<BTofCommonCal*>::iterator it3 = fBTofCommonCal.begin(); it3 != fBTofCommonCal.end(); it3++) { delete (*it3); }
00131   fBTofCommonCal.clear();
00132 
00133   for(int ib =0;ib<176;ib++){
00134     BTofCal* btof = new BTofCal;
00135     for(int i=0;i<static_cast<int>(nBarPar);i++){
00136       btof->setP1(i,test->getBTofPleft(ib,i));
00137       btof->setP2(i,test->getBTofPright(ib,i));
00138     }
00139     fBTofCal.push_back(btof);
00140   }       
00141 
00142   for(int ie=0;ie<96;ie++){
00143     ETofCal* etof= new ETofCal;
00144     for(int i=0;i<static_cast<int>(nEndPar);i++){
00145       etof->setP(i,test->getETofP(ie,i));
00146     }
00147     fETofCal.push_back(etof);
00148   }
00149 
00150   for(int ietf=0;ietf<72;ietf++) {
00151     for(int jetf=0;jetf<12;jetf++) {
00152       EtfCal* etf= new EtfCal;
00153       for( int k=0; k<static_cast<int>(nEtfPar); k++ ) {
00154         etf->setP( k,test->getEtfPcombine(ietf,jetf,k));
00155         etf->setP1(k,test->getEtfPleft(ietf,jetf,k));
00156         etf->setP2(k,test->getEtfPright(ietf,jetf,k));
00157       }
00158       fEtfCal.push_back(etf);
00159     }
00160   }
00161 
00162   BTofCommonCal* bcomtof = new BTofCommonCal;
00163   for(int i=0; i<static_cast<int>(nBarOffset); i++) {
00164     bcomtof->setOffset( i, test->getBTofOffset(i) );
00165   }
00166   fBTofCommonCal.push_back(bcomtof);
00167 
00168   return StatusCode::SUCCESS;
00169 
00170 }

StatusCode EstTofCaliSvc::finalize (  )  [virtual]

Definition at line 89 of file EstTofCaliSvc.cxx.

References Bes_Common::INFO, and msgSvc().

00089                                      {
00090   MsgStream log(msgSvc(), name());
00091   log << MSG::INFO << name() << ": End of Run" << endreq;
00092   return StatusCode::SUCCESS;
00093 }

void EstTofCaliSvc::handle ( const Incident &   ) 

Definition at line 416 of file EstTofCaliSvc.cxx.

References Bes_Common::DEBUG, FillfromDatabase(), and m_hasbeeninitialized.

00416                                              {
00417   MsgStream log( messageService(), name() );
00418   log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00419 
00420   if ( inc.type() == "NewRun" ){
00421     log << MSG::DEBUG << "New Run" << endreq;
00422     //    if(!m_hasbeeninitialized){
00423     StatusCode sc= FillfromDatabase();
00424     if(sc.isSuccess()){
00425       m_hasbeeninitialized=true;
00426     }
00427     //    }
00428   }
00429 }

StatusCode EstTofCaliSvc::initialize (  )  [virtual]

Definition at line 56 of file EstTofCaliSvc.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, Bes_Common::INFO, m_hasbeeninitialized, m_pCalibDataSvc, m_st, and msgSvc().

Referenced by main().

00056                                        {
00057   m_hasbeeninitialized=false;
00058   m_st=false;
00059 
00060   MsgStream log(msgSvc(), name());
00061   log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00062   
00063   StatusCode sc = Service::initialize();
00064   if ( sc.isFailure() ) return sc;
00065 
00066   IIncidentSvc* incsvc;
00067   sc = service("IncidentSvc", incsvc);
00068   int priority = 100;
00069   if( sc.isSuccess() ){
00070     incsvc -> addListener(this, "NewRun", priority);
00071   }
00072 
00073   StatusCode scc;
00074   
00075   log<<MSG::INFO << "setProperties()" << endreq;
00076   scc = service("CalibDataSvc", m_pCalibDataSvc, true);
00077   if ( !scc.isSuccess() ) {
00078     log<<MSG::ERROR<<"Could not get IDataProviderSvc interface of CalibXmlCnvSvc"<<endreq;
00079     return scc;
00080   } else {
00081     log << MSG::DEBUG<< "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc"<<endreq;
00082   }
00083   // Get properties from the JobOptionsSvc
00084   scc = setProperties();
00085   
00086   return sc;
00087 }  

static const InterfaceID& IEstTofCaliSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 18 of file IEstTofCaliSvc.h.

References IID_IEstTofCaliSvc().

00018 { return IID_IEstTofCaliSvc; }

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

Definition at line 46 of file EstTofCaliSvc.cxx.

References IID_IEstTofCaliSvc().

00046                                                                                       {
00047   
00048   if ( IID_IEstTofCaliSvc.versionMatch(riid) ) { 
00049     *ppvInterface = static_cast<IEstTofCaliSvc*> (this); 
00050   } else { 
00051     return Service::queryInterface(riid, ppvInterface) ; 
00052   }
00053   return StatusCode::SUCCESS;
00054 }

const double EstTofCaliSvc::TOffset (  )  [virtual]

Implements IEstTofCaliSvc.

Definition at line 205 of file EstTofCaliSvc.cxx.

References fBTofCommonCal.

00205                                     {
00206   double toffset = fBTofCommonCal[0]->getOffset(0);
00207   return toffset;
00208 }

const bool EstTofCaliSvc::ValidInfo (  )  [inline, virtual]

Implements IEstTofCaliSvc.

Definition at line 52 of file EstTofCaliSvc.h.

References m_st.

00052 {return m_st;};


Member Data Documentation

std::vector<BTofCal*> EstTofCaliSvc::fBTofCal [private]

Definition at line 61 of file EstTofCaliSvc.h.

Referenced by BTof(), Dump(), FillfromDatabase(), and ~EstTofCaliSvc().

std::vector<BTofCommonCal*> EstTofCaliSvc::fBTofCommonCal [private]

Definition at line 64 of file EstTofCaliSvc.h.

Referenced by BTime1(), BTime2(), BTofCommon(), FillfromDatabase(), TOffset(), and ~EstTofCaliSvc().

std::vector<EtfCal*> EstTofCaliSvc::fEtfCal [private]

Definition at line 63 of file EstTofCaliSvc.h.

Referenced by FillfromDatabase(), and ~EstTofCaliSvc().

std::vector<ETofCal*> EstTofCaliSvc::fETofCal [private]

Definition at line 62 of file EstTofCaliSvc.h.

Referenced by Dump(), ETof(), FillfromDatabase(), and ~EstTofCaliSvc().

bool EstTofCaliSvc::m_hasbeeninitialized [private]

Definition at line 56 of file EstTofCaliSvc.h.

Referenced by handle(), and initialize().

IDataProviderSvc* EstTofCaliSvc::m_pCalibDataSvc [private]

Definition at line 59 of file EstTofCaliSvc.h.

Referenced by FillfromDatabase(), and initialize().

IntegerProperty EstTofCaliSvc::m_run [private]

Definition at line 60 of file EstTofCaliSvc.h.

Referenced by EstTofCaliSvc().

bool EstTofCaliSvc::m_st [private]

Definition at line 66 of file EstTofCaliSvc.h.

Referenced by FillfromDatabase(), initialize(), and ValidInfo().


Generated on Tue Nov 29 23:18:48 2016 for BOSS_7.0.2 by  doxygen 1.4.7