BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
ScanEnergySvc Class Reference

#include <ScanEnergySvc.h>

+ Inheritance diagram for ScanEnergySvc:

Public Member Functions

 ScanEnergySvc (const std::string &name, ISvcLocator *svcloc)
 
 ~ScanEnergySvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
double getScanEnergy () const
 
void setScanEnergy (double _ScanEnergy)
 
int getRunStart () const
 
void setRunStart (int _RunStart)
 
int getRunEnd () const
 
void setRunEnd (int _RunEnd)
 
bool getScanEnergySvcInfo ()
 

Public Attributes

IDatabaseSvcm_dbsvc
 

Detailed Description

Definition at line 23 of file ScanEnergySvc.h.

Constructor & Destructor Documentation

◆ ScanEnergySvc()

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

Definition at line 43 of file ScanEnergySvc.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 // m_dbsvc = DatabaseSvc::instance();
51 }

◆ ~ScanEnergySvc()

ScanEnergySvc::~ScanEnergySvc ( )

Definition at line 53 of file ScanEnergySvc.cxx.

53 {
54}

Member Function Documentation

◆ finalize()

StatusCode ScanEnergySvc::finalize ( )
virtual

Definition at line 95 of file ScanEnergySvc.cxx.

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

◆ getRunEnd()

int ScanEnergySvc::getRunEnd ( ) const
inline

Definition at line 47 of file ScanEnergySvc.h.

47{return m_RunEnd;}

◆ getRunStart()

int ScanEnergySvc::getRunStart ( ) const
inline

Definition at line 45 of file ScanEnergySvc.h.

45{return m_RunStart;}

◆ getScanEnergy()

double ScanEnergySvc::getScanEnergy ( ) const
inline

Definition at line 43 of file ScanEnergySvc.h.

43{ return m_ScanEnergy;}

◆ getScanEnergySvcInfo()

bool ScanEnergySvc::getScanEnergySvcInfo ( )

Definition at line 115 of file ScanEnergySvc.cxx.

115 {
116 MsgStream log(messageService(), name());
117 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
118 int run = eventHeader->runNumber();
119
120 if (run>=55054&&run<=55859){
121
122 cout<<"Run in getScanEnergySvcInfo() is: "<<run<<endl;
123
124 char stmt1[400];
125 if(run<0) {
126 cout << "This data is the MC sample with the Run Number: " << run << endl;
127 run = -run;
128 }
129
130 sprintf(stmt1, "select runStart,runEnd,Energy from ScanEnergy where runStart <= %d and runEnd >= %d ", run, run);
131 cout<<"stmt is:"<<stmt1<<endl;
133 int row_no = m_dbsvc->query("offlinedb",stmt1,res);
134 if( row_no > 0 ) {
135 DatabaseRecord& dbrec = *res[row_no-1];
136 m_ScanEnergy = dbrec.GetDouble("Energy");
137 m_RunStart =dbrec.GetInt("runStart");
138 m_RunEnd =dbrec.GetInt("runEnd");
139 cout<<"m_ScanEnergy is:"<<m_ScanEnergy<<" m_RunStart is:"<<m_RunStart<<" m_RunEnd is:"<<m_RunEnd<<endl;
140 cout << "Successfully fetch ScanEnergySvc information for run: "
141 << run << endl;
142 return true;
143 } else if( row_no<=0 ) {
144 cout << " ScanEnergySvc:: can not found ScanEnergySvc information of run:"
145 << run << endl;
146 exit(1);
147 return false;
148 }
149 }
150
151 return true;
152}
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)
double GetDouble(std::string key)
int GetInt(std::string key)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
IDatabaseSvc * m_dbsvc

Referenced by handle().

◆ handle()

void ScanEnergySvc::handle ( const Incident & inc)

Definition at line 102 of file ScanEnergySvc.cxx.

102 {
103 MsgStream log( messageService(), name() );
104 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
105
106 if ( inc.type() == "NewRun" ){
107 log << MSG::DEBUG << "NewRun" << endreq;
109 log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endreq;
110 }
111 }
112}
bool getScanEnergySvcInfo()

◆ initialize()

StatusCode ScanEnergySvc::initialize ( )
virtual

Definition at line 65 of file ScanEnergySvc.cxx.

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

◆ setRunEnd()

void ScanEnergySvc::setRunEnd ( int _RunEnd)
inline

Definition at line 48 of file ScanEnergySvc.h.

48{m_RunEnd=_RunEnd;}

◆ setRunStart()

void ScanEnergySvc::setRunStart ( int _RunStart)
inline

Definition at line 46 of file ScanEnergySvc.h.

46{m_RunStart=_RunStart;}

◆ setScanEnergy()

void ScanEnergySvc::setScanEnergy ( double _ScanEnergy)
inline

Definition at line 44 of file ScanEnergySvc.h.

44{m_ScanEnergy=_ScanEnergy;}

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* ScanEnergySvc::m_dbsvc

Definition at line 40 of file ScanEnergySvc.h.

Referenced by getScanEnergySvcInfo(), and initialize().


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