10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/IIncidentListener.h"
12#include "GaudiKernel/IIncidentSvc.h"
13#include "GaudiKernel/IInterface.h"
14#include "GaudiKernel/Incident.h"
15#include "GaudiKernel/Kernel.h"
16#include "GaudiKernel/MsgStream.h"
17#include "GaudiKernel/Service.h"
18#include "GaudiKernel/SmartDataPtr.h"
19#include "GaudiKernel/StatusCode.h"
22#include "CalibData/Tof/TofCalibData.h"
23#include "CalibData/Tof/bTofCalibBase.h"
24#include "EventModel/Event.h"
25#include "EventModel/EventHeader.h"
26#include "EventModel/EventModel.h"
34 : base_class( name, svcloc ) {}
49 MsgStream log(
msgSvc(), name() );
50 log << MSG::INFO << name() <<
": Start of run initialisation" << endmsg;
52 StatusCode sc = Service::initialize();
53 if ( sc.isFailure() )
return sc;
56 sc = service(
"IncidentSvc", incsvc );
58 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
60 sc = serviceLocator()->service(
"DatabaseSvc", m_dbsvc,
true );
63 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endmsg;
67 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true );
70 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endmsg;
75 log << MSG::INFO <<
"setProperties()" << endmsg;
82 MsgStream log(
msgSvc(), name() );
83 log << MSG::INFO << name() <<
": End of Run" << endmsg;
84 return StatusCode::SUCCESS;
96 MsgStream log(
msgSvc(), name() );
97 log << MSG::DEBUG <<
"handle: " << inc.type() << endmsg;
99 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc,
"/Event/EventHeader" );
100 int run = eventHeader->runNumber();
101 if ( run < 0 || run > 11000 )
return;
103 if ( inc.type() ==
"NewRun" )
105 log << MSG::DEBUG <<
"New Run:" << run << endmsg;
111 MsgStream log(
msgSvc(), name() );
112 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc,
"/Event/EventHeader" );
113 int run = eventHeader->runNumber();
116 log << MSG::INFO <<
"This data is the MC sample with the Run Number: " << run << endmsg;
123 "from RunParams where run_number = %d",
127 int row_no = m_dbsvc->query(
"run", stmt1, res );
130 log << MSG::ERROR <<
"search errror" << endmsg;
135 sscanf( ( *records1 )[
"TOFCalib"],
"%ld", &
runNo );
139 "select be,end,counter,a1,a2,a3 "
140 "from TOF_Q where run_number = %ld",
144 row_no = m_dbsvc->query(
"run", stmt2, res );
147 log << MSG::ERROR <<
"search errror" << endmsg;
151 long int be, end, counter;
152 double sql_result[3];
154 for (
int jjj = 0; jjj < row_no; jjj++ )
157 sscanf( ( *records2 )[
"be"],
"%ld", &be );
158 sscanf( ( *records2 )[
"end"],
"%ld", &end );
159 sscanf( ( *records2 )[
"counter"],
"%ld", &counter );
160 sscanf( ( *records2 )[
"a1"],
"%lf", &sql_result[0] );
161 sscanf( ( *records2 )[
"a2"],
"%lf", &sql_result[1] );
162 sscanf( ( *records2 )[
"a3"],
"%lf", &sql_result[2] );
163 if ( be == 0 && end == 0 )
165 m_Endcap[counter][0] = sql_result[0];
166 m_Endcap[counter][1] = sql_result[1];
167 m_Endcap[counter][2] = sql_result[2];
169 if ( be == 1 && end == 0 )
171 m_Bar_East[counter][0] = sql_result[0];
172 m_Bar_East[counter][1] = sql_result[1];
173 m_Bar_East[counter][2] = sql_result[2];
175 if ( be == 1 && end == 1 )
177 m_Bar_West[counter][0] = sql_result[0];
178 m_Bar_West[counter][1] = sql_result[1];
179 m_Bar_West[counter][2] = sql_result[2];
186 MsgStream log(
msgSvc(), name() );
187 double qraw = -999.0;
188 if ( id < 0 || id > 175 )
190 log << MSG::WARNING <<
"BQRaw1 : TofId is out of range, tofid = " <<
id << endmsg;
193 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
194 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
195 double a = m_Bar_East[id][2];
196 double b = m_Bar_East[id][1];
197 double c = m_Bar_East[id][0] -
q / 2.5;
198 qraw = ( sqrt( b * b - 4.0 * a * c ) - b ) / ( 2.0 * a );
204 MsgStream log(
msgSvc(), name() );
205 double qraw = -999.0;
206 if ( id < 0 || id > 175 )
208 log << MSG::WARNING <<
"BQRaw2 : TofId is out of range, tofid = " <<
id << endmsg;
211 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
212 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
213 double a = m_Bar_West[id][2];
214 double b = m_Bar_West[id][1];
215 double c = m_Bar_West[id][0] -
q / 2.5;
216 qraw = ( sqrt( b * b - 4.0 * a * c ) - b ) / ( 2.0 * a );
221 MsgStream log(
msgSvc(), name() );
222 double qraw = -999.0;
223 if ( id < 0 || id > 95 )
225 log << MSG::WARNING <<
"EQRaw : TofId is out of range, tofid = " <<
id << endmsg;
228 if ( fabs(
q - 10000.0 ) < 1.0e-6 ) {
return 10000.0; }
229 else if ( fabs(
q + 999.0 ) < 1.0e-6 ) {
return -999.0; }
230 double a = m_Endcap[id][2];
231 double b = m_Endcap[id][1];
232 double c = m_Endcap[id][0] -
q / 2.5;
233 qraw = ( sqrt( b * b - 4.0 * a * c ) - b ) / ( 2.0 * a );
DECLARE_COMPONENT(BesBdkRc)
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
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()
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)