BOSS 8.0.0
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 21 of file ScanEnergySvc.h.

Constructor & Destructor Documentation

◆ ScanEnergySvc()

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

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

Referenced by ScanEnergySvc().

◆ ~ScanEnergySvc()

ScanEnergySvc::~ScanEnergySvc ( )

Definition at line 50 of file ScanEnergySvc.cxx.

50{}

Member Function Documentation

◆ finalize()

StatusCode ScanEnergySvc::finalize ( )
virtual

Definition at line 90 of file ScanEnergySvc.cxx.

90 {
91 MsgStream log( msgSvc(), name() );
92 log << MSG::INFO << "ScanEnergySvc::finalize()" << endmsg;
93 // if(m_connect_offline) delete m_connect_offline;
94 return StatusCode::SUCCESS;
95}
IMessageSvc * msgSvc()

◆ getRunEnd()

int ScanEnergySvc::getRunEnd ( ) const
inline

Definition at line 41 of file ScanEnergySvc.h.

41{ return m_RunEnd; }

◆ getRunStart()

int ScanEnergySvc::getRunStart ( ) const
inline

Definition at line 39 of file ScanEnergySvc.h.

39{ return m_RunStart; }

◆ getScanEnergy()

double ScanEnergySvc::getScanEnergy ( ) const
inline

Definition at line 37 of file ScanEnergySvc.h.

37{ return m_ScanEnergy; }

◆ getScanEnergySvcInfo()

bool ScanEnergySvc::getScanEnergySvcInfo ( )

Definition at line 109 of file ScanEnergySvc.cxx.

109 {
110 MsgStream log( msgSvc(), name() );
111 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc, "/Event/EventHeader" );
112 int run = eventHeader->runNumber();
113
114 if ( run >= 55054 && run <= 55859 )
115 {
116
117 cout << "Run in getScanEnergySvcInfo() is: " << run << endl;
118
119 char stmt1[400];
120 if ( run < 0 )
121 {
122 cout << "This data is the MC sample with the Run Number: " << run << endl;
123 run = -run;
124 }
125
126 sprintf(
127 stmt1,
128 "select runStart,runEnd,Energy from ScanEnergy where runStart <= %d and runEnd >= %d ",
129 run, run );
130 cout << "stmt is:" << stmt1 << endl;
131 DatabaseRecordVector res;
132 int row_no = m_dbsvc->query( "offlinedb", stmt1, res );
133 if ( row_no > 0 )
134 {
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
140 << " m_RunEnd is:" << m_RunEnd << endl;
141 cout << "Successfully fetch ScanEnergySvc information for run: " << run << endl;
142 return true;
143 }
144 else if ( row_no <= 0 )
145 {
146 cout << " ScanEnergySvc:: can not found ScanEnergySvc information of run:" << run
147 << endl;
148 exit( 1 );
149 return false;
150 }
151 }
152
153 return true;
154}
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)
IDatabaseSvc * m_dbsvc

Referenced by handle().

◆ handle()

void ScanEnergySvc::handle ( const Incident & inc)

Definition at line 97 of file ScanEnergySvc.cxx.

97 {
98 MsgStream log( msgSvc(), name() );
99 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
100
101 if ( inc.type() == "NewRun" )
102 {
103 log << MSG::DEBUG << "NewRun" << endmsg;
104 if ( !getScanEnergySvcInfo() )
105 { log << MSG::ERROR << "can not initilize Tof energy Calib Constants" << endmsg; }
106 }
107}
bool getScanEnergySvcInfo()

◆ initialize()

StatusCode ScanEnergySvc::initialize ( )
virtual

Definition at line 61 of file ScanEnergySvc.cxx.

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

◆ setRunEnd()

void ScanEnergySvc::setRunEnd ( int _RunEnd)
inline

Definition at line 42 of file ScanEnergySvc.h.

42{ m_RunEnd = _RunEnd; }

◆ setRunStart()

void ScanEnergySvc::setRunStart ( int _RunStart)
inline

Definition at line 40 of file ScanEnergySvc.h.

40{ m_RunStart = _RunStart; }

◆ setScanEnergy()

void ScanEnergySvc::setScanEnergy ( double _ScanEnergy)
inline

Definition at line 38 of file ScanEnergySvc.h.

38{ m_ScanEnergy = _ScanEnergy; }

Member Data Documentation

◆ m_dbsvc

IDatabaseSvc* ScanEnergySvc::m_dbsvc

Definition at line 35 of file ScanEnergySvc.h.

Referenced by getScanEnergySvcInfo(), and initialize().


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