BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcShEnCalibSvc Class Reference

#include <EmcShEnCalibSvc.h>

+ Inheritance diagram for EmcShEnCalibSvc:

Public Member Functions

 EmcShEnCalibSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~EmcShEnCalibSvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
void SetBossRelease (const std::string &_bossrelease)
 
std::string GetBossRelease () const
 
StatusCode getSftParVer (std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
 
bool getEmcShEnCalibSvcInfo ()
 
std::string getPi0CalibFile () const
 
std::string getSingleGammaCalibFile () const
 
unsigned int getRunFrom () const
 
unsigned int getRunTo () const
 

Public Attributes

IDatabaseSvcm_dbsvc
 

Detailed Description

Definition at line 22 of file EmcShEnCalibSvc.h.

Constructor & Destructor Documentation

◆ EmcShEnCalibSvc()

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

Definition at line 40 of file EmcShEnCalibSvc.cxx.

40 :
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("BossRelease",m_bossRelease = std::string("default"));
48 declareProperty("EmcShEnCalibPar",m_calPar="default");
49 declareProperty("EmcShEnCalibBossVer",m_bossVer="default");
50 m_ReadPar = false;
51 m_RunFrom = 0;
52 m_RunTo = 0;
53}

◆ ~EmcShEnCalibSvc()

EmcShEnCalibSvc::~EmcShEnCalibSvc ( )

Definition at line 55 of file EmcShEnCalibSvc.cxx.

55 {
56}

Member Function Documentation

◆ finalize()

StatusCode EmcShEnCalibSvc::finalize ( )
virtual

Definition at line 97 of file EmcShEnCalibSvc.cxx.

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

◆ GetBossRelease()

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

Definition at line 41 of file EmcShEnCalibSvc.h.

41{return m_bossRelease;}

◆ getEmcShEnCalibSvcInfo()

bool EmcShEnCalibSvc::getEmcShEnCalibSvcInfo ( )

Definition at line 189 of file EmcShEnCalibSvc.cxx.

189 {
190 MsgStream log(messageService(), name());
191 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
192 int run = eventHeader->runNumber();
193 //cout<<"Run in getEmcShEnCalibSvcInfo() is: "<<run<<endl;
194
195 char stmt1[400];
196 StatusCode st1;
197 //runfrm,runto are the value from the table ***CalConst;runfrm1,runto1 are the value from the table CalVtxLumVer
198 int runfrm1;
199 int runto1;
200 std::string cType;
201
202 if(run<0) {
203 //cout << "This data is the MC sample with the Run Number: " << run << endl;
204 run = -run;
205 }
206
207 if(m_bossRelease=="default") m_bossRelease = getenv("BES_RELEASE");
208
209 cType="EmcShEnCalib";
210
211 st1=getSftParVer(m_bossVer,m_calPar,runfrm1,runto1,run,m_bossRelease,cType);
212
213 sprintf(stmt1, "select RunFrom,RunTo,singleGammaCalib,pi0Calib from EmcShEnCalibConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d ", m_bossVer.c_str(), run, run);
214
216 int row_no = m_dbsvc->query("offlinedb",stmt1,res);
217
218 if( row_no > 0 ) {
219 DatabaseRecord& dbrec = *res[row_no-1];
220 m_SingleGammaCalibFile = dbrec.GetString("singleGammaCalib");
221 m_Pi0CalibFile = dbrec.GetString("pi0Calib");
222 m_RunFrom = dbrec.GetInt("RunFrom");
223 m_RunTo = dbrec.GetInt("RunTo");
224
225 /*
226 cout<<"BossReleaseVer="<<m_bossRelease.c_str()<<"\t"<<"EmcShEnCalibBossVer="<<m_bossVer.c_str()<<endl;
227 cout<<"m_Pi0CalibFile is:"<<m_Pi0CalibFile<<endl;
228 cout<<"m_SingleGammaCalibFile is:"<<m_SingleGammaCalibFile<<endl;
229 cout<<"m_RunFrom is:"<<m_RunFrom<<endl;
230 cout<<"m_RunTo is:"<<m_RunTo<<endl;
231 cout << "Successfully fetch EmcShEnCalibSvc information for run: " << run << endl;
232 //cout<<"////////// read parameters from EmcShEnCalibConst database/////////////"<<endl;
233 */
234 return true;
235 } else if( row_no<=0 ) {
236 cout << " EmcShEnCalibSvc:: can not found EmcShEnCalibSvc information of run:"
237 << run << ", boss version " << m_bossRelease << endl;
238 exit(1);
239 return false;
240 }
241 return true;
242}
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)
int GetInt(std::string key)
std::string GetString(std::string key)
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
IDatabaseSvc * m_dbsvc
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by handle().

◆ getPi0CalibFile()

std::string EmcShEnCalibSvc::getPi0CalibFile ( ) const
inline

Definition at line 52 of file EmcShEnCalibSvc.h.

52{return m_Pi0CalibFile;}

◆ getRunFrom()

unsigned int EmcShEnCalibSvc::getRunFrom ( ) const
inline

Definition at line 54 of file EmcShEnCalibSvc.h.

54{ return m_RunFrom;}

◆ getRunTo()

unsigned int EmcShEnCalibSvc::getRunTo ( ) const
inline

Definition at line 55 of file EmcShEnCalibSvc.h.

55{ return m_RunTo;}

◆ getSftParVer()

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

Definition at line 139 of file EmcShEnCalibSvc.cxx.

147{
148 MsgStream log(msgSvc(), "EmcShEnCalibSvc" );
149 char stmt[300];
150 int run_No =RunNo;
151 MYSQL_RES *res_set;
154 StatusCode sc=serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
155 if (sc .isFailure() ) {
156 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
157 return sc;
158 }
159
160 const char* bossRelease = BossRelease.c_str();
161 const char* dataType = DataType.c_str();
162
163 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);
164 //cout<<"stmt="<<stmt<<endl;
165
166 int row_no = m_dbsvc->query("offlinedb",stmt,res);
167 //cout<<"raw_no="<<row_no<<endl;
168 if(row_no<1){
169 std::cout<<"ERROR:error searching with:"<<stmt<<std::endl;
170 exit(1);
171 }
172 if(row_no==1){
173 DatabaseRecord* records1 = res[0];
174 runfrm=records1->GetInt("RunFrom");
175 runto=records1->GetInt("RunTo");
176 //cout<<dataType<<" runfrm,runto in getSftParVer is:"<<runfrm<<"::::"<<runto<<endl;
177
178 SftVer=records1->GetString("SftVer");
179 CalParVer=records1->GetString("ParVer");
180 // cout<<"stmt="<<stmt<<"\t"<<SftVer<<"\t"<<CalParVer<<endl;
181 }
182 if(row_no>1){
183 cout<<"ERROR: "<<dataType<<" set overlapped run number in the table CalVtxLumVer"<<endl;
184 exit(1);
185 }
186 return StatusCode::SUCCESS;
187}
char * SftVer
Definition DQA_TO_DB.cxx:18
struct st_mysql_res MYSQL_RES
IMessageSvc * msgSvc()

Referenced by getEmcShEnCalibSvcInfo().

◆ getSingleGammaCalibFile()

std::string EmcShEnCalibSvc::getSingleGammaCalibFile ( ) const
inline

Definition at line 53 of file EmcShEnCalibSvc.h.

53{return m_SingleGammaCalibFile;}

◆ handle()

void EmcShEnCalibSvc::handle ( const Incident & inc)

Definition at line 104 of file EmcShEnCalibSvc.cxx.

104 {
105 MsgStream log( messageService(), name() );
106 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
107
108 if ( inc.type() == "NewRun" ){
109 log << MSG::DEBUG << "NewRun" << endreq;
110
111 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
112 int run = eventHeader->runNumber();
113 //cout<<"&&&&&&&&&&&&&&:&&&&&&&&&&&&&&&&&&&& EmcShEnCalibSvc handle,run="<<run<<endl;
114 if (run<0) run = -run;
115 log << MSG::DEBUG << "handle: " <<"Run in handle is: "<<run<< endreq;
116 //cout<<"-------------in EmcShEnCalibSvc in the following-----------" <<endl;
117 //cout<< "handle: " <<"Run in handle is: "<<run<<endl;
118
119 if (run>=m_RunFrom&&run<=m_RunTo&&m_ReadPar==true){
120 //cout<<"do not read the database repeatly in EmcShEnCalibConst"<<endl;
121 //cout<<"run,RunFrom,runTo="<<run<<","<<m_RunFrom<<","<<m_RunTo<<endl;
122 } else {
123
124 //cout<<"read the database in EmcShEnCalibConst"<<endl;
126 log << MSG::ERROR << "can not initilize Shower energy Calib Constants" << endreq;
127 } else {
128 m_ReadPar=true;
129 //std::cout << "in handle of EmcShEnCalibSvc getPi0CalibFile()= " << getPi0CalibFile()<<std::endl;
130 //std::cout << "getSingleGammaCalibFile()= " << getSingleGammaCalibFile() << std::endl;
131 }
132
133 }
134 }
135
136}

◆ initialize()

StatusCode EmcShEnCalibSvc::initialize ( )
virtual

Definition at line 67 of file EmcShEnCalibSvc.cxx.

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

◆ SetBossRelease()

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

Definition at line 40 of file EmcShEnCalibSvc.h.

40{m_bossRelease = _bossrelease;}

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* EmcShEnCalibSvc::m_dbsvc

Definition at line 38 of file EmcShEnCalibSvc.h.

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


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