Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TofQElecSvc Class Reference

#include <TofQElecSvc.h>

Inheritance diagram for TofQElecSvc:

ITofQElecSvc ITofQElecSvc List of all members.

Public Member Functions

const unsigned int Board (bool barrel, int id, bool eastEnd)
const unsigned int Board (bool barrel, int id, bool eastEnd)
const double BQChannel1 (int id, double qtc)
const double BQChannel1 (int id, double qtc)
const double BQChannel2 (int id, double qtc)
const double BQChannel2 (int id, double qtc)
const double BQTC1 (int id, double q)
const double BQTC1 (int id, double q)
const double BQTC2 (int id, double q)
const double BQTC2 (int id, double q)
const unsigned int Channel (bool barrel, int id, bool eastEnd)
const unsigned int Channel (bool barrel, int id, bool eastEnd)
const unsigned int Crate (bool barrel, int id, bool eastEnd)
const unsigned int Crate (bool barrel, int id, bool eastEnd)
const double EQChannel (int id, double qtc)
const double EQChannel (int id, double qtc)
const double EQTC (int id, double q)
const double EQTC (int id, double q)
const unsigned int Fee (bool barrel, int id, bool eastEnd)
const unsigned int Fee (bool barrel, int id, bool eastEnd)
virtual StatusCode finalize ()
virtual StatusCode finalize ()
void handle (const Incident &)
void handle (const Incident &)
virtual StatusCode initialize ()
virtual StatusCode initialize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 TofQElecSvc (const std::string &name, ISvcLocator *svcloc)
 TofQElecSvc (const std::string &name, ISvcLocator *svcloc)
 ~TofQElecSvc ()
 ~TofQElecSvc ()

Static Public Member Functions

const InterfaceID & interfaceID ()
const InterfaceID & interfaceID ()

Private Member Functions

StatusCode FillfromDatabase ()
StatusCode FillfromDatabase ()

Private Attributes

CalibData::TofElecDatam_data
CalibData::TofElecDatam_data
bool m_hasbeeninitialized
IDataProviderSvc * m_pCalibDataSvc
IDataProviderSvc * m_pCalibDataSvc
IntegerProperty m_run

Constructor & Destructor Documentation

TofQElecSvc::TofQElecSvc const std::string &  name,
ISvcLocator *  svcloc
 

00022                                                                      : Service(name, svcloc) {
00023   declareProperty("Run",m_run=1);
00024 }

TofQElecSvc::~TofQElecSvc  ) 
 

00076                          {
00077   delete m_data;
00078   return;
00079 }

TofQElecSvc::TofQElecSvc const std::string &  name,
ISvcLocator *  svcloc
 

TofQElecSvc::~TofQElecSvc  ) 
 


Member Function Documentation

const unsigned int TofQElecSvc::Board bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

const unsigned int TofQElecSvc::Board bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

00151                                                                          {
00152   MsgStream log(msgSvc(), name());    
00153 
00154   if( barrel ) {
00155     if( id<0 || id>175 ) {
00156       log << MSG::WARNING <<"Board : TofId is out of Range, tofid=" << id << endreq;  
00157       return 1000;
00158     }
00159   }
00160   else {
00161     if( id<0 || id>95 ) {
00162       log << MSG::WARNING <<"Board : TofId is out of Range, tofid=" << id << endreq;  
00163       return 1000;
00164     }
00165   }
00166 
00167   unsigned int board;
00168   if( barrel ) {
00169     if( eastEnd ) {
00170       board = (m_data->getBTof(id)).getNumEast(0);
00171     }
00172     else {
00173       board = (m_data->getBTof(id)).getNumWest(0);
00174     }
00175   }
00176   else {
00177     board = (m_data->getETof(id)).getNum(0);
00178   }
00179 
00180   return board;
00181 }

const double TofQElecSvc::BQChannel1 int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::BQChannel1 int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

00361                                                        {
00362   double qChannel = -999.0;
00363   MsgStream log(msgSvc(), name());
00364   if( id<0 || id>175 ) {
00365     log << MSG::ERROR <<"BChannel1 : TofId is out of Range, tofid=" << id << endreq;  
00366     return qChannel;
00367   }
00368 
00369   double ratio = (m_data->getBTof(id)).getSimP1(0);
00370   double p[10];
00371   for(unsigned int i=0; i<10; i++ ) {
00372     p[i] = (m_data->getBTof(id)).getSimP1(i+1);
00373   }
00374   qChannel = ( p[0] + p[1]*qtc + p[2]*qtc*qtc + p[3]*qtc*qtc*qtc )*( 1.0 - TMath::Erf((qtc-p[4])/p[5]) ) + ( p[6] + p[7]*qtc )*( 1.0 + TMath::Erf((qtc-p[8])/p[9]) );
00375   qChannel = ratio*qChannel;
00376 
00377   //  cout << "Sim East tofid=" << id << " ratio=" << ratio;
00378   //  for( unsigned int i=0; i<11; i++ ) { cout << " P" << i << "= " << p[i]; }
00379   //  cout << endl;
00380 
00381   return qChannel;
00382 }

const double TofQElecSvc::BQChannel2 int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::BQChannel2 int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

00385                                                        {
00386   double qChannel = -999.0;
00387   MsgStream log(msgSvc(), name());    
00388   if( id<0 || id>175 ) {
00389     log << MSG::ERROR <<"BChannel2 : TofId is out of Range, tofid=" << id << endreq;  
00390     return qChannel;
00391   }
00392 
00393   double ratio = (m_data->getBTof(id)).getSimP2(0);
00394   double p[10];
00395   for(unsigned int i=0; i<10; i++ ) {
00396     p[i] = (m_data->getBTof(id)).getSimP2(i+1);
00397   }
00398   qChannel = ( p[0] + p[1]*qtc + p[2]*qtc*qtc + p[3]*qtc*qtc*qtc )*( 1.0 - TMath::Erf((qtc-p[4])/p[5]) ) + ( p[6] + p[7]*qtc )*( 1.0 + TMath::Erf((qtc-p[8])/p[9]) );
00399   qChannel = ratio*qChannel;
00400 
00401   //  cout << "Sim West tofid=" << id << " ratio=" << ratio;
00402   //  for( unsigned int i=0; i<11; i++ ) { cout << " P" << i << "= " << p[i]; }
00403   //  cout << endl;
00404 
00405   return qChannel;
00406 }

const double TofQElecSvc::BQTC1 int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::BQTC1 int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

00283                                                 {
00284   double qtcNew = -999.0;
00285   MsgStream log(msgSvc(), name());    
00286   if( id<0 || id>175 ) {
00287     log << MSG::WARNING <<"BQTC1 : TofId is out of Range, tofid=" << id << endreq;
00288     return qtcNew;
00289   }
00290   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00291   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00292 
00293   double ratio = (m_data->getBTof(id)).getP1(0);
00294   double p[10];
00295   for(unsigned int i=0; i<10; i++ ) {
00296     p[i] = (m_data->getBTof(id)).getP1(i+1);
00297   }
00298   q = q*ratio;
00299   qtcNew = p[0] + p[1]*q + p[2]*q*q + p[3]*q*q*q + p[4]*q*q*q*q + p[7]*exp(p[5]*(q-p[6]));
00300 
00301   //  cout << "East tofid=" << id << " ratio=" << ratio;
00302   //  for( unsigned int i=0; i<8; i++ ) { cout << " P" << i << "= " << p[i]; }
00303   //  cout << endl;
00304 
00305   return qtcNew;
00306 }

const double TofQElecSvc::BQTC2 int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::BQTC2 int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

00309                                                 {
00310   double qtcNew = -999.0;
00311   MsgStream log(msgSvc(), name());    
00312   if( id<0 || id>175 ) {
00313     log << MSG::WARNING <<"BQTC2 : TofId is out of Range, tofid=" << id << endreq;
00314     return qtcNew;
00315   }
00316   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00317   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00318 
00319   double ratio = (m_data->getBTof(id)).getP2(0);
00320   double p[10];
00321   for(unsigned int i=0; i<10; i++ ) {
00322     p[i] = (m_data->getBTof(id)).getP2(i+1);
00323   }
00324   q = q*ratio;
00325   qtcNew = p[0] + p[1]*q + p[2]*q*q + p[3]*q*q*q + p[4]*q*q*q*q + p[7]*exp(p[5]*(q-p[6]));
00326 
00327   //  cout << "West tofid=" << id << " ratio=" << ratio;
00328   //  for( unsigned int i=0; i<8; i++ ) { cout << " P" << i << "= " << p[i]; }
00329   //  cout << endl;
00330 
00331   return qtcNew;
00332 }

const unsigned int TofQElecSvc::Channel bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

const unsigned int TofQElecSvc::Channel bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

00250                                                                            {
00251   MsgStream log(msgSvc(), name());    
00252 
00253   if( barrel ) {
00254     if( id<0 || id>175 ) {
00255       log << MSG::WARNING <<"Channel : TofId is out of Range, tofid=" << id << endreq;  
00256       return 1000;
00257     }
00258   }
00259   else {
00260     if( id<0 || id>95 ) {
00261       log << MSG::WARNING <<"Channel : TofId is out of Range, tofid=" << id << endreq;  
00262       return 1000;
00263     }
00264   }
00265 
00266   unsigned int channel;
00267   if( barrel ) {
00268     if( eastEnd ) {
00269       channel = (m_data->getBTof(id)).getNumEast(1);
00270     }
00271     else {
00272       channel = (m_data->getBTof(id)).getNumWest(1);
00273     }
00274   }
00275   else {
00276     channel = (m_data->getETof(id)).getNum(1);
00277   }
00278 
00279   return channel;
00280 }

const unsigned int TofQElecSvc::Crate bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

const unsigned int TofQElecSvc::Crate bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

00184                                                                          {
00185   MsgStream log(msgSvc(), name());    
00186 
00187   if( barrel ) {
00188     if( id<0 || id>175 ) {
00189       log << MSG::WARNING <<"Crate : TofId is out of Range, tofid=" << id << endreq;  
00190       return 1000;
00191     }
00192   }
00193   else {
00194     if( id<0 || id>95 ) {
00195       log << MSG::WARNING <<"Crate : TofId is out of Range, tofid=" << id << endreq;
00196       return 1000;
00197     }
00198   }
00199 
00200   unsigned int crate;
00201   if( barrel ) {
00202     if( eastEnd ) {
00203       crate = (m_data->getBTof(id)).getNumEast(2);
00204     }
00205     else {
00206       crate = (m_data->getBTof(id)).getNumWest(2);
00207     }
00208   }
00209   else {
00210     crate = (m_data->getETof(id)).getNum(2);
00211   }
00212 
00213   return crate;
00214 }

const double TofQElecSvc::EQChannel int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::EQChannel int  id,
double  qtc
[virtual]
 

Implements ITofQElecSvc.

00409                                                       {
00410   double qChannel = -999.0;
00411   MsgStream log(msgSvc(), name());    
00412   if( id<0 || id>95 ) {
00413     log << MSG::ERROR <<"EQTC : TofId is out of Range, tofid=" << id << endreq;
00414     return qChannel;
00415   }
00416 
00417   double ratio = (m_data->getETof(id)).getSimP(0);
00418   double p[10];
00419   for(unsigned int i=0; i<10; i++ ) {
00420     p[i] = (m_data->getETof(id)).getSimP(i+1);
00421   }
00422   qChannel = ( p[0] + p[1]*qtc + p[2]*qtc*qtc + p[3]*qtc*qtc*qtc )*( 1.0 - TMath::Erf((qtc-p[4])/p[5]) ) + ( p[6] + p[7]*qtc )*( 1.0 + TMath::Erf((qtc-p[8])/p[9]) );
00423   qChannel = ratio*qChannel;
00424 
00425   //  cout << "Endcap tofid=" << id << " ratio=" << ratio;
00426   //  for( unsigned int i=0; i<11; i++ ) { cout << " P" << i << "= " << p[i]; }
00427   //  cout << endl;
00428 
00429   return qChannel;
00430 }

const double TofQElecSvc::EQTC int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

const double TofQElecSvc::EQTC int  id,
double  q
[virtual]
 

Implements ITofQElecSvc.

00335                                                {
00336   double qtcNew = -999.0;
00337   MsgStream log(msgSvc(), name());    
00338   if( id<0 || id>95 ) {
00339     log << MSG::WARNING <<"EQTC : TofId is out of Range, tofid=" << id << endreq;
00340     return qtcNew;
00341   }
00342   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00343   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00344 
00345   double ratio = (m_data->getETof(id)).getP(0);
00346   double p[10];
00347   for(unsigned int i=0; i<10; i++ ) {
00348     p[i] = (m_data->getETof(id)).getP(i+1);
00349   }
00350   q = q*ratio;
00351   qtcNew = p[0] + p[1]*q + p[2]*q*q + p[3]*q*q*q + p[4]*q*q*q*q + p[7]*exp(p[5]*(q-p[6]));
00352 
00353   //  cout << "Endcap tofid=" << id << " ratio=" << ratio;
00354   //  for( unsigned int i=0; i<8; i++ ) { cout << " P" << i << "= " << p[i]; }
00355   //  cout << endl;
00356 
00357   return qtcNew;
00358 }

const unsigned int TofQElecSvc::Fee bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

const unsigned int TofQElecSvc::Fee bool  barrel,
int  id,
bool  eastEnd
[virtual]
 

Implements ITofQElecSvc.

00217                                                                        {
00218   MsgStream log(msgSvc(), name());    
00219 
00220   if( barrel ) {
00221     if( id<0 || id>175 ) {
00222       log << MSG::WARNING <<"Fee : TofId is out of Range, tofid=" << id << endreq;  
00223       return 1000;
00224     }
00225   }
00226   else {
00227     if( id<0 || id>95 ) {
00228       log << MSG::WARNING <<"Fee : TofId is out of Range, tofid=" << id << endreq;  
00229       return 1000;
00230     }
00231   }
00232 
00233   unsigned int crate;
00234   if( barrel ) {
00235     if( eastEnd ) {
00236       crate = (m_data->getBTof(id)).getNumEast(3);
00237     }
00238     else {
00239       crate = (m_data->getBTof(id)).getNumWest(3);
00240     }
00241   }
00242   else {
00243     crate = (m_data->getETof(id)).getNum(3);
00244   }
00245 
00246   return crate;
00247 }

StatusCode TofQElecSvc::FillfromDatabase  )  [private]
 

StatusCode TofQElecSvc::FillfromDatabase  )  [private]
 

00082                                         {
00083 
00084   MsgStream log(msgSvc(), name());    
00085   std::string fullPath = "/Calib/TofQElec";
00086   log << MSG::INFO<<" Tof calib fullPath = "<<fullPath<< endreq;
00087   SmartDataPtr<CalibData::TofElecData> test(m_pCalibDataSvc, fullPath);
00088   if(!test){
00089     log << MSG::FATAL << "TofQElecSvc could not find TofQElecData in TCDS!!" << endreq;
00090     return StatusCode::FAILURE;
00091   }       
00092 
00093   if(m_data) delete m_data;
00094   m_data = new CalibData::TofElecData;
00095   m_data->sim(test);
00096    
00097   /*
00098   for( vector<CalibData::BarrelElec*>::iterator iter1 = fBarrelElec.begin(); iter1 != fBarrelElec.end(); iter1++ ) {
00099     delete *iter1;
00100   }
00101   fBarrelElec.clear();
00102   for( vector<CalibData::EndcapElec*>::iterator iter2 = fEndcapElec.begin(); iter2 != fEndcapElec.end(); iter2++ ) {
00103     delete *iter2;
00104   }
00105   fEndcapElec.clear();
00106 
00107   for( unsigned ib=0; ib<176; ib++ ) {
00108     BarrelElec* bElec = new BarrelElec;
00109     for( unsigned int j=0; j<4; j++ ) {
00110       bElec->setNumEast( j, ib );
00111       bElec->setNumWest( j, ib );
00112     }
00113     for( unsigned int k=0; k<11; k++ ) {
00114       bElec->setP1( k, ib );
00115       bElec->setP2( k, ib );
00116       bElec->setSimP1( k, ib );
00117       bElec->setSimP2( k, ib );
00118     }
00119     fBarrelElec.push_back( bElec );
00120   }
00121 
00122   for( unsigned ie=0; ie<96; ie++ ) {
00123     EndcapElec* eElec = new EndcapElec;
00124     for( unsigned int j=0; j<4; j++ ) {
00125       eElec->setNum( j, ie );
00126     }
00127     for( unsigned int k=0; k<11; k++ ) {
00128       eElec->setP( k, ie );
00129       eElec->setSimP( k, ie );
00130     }
00131     fEndcapElec.push_back( eElec );
00132   }
00133   */
00134 
00135   return StatusCode::SUCCESS;
00136 }

virtual StatusCode TofQElecSvc::finalize  )  [virtual]
 

StatusCode TofQElecSvc::finalize  )  [virtual]
 

00069                                    {
00070   MsgStream log(msgSvc(), name());
00071   log << MSG::INFO << name() << ": End of Run" << endreq;
00072   return StatusCode::SUCCESS;
00073 }

void TofQElecSvc::handle const Incident &   ) 
 

void TofQElecSvc::handle const Incident &   ) 
 

00139                                            {
00140   MsgStream log( messageService(), name() );
00141   log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00142 
00143   if ( inc.type() == "NewRun" ){
00144     log << MSG::DEBUG << "New Run" << endreq;
00145     StatusCode sc= FillfromDatabase();
00146   }
00147   return;
00148 }

virtual StatusCode TofQElecSvc::initialize  )  [virtual]
 

StatusCode TofQElecSvc::initialize  )  [virtual]
 

00037                                      {
00038   m_hasbeeninitialized=false;
00039 
00040   MsgStream log(msgSvc(), name());
00041   log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00042   
00043   StatusCode sc = Service::initialize();
00044   if ( sc.isFailure() ) return sc;
00045 
00046   IIncidentSvc* incsvc;
00047   sc = service("IncidentSvc", incsvc);
00048   int priority = 100;
00049   if( sc.isSuccess() ){
00050     incsvc -> addListener(this, "NewRun", priority);
00051   }
00052 
00053   StatusCode scc;
00054   
00055   log<<MSG::INFO << "setProperties()" << endreq;
00056   scc = service("CalibDataSvc", m_pCalibDataSvc, true);
00057   if ( !scc.isSuccess() ) {
00058     log<<MSG::ERROR<<"Could not get IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
00059     return scc;
00060   } else {
00061     log << MSG::DEBUG<< "Retrieved IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
00062   }
00063   // Get properties from the JobOptionsSvc
00064   scc = setProperties();
00065   m_data=0;
00066   return sc;
00067 }  

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

00014 { return IID_ITofQElecSvc; }

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

00014 { return IID_ITofQElecSvc; }

virtual StatusCode TofQElecSvc::queryInterface const InterfaceID &  riid,
void **  ppvUnknown
[virtual]
 

StatusCode TofQElecSvc::queryInterface const InterfaceID &  riid,
void **  ppvUnknown
[virtual]
 

00027                                                                                     {
00028   
00029   if ( IID_ITofQElecSvc.versionMatch(riid) ) { 
00030     *ppvInterface = static_cast<ITofQElecSvc*> (this); 
00031   } else { 
00032     return Service::queryInterface(riid, ppvInterface) ; 
00033   }
00034   return StatusCode::SUCCESS;
00035 }


Member Data Documentation

CalibData::TofElecData* TofQElecSvc::m_data [private]
 

CalibData::TofElecData* TofQElecSvc::m_data [private]
 

bool TofQElecSvc::m_hasbeeninitialized [private]
 

IDataProviderSvc* TofQElecSvc::m_pCalibDataSvc [private]
 

IDataProviderSvc* TofQElecSvc::m_pCalibDataSvc [private]
 

IntegerProperty TofQElecSvc::m_run [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 18:59:46 2011 for BOSS6.5.5 by  doxygen 1.3.9.1