4#include "GaudiKernel/Kernel.h"
5#include "GaudiKernel/IInterface.h"
6#include "GaudiKernel/StatusCode.h"
8#include "GaudiKernel/SvcFactory.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/IIncidentSvc.h"
11#include "GaudiKernel/Incident.h"
12#include "GaudiKernel/IIncidentListener.h"
13#include "GaudiKernel/IDataProviderSvc.h"
14#include "GaudiKernel/Service.h"
15#include "GaudiKernel/DataSvc.h"
16#include "GaudiKernel/SmartDataPtr.h"
23 declareProperty(
"Run",m_run=1);
29 if ( IID_ITofQElecSvc.versionMatch(riid) ) {
32 return Service::queryInterface(riid, ppvInterface) ;
34 return StatusCode::SUCCESS;
38 m_hasbeeninitialized=
false;
40 MsgStream log(
msgSvc(), name());
41 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
43 StatusCode sc = Service::initialize();
44 if ( sc.isFailure() )
return sc;
47 sc = service(
"IncidentSvc", incsvc);
50 incsvc -> addListener(
this,
"NewRun", priority);
55 log<<MSG::INFO <<
"setProperties()" << endreq;
56 scc = service(
"CalibDataSvc", m_pCalibDataSvc,
true);
57 if ( !scc.isSuccess() ) {
58 log<<MSG::ERROR<<
"Could not get IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
61 log << MSG::DEBUG<<
"Retrieved IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
64 scc = setProperties();
70 MsgStream log(
msgSvc(), name());
71 log << MSG::INFO << name() <<
": End of Run" << endreq;
72 return StatusCode::SUCCESS;
82StatusCode TofQElecSvc::FillfromDatabase(){
84 MsgStream log(
msgSvc(), name());
85 std::string fullPath =
"/Calib/TofQElec";
86 log << MSG::INFO<<
" Tof calib fullPath = "<<fullPath<< endreq;
87 SmartDataPtr<CalibData::TofElecData>
test(m_pCalibDataSvc, fullPath);
89 log << MSG::FATAL <<
"TofQElecSvc could not find TofQElecData in TCDS!!" << endreq;
90 return StatusCode::FAILURE;
93 if(m_data)
delete m_data;
135 return StatusCode::SUCCESS;
140 MsgStream log( messageService(), name() );
141 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
143 if ( inc.type() ==
"NewRun" ){
144 log << MSG::DEBUG <<
"New Run" << endreq;
145 StatusCode sc= FillfromDatabase();
152 MsgStream log(
msgSvc(), name());
155 if( id<0 || id>175 ) {
156 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endreq;
161 if( id<0 || id>95 ) {
162 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endreq;
170 board = (m_data->
getBTof(
id)).getNumEast(0);
173 board = (m_data->
getBTof(
id)).getNumWest(0);
177 board = (m_data->
getETof(
id)).getNum(0);
185 MsgStream log(
msgSvc(), name());
188 if( id<0 || id>175 ) {
189 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endreq;
194 if( id<0 || id>95 ) {
195 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endreq;
203 crate = (m_data->
getBTof(
id)).getNumEast(2);
206 crate = (m_data->
getBTof(
id)).getNumWest(2);
210 crate = (m_data->
getETof(
id)).getNum(2);
218 MsgStream log(
msgSvc(), name());
221 if( id<0 || id>175 ) {
222 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endreq;
227 if( id<0 || id>95 ) {
228 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endreq;
236 crate = (m_data->
getBTof(
id)).getNumEast(3);
239 crate = (m_data->
getBTof(
id)).getNumWest(3);
243 crate = (m_data->
getETof(
id)).getNum(3);
251 MsgStream log(
msgSvc(), name());
254 if( id<0 || id>175 ) {
255 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endreq;
260 if( id<0 || id>95 ) {
261 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endreq;
266 unsigned int channel;
269 channel = (m_data->
getBTof(
id)).getNumEast(1);
272 channel = (m_data->
getBTof(
id)).getNumWest(1);
276 channel = (m_data->
getETof(
id)).getNum(1);
284 double qtcNew = -999.0;
285 MsgStream log(
msgSvc(), name());
286 if( id<0 || id>175 ) {
287 log << MSG::WARNING <<
"BQTC1 : TofId is out of Range, tofid=" <<
id << endreq;
290 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
291 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
293 double ratio = (m_data->
getBTof(
id)).getP1(0);
295 for(
unsigned int i=0; i<10; i++ ) {
296 p[i] = (m_data->
getBTof(
id)).getP1(i+1);
299 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]));
310 double qtcNew = -999.0;
311 MsgStream log(
msgSvc(), name());
312 if( id<0 || id>175 ) {
313 log << MSG::WARNING <<
"BQTC2 : TofId is out of Range, tofid=" <<
id << endreq;
316 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
317 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
319 double ratio = (m_data->
getBTof(
id)).getP2(0);
321 for(
unsigned int i=0; i<10; i++ ) {
322 p[i] = (m_data->
getBTof(
id)).getP2(i+1);
325 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]));
336 double qtcNew = -999.0;
337 MsgStream log(
msgSvc(), name());
338 if( id<0 || id>95 ) {
339 log << MSG::WARNING <<
"EQTC : TofId is out of Range, tofid=" <<
id << endreq;
342 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
343 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
345 double ratio = (m_data->
getETof(
id)).getP(0);
347 for(
unsigned int i=0; i<10; i++ ) {
348 p[i] = (m_data->
getETof(
id)).getP(i+1);
351 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]));
362 double qChannel = -999.0;
363 MsgStream log(
msgSvc(), name());
364 if( id<0 || id>175 ) {
365 log << MSG::ERROR <<
"BChannel1 : TofId is out of Range, tofid=" <<
id << endreq;
369 double ratio = (m_data->
getBTof(
id)).getSimP1(0);
371 for(
unsigned int i=0; i<10; i++ ) {
372 p[i] = (m_data->
getBTof(
id)).getSimP1(i+1);
374 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]) );
375 qChannel = ratio*qChannel;
386 double qChannel = -999.0;
387 MsgStream log(
msgSvc(), name());
388 if( id<0 || id>175 ) {
389 log << MSG::ERROR <<
"BChannel2 : TofId is out of Range, tofid=" <<
id << endreq;
393 double ratio = (m_data->
getBTof(
id)).getSimP2(0);
395 for(
unsigned int i=0; i<10; i++ ) {
396 p[i] = (m_data->
getBTof(
id)).getSimP2(i+1);
398 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]) );
399 qChannel = ratio*qChannel;
410 double qChannel = -999.0;
411 MsgStream log(
msgSvc(), name());
412 if( id<0 || id>95 ) {
413 log << MSG::ERROR <<
"EQTC : TofId is out of Range, tofid=" <<
id << endreq;
417 double ratio = (m_data->
getETof(
id)).getSimP(0);
419 for(
unsigned int i=0; i<10; i++ ) {
420 p[i] = (m_data->
getETof(
id)).getSimP(i+1);
422 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]) );
423 qChannel = ratio*qChannel;
EvtComplex exp(const EvtComplex &c)
****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
void sim(TofElecData *other1)
EndcapElec getETof(int cnt) const
BarrelElec getBTof(int cnt) const
const double EQTC(int id, double q)
const double BQChannel2(int id, double qtc)
const double BQChannel1(int id, double qtc)
const unsigned int Channel(bool barrel, int id, bool eastEnd)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
TofQElecSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode finalize()
void handle(const Incident &)
const double BQTC1(int id, double q)
const unsigned int Fee(bool barrel, int id, bool eastEnd)
virtual StatusCode initialize()
const double EQChannel(int id, double qtc)
const unsigned int Crate(bool barrel, int id, bool eastEnd)
const unsigned int Board(bool barrel, int id, bool eastEnd)
const double BQTC2(int id, double q)