#include <TofQElecSvc.h>
Inheritance diagram for TofQElecSvc:
Public Member Functions | |
TofQElecSvc (const std::string &name, ISvcLocator *svcloc) | |
~TofQElecSvc () | |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
void | handle (const Incident &) |
const unsigned int | Board (bool barrel, int id, bool eastEnd) |
const unsigned int | Crate (bool barrel, int id, bool eastEnd) |
const unsigned int | Fee (bool barrel, int id, bool eastEnd) |
const unsigned int | Channel (bool barrel, int id, bool eastEnd) |
const double | BQTC1 (int id, double q) |
const double | BQTC2 (int id, double q) |
const double | EQTC (int id, double q) |
const double | BQChannel1 (int id, double qtc) |
const double | BQChannel2 (int id, double qtc) |
const double | EQChannel (int id, double qtc) |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
Private Member Functions | |
StatusCode | FillfromDatabase () |
Private Attributes | |
bool | m_hasbeeninitialized |
IDataProviderSvc * | m_pCalibDataSvc |
IntegerProperty | m_run |
CalibData::TofElecData * | m_data |
Definition at line 17 of file TofQElecSvc.h.
TofQElecSvc::TofQElecSvc | ( | const std::string & | name, | |
ISvcLocator * | svcloc | |||
) |
TofQElecSvc::~TofQElecSvc | ( | ) |
Definition at line 76 of file TofQElecSvc.cxx.
References m_data.
00076 { 00077 delete m_data; 00078 return; 00079 }
Implements ITofQElecSvc.
Definition at line 151 of file TofQElecSvc.cxx.
References CalibData::TofElecData::getBTof(), CalibData::TofElecData::getETof(), m_data, msgSvc(), and Bes_Common::WARNING.
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.
Definition at line 361 of file TofQElecSvc.cxx.
References calibUtil::ERROR, CalibData::TofElecData::getBTof(), genRecEmupikp::i, m_data, and msgSvc().
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.
Definition at line 385 of file TofQElecSvc.cxx.
References calibUtil::ERROR, CalibData::TofElecData::getBTof(), genRecEmupikp::i, m_data, and msgSvc().
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.
Definition at line 283 of file TofQElecSvc.cxx.
References exp(), CalibData::TofElecData::getBTof(), genRecEmupikp::i, m_data, msgSvc(), and Bes_Common::WARNING.
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.
Definition at line 309 of file TofQElecSvc.cxx.
References exp(), CalibData::TofElecData::getBTof(), genRecEmupikp::i, m_data, msgSvc(), and Bes_Common::WARNING.
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 }
Implements ITofQElecSvc.
Definition at line 250 of file TofQElecSvc.cxx.
References CalibData::TofElecData::getBTof(), CalibData::TofElecData::getETof(), m_data, msgSvc(), and Bes_Common::WARNING.
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 }
Implements ITofQElecSvc.
Definition at line 184 of file TofQElecSvc.cxx.
References CalibData::TofElecData::getBTof(), CalibData::TofElecData::getETof(), m_data, msgSvc(), and Bes_Common::WARNING.
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.
Definition at line 409 of file TofQElecSvc.cxx.
References calibUtil::ERROR, CalibData::TofElecData::getETof(), genRecEmupikp::i, m_data, and msgSvc().
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.
Definition at line 335 of file TofQElecSvc.cxx.
References exp(), CalibData::TofElecData::getETof(), genRecEmupikp::i, m_data, msgSvc(), and Bes_Common::WARNING.
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 }
Implements ITofQElecSvc.
Definition at line 217 of file TofQElecSvc.cxx.
References CalibData::TofElecData::getBTof(), CalibData::TofElecData::getETof(), m_data, msgSvc(), and Bes_Common::WARNING.
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] |
Definition at line 82 of file TofQElecSvc.cxx.
References Bes_Common::FATAL, Bes_Common::INFO, m_data, m_pCalibDataSvc, msgSvc(), CalibData::TofElecData::sim(), deljobs::string, and test.
Referenced by handle().
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 }
StatusCode TofQElecSvc::finalize | ( | ) | [virtual] |
Definition at line 69 of file TofQElecSvc.cxx.
References Bes_Common::INFO, and msgSvc().
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 & | ) |
Definition at line 139 of file TofQElecSvc.cxx.
References Bes_Common::DEBUG, and FillfromDatabase().
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 }
StatusCode TofQElecSvc::initialize | ( | ) | [virtual] |
Definition at line 37 of file TofQElecSvc.cxx.
References Bes_Common::DEBUG, calibUtil::ERROR, Bes_Common::INFO, m_data, m_hasbeeninitialized, m_pCalibDataSvc, and msgSvc().
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 }
static const InterfaceID& ITofQElecSvc::interfaceID | ( | ) | [inline, static, inherited] |
Definition at line 14 of file ITofQElecSvc.h.
References IID_ITofQElecSvc().
00014 { return IID_ITofQElecSvc; }
StatusCode TofQElecSvc::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvUnknown | |||
) | [virtual] |
Definition at line 27 of file TofQElecSvc.cxx.
References IID_ITofQElecSvc().
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 }
CalibData::TofElecData* TofQElecSvc::m_data [private] |
Definition at line 49 of file TofQElecSvc.h.
Referenced by Board(), BQChannel1(), BQChannel2(), BQTC1(), BQTC2(), Channel(), Crate(), EQChannel(), EQTC(), Fee(), FillfromDatabase(), initialize(), and ~TofQElecSvc().
bool TofQElecSvc::m_hasbeeninitialized [private] |
IDataProviderSvc* TofQElecSvc::m_pCalibDataSvc [private] |
IntegerProperty TofQElecSvc::m_run [private] |