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"
48 MsgStream log(
msgSvc(), name());
49 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
51 StatusCode sc = Service::initialize();
52 if ( sc.isFailure() )
return sc;
55 sc = service(
"IncidentSvc", incsvc);
58 incsvc -> addListener(
this,
"NewRun", priority);
61 sc = serviceLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
62 if (sc .isFailure() ) {
63 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endreq;
68 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
69 if (sc .isFailure() ) {
70 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
75 log<<MSG::INFO <<
"setProperties()" << endreq;
76 scc = setProperties();
83 MsgStream log(
msgSvc(), name());
84 log << MSG::INFO << name() <<
": End of Run" << endreq;
85 return StatusCode::SUCCESS;
94 return m_Bar_East[layer][
no];
99 return m_Bar_West[layer][
no];
104 return m_Endcap[layer][
no];
109 MsgStream log( messageService(), name() );
110 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
112 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
113 int run = eventHeader->runNumber();
114 if( run<0 || run>11000 )
return;
116 if ( inc.type() ==
"NewRun" ){
117 log << MSG::DEBUG <<
"New Run:" << run << endreq;
124 MsgStream log(messageService(), name());
125 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
126 int run = eventHeader->runNumber();
128 log << MSG::INFO <<
"This data is the MC sample with the Run Number: " << run << endreq;
133 sprintf(stmt1,
"select TOFCalib "
134 "from RunParams where run_number = %d", run);
137 int row_no = m_dbsvc->
query(
"run",stmt1,res);
139 log << MSG::ERROR<<
"search errror"<<endreq;
144 sscanf((*records1)[
"TOFCalib"],
"%ld", &
runNo);
147 sprintf(stmt2,
"select be,end,counter,a1,a2,a3 "
148 "from TOF_Q where run_number = %ld",
runNo);
151 row_no = m_dbsvc->
query(
"run",stmt2,res);
153 log << MSG::ERROR<<
"search errror"<<endreq;
157 long int be,end,counter;
158 double sql_result[3];
160 for(
int jjj=0;jjj<row_no;jjj++){
162 sscanf((*records2)[
"be"],
"%ld", &be);
163 sscanf((*records2)[
"end"],
"%ld", &end);
164 sscanf((*records2)[
"counter"],
"%ld", &counter);
165 sscanf((*records2)[
"a1"],
"%lf", &sql_result[0]);
166 sscanf((*records2)[
"a2"],
"%lf", &sql_result[1]);
167 sscanf((*records2)[
"a3"],
"%lf", &sql_result[2]);
169 m_Endcap[counter][0]=sql_result[0];
170 m_Endcap[counter][1]=sql_result[1];
171 m_Endcap[counter][2]=sql_result[2];
174 m_Bar_East[counter][0]=sql_result[0];
175 m_Bar_East[counter][1]=sql_result[1];
176 m_Bar_East[counter][2]=sql_result[2];
179 m_Bar_West[counter][0]=sql_result[0];
180 m_Bar_West[counter][1]=sql_result[1];
181 m_Bar_West[counter][2]=sql_result[2];
189 MsgStream log(
msgSvc(), name());
190 double qraw = -999.0;
191 if( id<0 || id>175 ) {
192 log << MSG::WARNING <<
"BQRaw1 : TofId is out of range, tofid = " <<
id << endreq;
195 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
196 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
197 double a = m_Bar_East[id][2];
198 double b = m_Bar_East[id][1];
199 double c = m_Bar_East[id][0] -
q/2.5;
200 qraw = ( sqrt(
b*
b - 4.0*a*c ) -
b )/( 2.0*a );
207 MsgStream log(
msgSvc(), name());
208 double qraw = -999.0;
209 if( id<0 || id>175 ) {
210 log << MSG::WARNING <<
"BQRaw2 : TofId is out of range, tofid = " <<
id << endreq;
213 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
214 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
215 double a = m_Bar_West[id][2];
216 double b = m_Bar_West[id][1];
217 double c = m_Bar_West[id][0] -
q/2.5;
218 qraw = ( sqrt(
b*
b - 4.0*a*c ) -
b )/( 2.0*a );
224 MsgStream log(
msgSvc(), name());
225 double qraw = -999.0;
226 if( id<0 || id>95 ) {
227 log << MSG::WARNING <<
"EQRaw : TofId is out of range, tofid = " <<
id << endreq;
230 if( fabs(
q-10000.0)<1.0e-6 ) {
return 10000.0; }
231 else if( fabs(
q+999.0)<1.0e-6 ) {
return -999.0; }
232 double a = m_Endcap[id][2];
233 double b = m_Endcap[id][1];
234 double c = m_Endcap[id][0] -
q/2.5;
235 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)
virtual StatusCode finalize()
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)