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"
25 declareProperty(
"Run",m_run=1);
40 m_hasbeeninitialized=
false;
42 MsgStream log(
msgSvc(), name());
43 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
45 StatusCode sc = Service::initialize();
46 if ( sc.isFailure() )
return sc;
49 sc = service(
"IncidentSvc", incsvc);
52 incsvc -> addListener(
this,
"NewRun", priority);
57 log<<MSG::INFO <<
"setProperties()" << endreq;
58 scc = service(
"CalibDataSvc", m_pCalibDataSvc,
true);
59 if ( !scc.isSuccess() ) {
60 log<<MSG::ERROR<<
"Could not get IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
63 log << MSG::DEBUG<<
"Retrieved IDataProviderSvc interface of QElecXmlCnvSvc"<<endreq;
66 scc = setProperties();
72 MsgStream log(
msgSvc(), name());
73 log << MSG::INFO << name() <<
": End of Run" << endreq;
74 return StatusCode::SUCCESS;
84StatusCode TofQElecSvc::FillfromDatabase(){
86 MsgStream log(
msgSvc(), name());
87 std::string fullPath =
"/Calib/TofQElec";
88 log << MSG::INFO<<
" Tof calib fullPath = "<<fullPath<< endreq;
89 SmartDataPtr<CalibData::TofElecData>
test(m_pCalibDataSvc, fullPath);
91 log << MSG::FATAL <<
"TofQElecSvc could not find TofQElecData in TCDS!!" << endreq;
92 return StatusCode::FAILURE;
95 if(m_data)
delete m_data;
137 return StatusCode::SUCCESS;
142 MsgStream log( messageService(), name() );
143 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
145 if ( inc.type() ==
"NewRun" ){
146 log << MSG::DEBUG <<
"New Run" << endreq;
147 StatusCode sc= FillfromDatabase();
154 MsgStream log(
msgSvc(), name());
157 if( id<0 || id>175 ) {
158 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endreq;
163 if( id<0 || id>95 ) {
164 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endreq;
172 board = (m_data->
getBTof(
id)).getNumEast(0);
175 board = (m_data->
getBTof(
id)).getNumWest(0);
179 board = (m_data->
getETof(
id)).getNum(0);
187 MsgStream log(
msgSvc(), name());
190 if( id<0 || id>175 ) {
191 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endreq;
196 if( id<0 || id>95 ) {
197 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endreq;
205 crate = (m_data->
getBTof(
id)).getNumEast(2);
208 crate = (m_data->
getBTof(
id)).getNumWest(2);
212 crate = (m_data->
getETof(
id)).getNum(2);
220 MsgStream log(
msgSvc(), name());
223 if( id<0 || id>175 ) {
224 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endreq;
229 if( id<0 || id>95 ) {
230 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endreq;
238 crate = (m_data->
getBTof(
id)).getNumEast(3);
241 crate = (m_data->
getBTof(
id)).getNumWest(3);
245 crate = (m_data->
getETof(
id)).getNum(3);
253 MsgStream log(
msgSvc(), name());
256 if( id<0 || id>175 ) {
257 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endreq;
262 if( id<0 || id>95 ) {
263 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endreq;
268 unsigned int channel;
271 channel = (m_data->
getBTof(
id)).getNumEast(1);
274 channel = (m_data->
getBTof(
id)).getNumWest(1);
278 channel = (m_data->
getETof(
id)).getNum(1);
286 double qtcNew = -999.0;
287 MsgStream log(
msgSvc(), name());
288 if( id<0 || id>175 ) {
289 log << MSG::WARNING <<
"BQTC1 : TofId is out of Range, tofid=" <<
id << endreq;
292 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
293 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
295 double ratio = (m_data->
getBTof(
id)).getP1(0);
297 for(
unsigned int i=0; i<10; i++ ) {
298 p[i] = (m_data->
getBTof(
id)).getP1(i+1);
301 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]));
312 double qtcNew = -999.0;
313 MsgStream log(
msgSvc(), name());
314 if( id<0 || id>175 ) {
315 log << MSG::WARNING <<
"BQTC2 : TofId is out of Range, tofid=" <<
id << endreq;
318 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
319 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
321 double ratio = (m_data->
getBTof(
id)).getP2(0);
323 for(
unsigned int i=0; i<10; i++ ) {
324 p[i] = (m_data->
getBTof(
id)).getP2(i+1);
327 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]));
338 double qtcNew = -999.0;
339 MsgStream log(
msgSvc(), name());
340 if( id<0 || id>95 ) {
341 log << MSG::WARNING <<
"EQTC : TofId is out of Range, tofid=" <<
id << endreq;
344 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
345 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
347 double ratio = (m_data->
getETof(
id)).getP(0);
349 for(
unsigned int i=0; i<10; i++ ) {
350 p[i] = (m_data->
getETof(
id)).getP(i+1);
353 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]));
364 double qChannel = -999.0;
365 MsgStream log(
msgSvc(), name());
366 if( id<0 || id>175 ) {
367 log << MSG::ERROR <<
"BChannel1 : TofId is out of Range, tofid=" <<
id << endreq;
371 double ratio = (m_data->
getBTof(
id)).getSimP1(0);
373 for(
unsigned int i=0; i<10; i++ ) {
374 p[i] = (m_data->
getBTof(
id)).getSimP1(i+1);
376 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]) );
377 qChannel = ratio*qChannel;
388 double qChannel = -999.0;
389 MsgStream log(
msgSvc(), name());
390 if( id<0 || id>175 ) {
391 log << MSG::ERROR <<
"BChannel2 : TofId is out of Range, tofid=" <<
id << endreq;
395 double ratio = (m_data->
getBTof(
id)).getSimP2(0);
397 for(
unsigned int i=0; i<10; i++ ) {
398 p[i] = (m_data->
getBTof(
id)).getSimP2(i+1);
400 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]) );
401 qChannel = ratio*qChannel;
412 double qChannel = -999.0;
413 MsgStream log(
msgSvc(), name());
414 if( id<0 || id>95 ) {
415 log << MSG::ERROR <<
"EQTC : TofId is out of Range, tofid=" <<
id << endreq;
419 double ratio = (m_data->
getETof(
id)).getSimP(0);
421 for(
unsigned int i=0; i<10; i++ ) {
422 p[i] = (m_data->
getETof(
id)).getSimP(i+1);
424 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]) );
425 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 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)