BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TofEnergyCalibSvc Class Reference

#include <TofEnergyCalibSvc.h>

Inheritance diagram for TofEnergyCalibSvc:

Public Member Functions

 TofEnergyCalibSvc (const std::string &name, ISvcLocator *svcloc)
 ~TofEnergyCalibSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
void SetBossRelease (const std::string &_bossrelease)
std::string GetBossRelease () const
double getCalibConst () const
double getPara1 () const
double getPara2 () const
double getPara3 () const
double getPara4 () const
double getPara5 () const
void setCalibConst (double _CalibConst)
void setPara1 (double _Para1)
void setPara2 (double _Para2)
void setPara3 (double _Para3)
void setPara4 (double _Para4)
void setPara5 (double _Para5)
StatusCode getSftParVer (std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
bool getTofEnergyCalibSvcInfo ()

Public Attributes

IDatabaseSvcm_dbsvc

Detailed Description

Definition at line 22 of file TofEnergyCalibSvc.h.

Constructor & Destructor Documentation

◆ TofEnergyCalibSvc()

TofEnergyCalibSvc::TofEnergyCalibSvc ( const std::string & name,
ISvcLocator * svcloc )

Definition at line 40 of file TofEnergyCalibSvc.cxx.

41 : base_class( name, svcloc ) {
42 // declare properties
43 declareProperty( "Host", host = std::string( "bes3db2.ihep.ac.cn" ) );
44 declareProperty( "DbName", dbName = std::string( "offlinedb" ) );
45 declareProperty( "UserName", userName = std::string( "guest" ) );
46 declareProperty( "Password", password = std::string( "guestpass" ) );
47 declareProperty( "IsData", m_isData = std::string( "default" ) );
48 declareProperty( "BossRelease", m_bossRelease = std::string( "default" ) );
49 declareProperty( "TofEnergyPar", m_calPar = "default" );
50 declareProperty( "TofEnergyBossVer", m_bossVer = "default" );
51 // m_dbsvc = DatabaseSvc::instance();
52}

Referenced by TofEnergyCalibSvc().

◆ ~TofEnergyCalibSvc()

TofEnergyCalibSvc::~TofEnergyCalibSvc ( )

Definition at line 54 of file TofEnergyCalibSvc.cxx.

54{}

Member Function Documentation

◆ finalize()

StatusCode TofEnergyCalibSvc::finalize ( )
virtual

Definition at line 85 of file TofEnergyCalibSvc.cxx.

85 {
86 MsgStream log( msgSvc(), name() );
87 log << MSG::INFO << "TofEnergyCalibSvc::finalize()" << endmsg;
88 // if(m_connect_offline) delete m_connect_offline;
89 return StatusCode::SUCCESS;
90}
IMessageSvc * msgSvc()

◆ GetBossRelease()

std::string TofEnergyCalibSvc::GetBossRelease ( ) const
inline

Definition at line 50 of file TofEnergyCalibSvc.h.

50{ return m_bossRelease; }

◆ getCalibConst()

double TofEnergyCalibSvc::getCalibConst ( ) const
inline

Definition at line 51 of file TofEnergyCalibSvc.h.

51{ return m_CalibConst; }

◆ getPara1()

double TofEnergyCalibSvc::getPara1 ( ) const
inline

Definition at line 52 of file TofEnergyCalibSvc.h.

52{ return m_Para1; }

◆ getPara2()

double TofEnergyCalibSvc::getPara2 ( ) const
inline

Definition at line 53 of file TofEnergyCalibSvc.h.

53{ return m_Para2; }

◆ getPara3()

double TofEnergyCalibSvc::getPara3 ( ) const
inline

Definition at line 54 of file TofEnergyCalibSvc.h.

54{ return m_Para3; }

◆ getPara4()

double TofEnergyCalibSvc::getPara4 ( ) const
inline

Definition at line 55 of file TofEnergyCalibSvc.h.

55{ return m_Para4; }

◆ getPara5()

double TofEnergyCalibSvc::getPara5 ( ) const
inline

Definition at line 56 of file TofEnergyCalibSvc.h.

56{ return m_Para5; }

◆ getSftParVer()

StatusCode TofEnergyCalibSvc::getSftParVer ( std::string & SftVer,
std::string & CalParVer,
int & runfrm,
int & runto,
int RunNo,
std::string BossRelease,
std::string DataType )

Definition at line 105 of file TofEnergyCalibSvc.cxx.

107 {
108 MsgStream log( msgSvc(), "TofEnergyCalibSvc" );
109 char stmt[300];
110 int run_No = RunNo;
111 MYSQL_RES* res_set;
112 IDatabaseSvc* m_dbsvc;
113 DatabaseRecordVector res;
114 StatusCode sc = serviceLocator()->service( "DatabaseSvc", m_dbsvc, true );
115 if ( sc.isFailure() )
116 {
117 log << MSG::ERROR << " Unable to find DatabaseSvc " << endmsg;
118 return sc;
119 }
120
121 const char* bossRelease = BossRelease.c_str();
122 const char* dataType = DataType.c_str();
123
124 sprintf( stmt,
125 "select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and "
126 "RunFrom <= %d and RunTo "
127 ">= %d and DataType='%s' ",
128 bossRelease, run_No, run_No, dataType );
129
130 int row_no = m_dbsvc->query( "offlinedb", stmt, res );
131 if ( row_no < 1 )
132 {
133 std::cout << "ERROR:error searching with:" << stmt << std::endl;
134 exit( 1 );
135 }
136 if ( row_no == 1 )
137 {
138 DatabaseRecord* records1 = res[0];
139 runfrm = records1->GetInt( "RunFrom" );
140 runto = records1->GetInt( "RunTo" );
141 cout << dataType << " runfrm,runto in getSftParVer is:" << runfrm << "::::" << runto
142 << endl;
143 SftVer = records1->GetString( "SftVer" );
144 CalParVer = records1->GetString( "ParVer" );
145 }
146 if ( row_no > 1 )
147 {
148 cout << "ERROR: " << dataType << " set overlapped run number in the table CalVtxLumVer"
149 << endl;
150 exit( 1 );
151 }
152 return StatusCode::SUCCESS;
153}
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)
char * SftVer
Definition DQA_TO_DB.cxx:19
IDatabaseSvc * m_dbsvc

Referenced by getTofEnergyCalibSvcInfo().

◆ getTofEnergyCalibSvcInfo()

bool TofEnergyCalibSvc::getTofEnergyCalibSvcInfo ( )

Definition at line 154 of file TofEnergyCalibSvc.cxx.

154 {
155 MsgStream log( msgSvc(), name() );
156 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc, "/Event/EventHeader" );
157 int run = eventHeader->runNumber();
158 // cout<<"Run in getTofEnergyCalibSvcInfo() is: "<<run<<endl;
159
160 char stmt1[400];
161 StatusCode st1;
162 // runfrm,runto are the value from the table ***CalConst;runfrm1,runto1 are the value from
163 // the table CalVtxLumVer
164 int runfrm, runfrm1;
165 int runto, runto1;
166std:
167 string cType;
168
169 if ( run < 0 )
170 {
171 cout << "This data is the MC sample with the Run Number: " << run << endl;
172 run = -run;
173 }
174
175 if ( m_bossRelease == "default" ) m_bossRelease = getenv( "BES_RELEASE" );
176 if ( m_isData == "default" )
177 {
178 cout << "Please set the type of TofEnergy" << endl;
179 exit( 1 );
180 }
181 if ( m_isData == "Data" ) cType = "TofEnergyData";
182 if ( m_isData == "MC" ) cType = "TofEnergyMC";
183 st1 = getSftParVer( m_bossVer, m_calPar, runfrm1, runto1, run, m_bossRelease, cType );
184 if ( cType == "TofEnergyData" )
185 {
186 sprintf( stmt1,
187 "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergyCalib where "
188 "BossVer = '%s' and RunFrom <= "
189 "%d and RunTo >= %d and isData = '%s'",
190 m_bossVer.c_str(), run, run, m_isData.c_str() );
191 }
192 else if ( cType == "TofEnergyMC" )
193 {
194 sprintf( stmt1,
195 "select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergySim where BossVer "
196 "= '%s' and RunFrom <= %d "
197 "and RunTo >= %d and isData = '%s'",
198 m_bossVer.c_str(), run, run, m_isData.c_str() );
199 }
200 // cout<<"stmt is:"<<stmt1<<endl;
201 DatabaseRecordVector res;
202 int row_no = m_dbsvc->query( "offlinedb", stmt1, res );
203 if ( row_no > 0 )
204 {
205 DatabaseRecord& dbrec = *res[row_no - 1];
206 m_CalibConst = dbrec.GetDouble( "CalibConst" );
207 m_Para1 = dbrec.GetDouble( "Para1" );
208 m_Para2 = dbrec.GetDouble( "Para2" );
209 m_Para3 = dbrec.GetDouble( "Para3" );
210 m_Para4 = dbrec.GetDouble( "Para4" );
211 m_Para5 = dbrec.GetDouble( "Para5" );
212 cout << stmt1 << endl;
213 cout << "BossReleaseVer=" << m_bossRelease.c_str() << "\t"
214 << "TofEnergyBossVer=" << m_bossVer.c_str() << endl;
215 cout << "m_CalibConst is:" << m_CalibConst << endl;
216 cout << "Para1=" << m_Para1 << "\t"
217 << "Para2=" << m_Para2 << "\t"
218 << "Para3=" << m_Para3 << "\t"
219 << "Para4=" << m_Para4 << "\t"
220 << "Para5=" << m_Para5 << endl;
221 cout << "Successfully fetch TofEnergyCalibSvc information for run: " << run << endl;
222 return true;
223 }
224 else if ( row_no <= 0 )
225 {
226 cout << " TofEnergyCalibSvc:: can not found TofEnergyCalibSvc information of run:" << run
227 << ", boss version " << m_bossRelease << endl;
228 exit( 1 );
229 return false;
230 }
231 return true;
232}
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)

Referenced by handle().

◆ handle()

void TofEnergyCalibSvc::handle ( const Incident & inc)

Definition at line 92 of file TofEnergyCalibSvc.cxx.

92 {
93 MsgStream log( msgSvc(), name() );
94 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
95
96 if ( inc.type() == "NewRun" )
97 {
98 log << MSG::DEBUG << "NewRun" << endmsg;
100 { log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endmsg; }
101 }
102}

◆ initialize()

StatusCode TofEnergyCalibSvc::initialize ( )
virtual

Definition at line 56 of file TofEnergyCalibSvc.cxx.

56 {
57 MsgStream log( msgSvc(), name() );
58 log << MSG::INFO << "TofEnergyCalibSvc::initialize()" << endmsg;
59
60 StatusCode sc = Service::initialize();
61 if ( sc.isFailure() ) return sc;
62
63 IIncidentSvc* incsvc;
64 sc = service( "IncidentSvc", incsvc );
65 int priority = 100;
66 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
67
68 sc = serviceLocator()->service( "DatabaseSvc", m_dbsvc, true );
69 if ( sc.isFailure() )
70 {
71 log << MSG::ERROR << "Unable to find DatabaseSvc " << endmsg;
72 return sc;
73 }
74
75 sc = serviceLocator()->service( "EventDataSvc", m_eventSvc, true );
76 if ( sc.isFailure() )
77 {
78 log << MSG::ERROR << "Unable to find EventDataSvc " << endmsg;
79 return sc;
80 }
81
82 return StatusCode::SUCCESS;
83}

◆ SetBossRelease()

void TofEnergyCalibSvc::SetBossRelease ( const std::string & _bossrelease)
inline

Definition at line 49 of file TofEnergyCalibSvc.h.

49{ m_bossRelease = _bossrelease; }

◆ setCalibConst()

void TofEnergyCalibSvc::setCalibConst ( double _CalibConst)
inline

Definition at line 57 of file TofEnergyCalibSvc.h.

57{ m_CalibConst = _CalibConst; }

◆ setPara1()

void TofEnergyCalibSvc::setPara1 ( double _Para1)
inline

Definition at line 58 of file TofEnergyCalibSvc.h.

58{ m_Para1 = _Para1; }

◆ setPara2()

void TofEnergyCalibSvc::setPara2 ( double _Para2)
inline

Definition at line 59 of file TofEnergyCalibSvc.h.

59{ m_Para2 = _Para2; }

◆ setPara3()

void TofEnergyCalibSvc::setPara3 ( double _Para3)
inline

Definition at line 60 of file TofEnergyCalibSvc.h.

60{ m_Para3 = _Para3; }

◆ setPara4()

void TofEnergyCalibSvc::setPara4 ( double _Para4)
inline

Definition at line 61 of file TofEnergyCalibSvc.h.

61{ m_Para4 = _Para4; }

◆ setPara5()

void TofEnergyCalibSvc::setPara5 ( double _Para5)
inline

Definition at line 62 of file TofEnergyCalibSvc.h.

62{ m_Para5 = _Para5; }

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* TofEnergyCalibSvc::m_dbsvc

Definition at line 38 of file TofEnergyCalibSvc.h.

Referenced by getSftParVer(), getTofEnergyCalibSvcInfo(), and initialize().


The documentation for this class was generated from the following files: