9#include "GaudiKernel/Kernel.h"
10#include "GaudiKernel/IInterface.h"
11#include "GaudiKernel/StatusCode.h"
12#include "GaudiKernel/SvcFactory.h"
13#include "GaudiKernel/MsgStream.h"
14#include "GaudiKernel/IIncidentSvc.h"
15#include "GaudiKernel/Incident.h"
16#include "GaudiKernel/IIncidentListener.h"
17#include "GaudiKernel/IDataProviderSvc.h"
18#include "GaudiKernel/Service.h"
19#include "GaudiKernel/SmartDataPtr.h"
36 if ( IID_ITofQCorrSvc.versionMatch(riid) ) {
39 return Service::queryInterface(riid, ppvInterface) ;
41 return StatusCode::SUCCESS;
47 MsgStream log(
msgSvc(), name());
48 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
50 StatusCode sc = Service::initialize();
51 if ( sc.isFailure() )
return sc;
54 sc = service(
"IncidentSvc", incsvc);
57 incsvc -> addListener(
this,
"NewRun", priority);
60 sc = serviceLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
61 if (sc .isFailure() ) {
62 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endreq;
67 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
68 if (sc .isFailure() ) {
69 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
74 log<<MSG::INFO <<
"setProperties()" << endreq;
75 scc = setProperties();
82 MsgStream log(
msgSvc(), name());
83 log << MSG::INFO << name() <<
": End of Run" << endreq;
84 return StatusCode::SUCCESS;
93 return m_Bar_East[layer][
no];
98 return m_Bar_West[layer][
no];
103 return m_Endcap[layer][
no];
108 MsgStream log( messageService(), name() );
109 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
111 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
112 int run = eventHeader->runNumber();
113 if( run<0 || run>11000 )
return;
115 if ( inc.type() ==
"NewRun" ){
116 log << MSG::DEBUG <<
"New Run:" << run << endreq;
123 MsgStream log(messageService(), name());
124 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
125 int run = eventHeader->runNumber();
127 log << MSG::INFO <<
"This data is the MC sample with the Run Number: " << run << endreq;
132 sprintf(stmt1,
"select TOFCalib "
133 "from RunParams where run_number = %d", run);
136 int row_no = m_dbsvc->
query(
"run",stmt1,res);
138 log << MSG::ERROR<<
"search errror"<<endreq;
143 sscanf((*records1)[
"TOFCalib"],
"%ld", &
runNo);
146 sprintf(stmt2,
"select be,end,counter,a1,a2,a3 "
147 "from TOF_Q where run_number = %ld",
runNo);
150 row_no = m_dbsvc->
query(
"run",stmt2,res);
152 log << MSG::ERROR<<
"search errror"<<endreq;
156 long int be,end,counter;
157 double sql_result[3];
159 for(
int jjj=0;jjj<row_no;jjj++){
161 sscanf((*records2)[
"be"],
"%ld", &be);
162 sscanf((*records2)[
"end"],
"%ld", &end);
163 sscanf((*records2)[
"counter"],
"%ld", &counter);
164 sscanf((*records2)[
"a1"],
"%lf", &sql_result[0]);
165 sscanf((*records2)[
"a2"],
"%lf", &sql_result[1]);
166 sscanf((*records2)[
"a3"],
"%lf", &sql_result[2]);
168 m_Endcap[counter][0]=sql_result[0];
169 m_Endcap[counter][1]=sql_result[1];
170 m_Endcap[counter][2]=sql_result[2];
173 m_Bar_East[counter][0]=sql_result[0];
174 m_Bar_East[counter][1]=sql_result[1];
175 m_Bar_East[counter][2]=sql_result[2];
178 m_Bar_West[counter][0]=sql_result[0];
179 m_Bar_West[counter][1]=sql_result[1];
180 m_Bar_West[counter][2]=sql_result[2];
188 MsgStream log(
msgSvc(), name());
189 double qraw = -999.0;
190 if( id<0 || id>175 ) {
191 log << MSG::WARNING <<
"BQRaw1 : TofId is out of range, tofid = " <<
id << endreq;
194 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
195 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
196 double a = m_Bar_East[id][2];
197 double b = m_Bar_East[id][1];
198 double c = m_Bar_East[id][0] -
q/2.5;
199 qraw = ( sqrt(
b*
b - 4.0*a*c ) -
b )/( 2.0*a );
206 MsgStream log(
msgSvc(), name());
207 double qraw = -999.0;
208 if( id<0 || id>175 ) {
209 log << MSG::WARNING <<
"BQRaw2 : TofId is out of range, tofid = " <<
id << endreq;
212 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
213 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
214 double a = m_Bar_West[id][2];
215 double b = m_Bar_West[id][1];
216 double c = m_Bar_West[id][0] -
q/2.5;
217 qraw = ( sqrt(
b*
b - 4.0*a*c ) -
b )/( 2.0*a );
223 MsgStream log(
msgSvc(), name());
224 double qraw = -999.0;
225 if( id<0 || id>95 ) {
226 log << MSG::WARNING <<
"EQRaw : TofId is out of range, tofid = " <<
id << endreq;
229 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
230 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
231 double a = m_Endcap[id][2];
232 double b = m_Endcap[id][1];
233 double c = m_Endcap[id][0] -
q/2.5;
234 qraw = ( sqrt(
b*
b - 4.0*a*c ) -
b )/( 2.0*a );
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
****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
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
const double getEndcap(int layer, int no)
virtual StatusCode initialize()
const double getBarEast(int layer, int no)
const double getBarWest(int layer, int no)
TofQCorrSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode finalize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
const double BQRaw2(int id, double q)
const double BQRaw1(int id, double q)
void handle(const Incident &)
const double EQRaw(int id, double q)