5#include "GaudiKernel/DataSvc.h"
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/IIncidentListener.h"
8#include "GaudiKernel/IIncidentSvc.h"
9#include "GaudiKernel/IInterface.h"
10#include "GaudiKernel/Incident.h"
11#include "GaudiKernel/Kernel.h"
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/Service.h"
14#include "GaudiKernel/SmartDataPtr.h"
15#include "GaudiKernel/StatusCode.h"
25 : base_class( name, svcloc ), m_data(
nullptr ) {
26 declareProperty(
"Run", m_run = 1 );
30 m_hasbeeninitialized =
false;
32 MsgStream log(
msgSvc(), name() );
33 log << MSG::INFO << name() <<
": Start of run initialisation" << endmsg;
35 StatusCode sc = Service::initialize();
36 if ( sc.isFailure() )
return sc;
39 sc = service(
"IncidentSvc", incsvc );
41 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
45 log << MSG::INFO <<
"setProperties()" << endmsg;
46 scc = service(
"CalibDataSvc", m_pCalibDataSvc,
true );
47 if ( !scc.isSuccess() )
49 log << MSG::ERROR <<
"Could not get IDataProviderSvc interface of QElecXmlCnvSvc"
54 { log << MSG::DEBUG <<
"Retrieved IDataProviderSvc interface of QElecXmlCnvSvc" << endmsg; }
61 MsgStream log(
msgSvc(), name() );
62 log << MSG::INFO << name() <<
": End of Run" << endmsg;
63 return StatusCode::SUCCESS;
67 if ( m_data )
delete m_data;
71StatusCode TofQElecSvc::FillfromDatabase() {
73 MsgStream log(
msgSvc(), name() );
74 std::string fullPath =
"/Calib/TofQElec";
75 log << MSG::INFO <<
" Tof calib fullPath = " << fullPath << endmsg;
76 SmartDataPtr<CalibData::TofElecData>
test( m_pCalibDataSvc, fullPath );
79 log << MSG::FATAL <<
"TofQElecSvc could not find TofQElecData in TCDS!!" << endmsg;
80 return StatusCode::FAILURE;
83 if ( m_data )
delete m_data;
84 m_data =
new CalibData::TofElecData;
125 return StatusCode::SUCCESS;
129 MsgStream log(
msgSvc(), name() );
130 log << MSG::DEBUG <<
"handle: " << inc.type() << endmsg;
132 if ( inc.type() ==
"NewRun" )
134 log << MSG::DEBUG <<
"New Run" << endmsg;
135 StatusCode sc = FillfromDatabase();
141 MsgStream log(
msgSvc(), name() );
145 if ( id < 0 || id > 175 )
147 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endmsg;
153 if ( id < 0 || id > 95 )
155 log << MSG::WARNING <<
"Board : TofId is out of Range, tofid=" <<
id << endmsg;
163 if ( eastEnd ) { board = ( m_data->getBTof(
id ) ).getNumEast( 0 ); }
164 else { board = ( m_data->getBTof(
id ) ).getNumWest( 0 ); }
166 else { board = ( m_data->getETof(
id ) ).getNum( 0 ); }
172 MsgStream log(
msgSvc(), name() );
176 if ( id < 0 || id > 175 )
178 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endmsg;
184 if ( id < 0 || id > 95 )
186 log << MSG::WARNING <<
"Crate : TofId is out of Range, tofid=" <<
id << endmsg;
194 if ( eastEnd ) { crate = ( m_data->getBTof(
id ) ).getNumEast( 2 ); }
195 else { crate = ( m_data->getBTof(
id ) ).getNumWest( 2 ); }
197 else { crate = ( m_data->getETof(
id ) ).getNum( 2 ); }
203 MsgStream log(
msgSvc(), name() );
207 if ( id < 0 || id > 175 )
209 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endmsg;
215 if ( id < 0 || id > 95 )
217 log << MSG::WARNING <<
"Fee : TofId is out of Range, tofid=" <<
id << endmsg;
225 if ( eastEnd ) { crate = ( m_data->getBTof(
id ) ).getNumEast( 3 ); }
226 else { crate = ( m_data->getBTof(
id ) ).getNumWest( 3 ); }
228 else { crate = ( m_data->getETof(
id ) ).getNum( 3 ); }
234 MsgStream log(
msgSvc(), name() );
238 if ( id < 0 || id > 175 )
240 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endmsg;
246 if ( id < 0 || id > 95 )
248 log << MSG::WARNING <<
"Channel : TofId is out of Range, tofid=" <<
id << endmsg;
253 unsigned int channel;
256 if ( eastEnd ) { channel = ( m_data->getBTof(
id ) ).getNumEast( 1 ); }
257 else { channel = ( m_data->getBTof(
id ) ).getNumWest( 1 ); }
259 else { channel = ( m_data->getETof(
id ) ).getNum( 1 ); }
265 double qtcNew = -999.0;
266 MsgStream log(
msgSvc(), name() );
267 if ( id < 0 || id > 175 )
269 log << MSG::WARNING <<
"BQTC1 : TofId is out of Range, tofid=" <<
id << endmsg;
272 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
273 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
275 double ratio = ( m_data->getBTof(
id ) ).getP1( 0 );
277 for (
unsigned int i = 0; i < 10; i++ ) { p[i] = ( m_data->getBTof(
id ) ).getP1( i + 1 ); }
279 qtcNew = p[0] + p[1] *
q + p[2] *
q *
q + p[3] *
q *
q *
q + p[4] *
q *
q *
q *
q +
280 p[7] *
exp( p[5] * (
q - p[6] ) );
290 double qtcNew = -999.0;
291 MsgStream log(
msgSvc(), name() );
292 if ( id < 0 || id > 175 )
294 log << MSG::WARNING <<
"BQTC2 : TofId is out of Range, tofid=" <<
id << endmsg;
297 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
298 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
300 double ratio = ( m_data->getBTof(
id ) ).getP2( 0 );
302 for (
unsigned int i = 0; i < 10; i++ ) { p[i] = ( m_data->getBTof(
id ) ).getP2( i + 1 ); }
304 qtcNew = p[0] + p[1] *
q + p[2] *
q *
q + p[3] *
q *
q *
q + p[4] *
q *
q *
q *
q +
305 p[7] *
exp( p[5] * (
q - p[6] ) );
315 double qtcNew = -999.0;
316 MsgStream log(
msgSvc(), name() );
317 if ( id < 0 || id > 95 )
319 log << MSG::WARNING <<
"EQTC : TofId is out of Range, tofid=" <<
id << endmsg;
322 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
323 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
325 double ratio = ( m_data->getETof(
id ) ).getP( 0 );
327 for (
unsigned int i = 0; i < 10; i++ ) { p[i] = ( m_data->getETof(
id ) ).getP( i + 1 ); }
329 qtcNew = p[0] + p[1] *
q + p[2] *
q *
q + p[3] *
q *
q *
q + p[4] *
q *
q *
q *
q +
330 p[7] *
exp( p[5] * (
q - p[6] ) );
340 double qChannel = -999.0;
341 MsgStream log(
msgSvc(), name() );
342 if ( id < 0 || id > 175 )
344 log << MSG::ERROR <<
"BChannel1 : TofId is out of Range, tofid=" <<
id << endmsg;
348 double ratio = ( m_data->getBTof(
id ) ).getSimP1( 0 );
350 for (
unsigned int i = 0; i < 10; i++ )
351 { p[i] = ( m_data->getBTof(
id ) ).getSimP1( i + 1 ); }
352 qChannel = ( p[0] + p[1] * qtc + p[2] * qtc * qtc + p[3] * qtc * qtc * qtc ) *
353 ( 1.0 - TMath::Erf( ( qtc - p[4] ) / p[5] ) ) +
354 ( p[6] + p[7] * qtc ) * ( 1.0 + TMath::Erf( ( qtc - p[8] ) / p[9] ) );
355 qChannel = ratio * qChannel;
365 double qChannel = -999.0;
366 MsgStream log(
msgSvc(), name() );
367 if ( id < 0 || id > 175 )
369 log << MSG::ERROR <<
"BChannel2 : TofId is out of Range, tofid=" <<
id << endmsg;
373 double ratio = ( m_data->getBTof(
id ) ).getSimP2( 0 );
375 for (
unsigned int i = 0; i < 10; i++ )
376 { p[i] = ( m_data->getBTof(
id ) ).getSimP2( i + 1 ); }
377 qChannel = ( p[0] + p[1] * qtc + p[2] * qtc * qtc + p[3] * qtc * qtc * qtc ) *
378 ( 1.0 - TMath::Erf( ( qtc - p[4] ) / p[5] ) ) +
379 ( p[6] + p[7] * qtc ) * ( 1.0 + TMath::Erf( ( qtc - p[8] ) / p[9] ) );
380 qChannel = ratio * qChannel;
390 double qChannel = -999.0;
391 MsgStream log(
msgSvc(), name() );
392 if ( id < 0 || id > 95 )
394 log << MSG::ERROR <<
"EQTC : TofId is out of Range, tofid=" <<
id << endmsg;
398 double ratio = ( m_data->getETof(
id ) ).getSimP( 0 );
400 for (
unsigned int i = 0; i < 10; i++ )
401 { p[i] = ( m_data->getETof(
id ) ).getSimP( i + 1 ); }
402 qChannel = ( p[0] + p[1] * qtc + p[2] * qtc * qtc + p[3] * qtc * qtc * qtc ) *
403 ( 1.0 - TMath::Erf( ( qtc - p[4] ) / p[5] ) ) +
404 ( p[6] + p[7] * qtc ) * ( 1.0 + TMath::Erf( ( qtc - p[8] ) / p[9] ) );
405 qChannel = ratio * qChannel;
DECLARE_COMPONENT(BesBdkRc)
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
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)
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)