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

#include <EmcSatuDeadEnSvc.h>

+ Inheritance diagram for EmcSatuDeadEnSvc:

Public Member Functions

 EmcSatuDeadEnSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~EmcSatuDeadEnSvc ()
 
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 getEmcSatuDeadEnSvcInfo ()
 
std::string getSatuEnFile () const
 
std::string getDeadEnFile () const
 
unsigned int getRunFrom () const
 
unsigned int getRunTo () const
 

Public Attributes

IDatabaseSvcm_dbsvc
 

Detailed Description

Definition at line 22 of file EmcSatuDeadEnSvc.h.

Constructor & Destructor Documentation

◆ EmcSatuDeadEnSvc()

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

Definition at line 40 of file EmcSatuDeadEnSvc.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("EmcSatuDeadEnPar",m_calPar="default");
49 declareProperty("EmcSatuDeadEnBossVer",m_bossVer="default");
50 m_ReadPar = false;
51 m_RunFrom = 0;
52 m_RunTo = 0;
53}

◆ ~EmcSatuDeadEnSvc()

EmcSatuDeadEnSvc::~EmcSatuDeadEnSvc ( )

Definition at line 55 of file EmcSatuDeadEnSvc.cxx.

55 {
56}

Member Function Documentation

◆ finalize()

StatusCode EmcSatuDeadEnSvc::finalize ( )
virtual

Definition at line 88 of file EmcSatuDeadEnSvc.cxx.

88 {
89 MsgStream log(messageService(), name());
90 log << MSG::INFO << "EmcSatuDeadEnSvc::finalize()" << endreq;
91
92 return StatusCode::SUCCESS;
93}

◆ GetBossRelease()

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

Definition at line 41 of file EmcSatuDeadEnSvc.h.

41{return m_bossRelease;}

◆ getDeadEnFile()

std::string EmcSatuDeadEnSvc::getDeadEnFile ( ) const
inline

Definition at line 53 of file EmcSatuDeadEnSvc.h.

53{return m_DeadEnFile;}

◆ getEmcSatuDeadEnSvcInfo()

bool EmcSatuDeadEnSvc::getEmcSatuDeadEnSvcInfo ( )

Definition at line 181 of file EmcSatuDeadEnSvc.cxx.

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

◆ getRunFrom()

unsigned int EmcSatuDeadEnSvc::getRunFrom ( ) const
inline

Definition at line 54 of file EmcSatuDeadEnSvc.h.

54{ return m_RunFrom;}

◆ getRunTo()

unsigned int EmcSatuDeadEnSvc::getRunTo ( ) const
inline

Definition at line 55 of file EmcSatuDeadEnSvc.h.

55{ return m_RunTo;}

◆ getSatuEnFile()

std::string EmcSatuDeadEnSvc::getSatuEnFile ( ) const
inline

Definition at line 52 of file EmcSatuDeadEnSvc.h.

52{return m_SatuEnFile;}

◆ getSftParVer()

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

Definition at line 131 of file EmcSatuDeadEnSvc.cxx.

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

Referenced by getEmcSatuDeadEnSvcInfo().

◆ handle()

void EmcSatuDeadEnSvc::handle ( const Incident & inc)

Definition at line 95 of file EmcSatuDeadEnSvc.cxx.

95 {
96 MsgStream log( messageService(), name() );
97 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
98
99 /*
100 if ( inc.type() == "NewRun" ){
101 log << MSG::DEBUG << "NewRun" << endreq;
102
103 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
104 int run = eventHeader->runNumber();
105 //cout<<"&&&&&&&&&&&&&&:&&&&&&&&&&&&&&&&&&&& EmcSatuDeadEnSvc handle,run="<<run<<endl;
106 if (run<0) run = -run;
107 log << MSG::DEBUG << "handle: " <<"Run in handle is: "<<run<< endreq;
108 log << MSG::DEBUG << "-------------in EmcSatuDeadEnSvc in the following-----------" <<endreq;
109 log << MSG::DEBUG << "handle: " <<"Run in handle is: "<<run<<endreq;
110
111 if (run>=m_RunFrom&&run<=m_RunTo&&m_ReadPar==true){
112 log << MSG::DEBUG << "do not read the database repeatly in EmcSatuDeadEn"<<endreq;
113 log << MSG::DEBUG << "run,RunFrom,runTo="<<run<<","<<m_RunFrom<<","<<m_RunTo <<endreq;
114 } else {
115
116 log << MSG::DEBUG << "read the database in EmcSatuDeadEn" <<endreq;
117 if(!getEmcSatuDeadEnSvcInfo()){
118 log << MSG::ERROR << "can not get EmcSatuDeadEnSvc" << endreq;
119 } else {
120 m_ReadPar=true;
121 log << MSG::DEBUG << "in handle of EmcSatuDeadEnSvc getSatuEnFile()= " << getSatuEnFile()<<std::endreq;
122 log << MSG::DEBUG << "getDeadEnFile()= " << getDeadEnFile() << std::endreq;
123 }
124
125 }
126 } // NewRun
127 */
128}

◆ initialize()

StatusCode EmcSatuDeadEnSvc::initialize ( )
virtual

Definition at line 58 of file EmcSatuDeadEnSvc.cxx.

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

◆ SetBossRelease()

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

Definition at line 40 of file EmcSatuDeadEnSvc.h.

40{m_bossRelease = _bossrelease;}

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* EmcSatuDeadEnSvc::m_dbsvc

Definition at line 38 of file EmcSatuDeadEnSvc.h.

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


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