BOSS 7.1.2
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 23 of file TofEnergyCalibSvc.h.

Constructor & Destructor Documentation

◆ TofEnergyCalibSvc()

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

Definition at line 43 of file TofEnergyCalibSvc.cxx.

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

◆ ~TofEnergyCalibSvc()

TofEnergyCalibSvc::~TofEnergyCalibSvc ( )

Definition at line 57 of file TofEnergyCalibSvc.cxx.

57 {
58}

Member Function Documentation

◆ finalize()

StatusCode TofEnergyCalibSvc::finalize ( )
virtual

Definition at line 99 of file TofEnergyCalibSvc.cxx.

99 {
100 MsgStream log(messageService(), name());
101 log << MSG::INFO << "TofEnergyCalibSvc::finalize()" << endreq;
102 // if(m_connect_offline) delete m_connect_offline;
103 return StatusCode::SUCCESS;
104}

◆ GetBossRelease()

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

Definition at line 52 of file TofEnergyCalibSvc.h.

52{return m_bossRelease;}

◆ getCalibConst()

double TofEnergyCalibSvc::getCalibConst ( ) const
inline

Definition at line 53 of file TofEnergyCalibSvc.h.

53{ return m_CalibConst;}

◆ getPara1()

double TofEnergyCalibSvc::getPara1 ( ) const
inline

Definition at line 54 of file TofEnergyCalibSvc.h.

54{ return m_Para1;}

◆ getPara2()

double TofEnergyCalibSvc::getPara2 ( ) const
inline

Definition at line 55 of file TofEnergyCalibSvc.h.

55{ return m_Para2;}

◆ getPara3()

double TofEnergyCalibSvc::getPara3 ( ) const
inline

Definition at line 56 of file TofEnergyCalibSvc.h.

56{ return m_Para3;}

◆ getPara4()

double TofEnergyCalibSvc::getPara4 ( ) const
inline

Definition at line 57 of file TofEnergyCalibSvc.h.

57{ return m_Para4;}

◆ getPara5()

double TofEnergyCalibSvc::getPara5 ( ) const
inline

Definition at line 58 of file TofEnergyCalibSvc.h.

58{ 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 119 of file TofEnergyCalibSvc.cxx.

127{
128 MsgStream log(msgSvc(), "TofEnergyCalibSvc" );
129 char stmt[300];
130 int run_No =RunNo;
131 MYSQL_RES *res_set;
134 StatusCode sc=serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
135 if (sc .isFailure() ) {
136 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
137 return sc;
138 }
139
140 const char* bossRelease = BossRelease.c_str();
141 const char* dataType = DataType.c_str();
142
143 sprintf(stmt,"select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType='%s' ",bossRelease,run_No,run_No,dataType);
144
145 int row_no = m_dbsvc->query("offlinedb",stmt,res);
146 if(row_no<1){
147 std::cout<<"ERROR:error searching with:"<<stmt<<std::endl;
148 exit(1);
149 }
150 if(row_no==1){
151 DatabaseRecord* records1 = res[0];
152 runfrm=records1->GetInt("RunFrom");
153 runto=records1->GetInt("RunTo");
154 cout<<dataType<<" runfrm,runto in getSftParVer is:"<<runfrm<<"::::"<<runto<<endl;
155 SftVer=records1->GetString("SftVer");
156 CalParVer=records1->GetString("ParVer");
157 }
158 if(row_no>1){
159 cout<<"ERROR: "<<dataType<<" set overlapped run number in the table CalVtxLumVer"<<endl;
160 exit(1);
161 }
162 return StatusCode::SUCCESS;
163 }
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:18
struct st_mysql_res MYSQL_RES
IMessageSvc * msgSvc()
int GetInt(std::string key)
std::string GetString(std::string key)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
IDatabaseSvc * m_dbsvc

Referenced by getTofEnergyCalibSvcInfo().

◆ getTofEnergyCalibSvcInfo()

bool TofEnergyCalibSvc::getTofEnergyCalibSvcInfo ( )

Definition at line 164 of file TofEnergyCalibSvc.cxx.

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

106 {
107 MsgStream log( messageService(), name() );
108 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
109
110 if ( inc.type() == "NewRun" ){
111 log << MSG::DEBUG << "NewRun" << endreq;
113 log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endreq;
114 }
115 }
116}

◆ initialize()

StatusCode TofEnergyCalibSvc::initialize ( )
virtual

Definition at line 69 of file TofEnergyCalibSvc.cxx.

69 {
70 MsgStream log(messageService(), name());
71 log << MSG::INFO << "TofEnergyCalibSvc::initialize()" << endreq;
72
73 StatusCode sc = Service::initialize();
74 if( sc.isFailure() ) return sc;
75
76
77 IIncidentSvc* incsvc;
78 sc = service("IncidentSvc", incsvc);
79 int priority = 100;
80 if( sc.isSuccess() ){
81 incsvc -> addListener(this, "NewRun", priority);
82 }
83
84 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
85 if (sc .isFailure() ) {
86 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
87 return sc;
88 }
89
90 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
91 if (sc .isFailure() ) {
92 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
93 return sc;
94 }
95
96 return StatusCode::SUCCESS;
97}

◆ SetBossRelease()

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

Definition at line 51 of file TofEnergyCalibSvc.h.

51{m_bossRelease = _bossrelease;}

◆ setCalibConst()

void TofEnergyCalibSvc::setCalibConst ( double _CalibConst)
inline

Definition at line 59 of file TofEnergyCalibSvc.h.

59{m_CalibConst=_CalibConst;}

◆ setPara1()

void TofEnergyCalibSvc::setPara1 ( double _Para1)
inline

Definition at line 60 of file TofEnergyCalibSvc.h.

60{m_Para1=_Para1;}

◆ setPara2()

void TofEnergyCalibSvc::setPara2 ( double _Para2)
inline

Definition at line 61 of file TofEnergyCalibSvc.h.

61{m_Para2=_Para2;}

◆ setPara3()

void TofEnergyCalibSvc::setPara3 ( double _Para3)
inline

Definition at line 62 of file TofEnergyCalibSvc.h.

62{m_Para3=_Para3;}

◆ setPara4()

void TofEnergyCalibSvc::setPara4 ( double _Para4)
inline

Definition at line 63 of file TofEnergyCalibSvc.h.

63{m_Para4=_Para4;}

◆ setPara5()

void TofEnergyCalibSvc::setPara5 ( double _Para5)
inline

Definition at line 64 of file TofEnergyCalibSvc.h.

64{m_Para5=_Para5;}

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* TofEnergyCalibSvc::m_dbsvc

Definition at line 41 of file TofEnergyCalibSvc.h.

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


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