CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
BeamEnergySvc Class Reference

#include <BeamEnergySvc.h>

+ Inheritance diagram for BeamEnergySvc:

Public Member Functions

 BeamEnergySvc (const std::string &name, ISvcLocator *svcLoc)
 
virtual ~BeamEnergySvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvIF)
 
void handle (const Incident &)
 
void getBeamEnergyInfo ()
 
bool isRunValid ()
 
double getbeamE ()
 
- Public Member Functions inherited from IBeamEnergySvc
virtual ~IBeamEnergySvc ()
 
virtual bool isRunValid ()=0
 
virtual double getbeamE ()=0
 
virtual void getBeamEnergyInfo ()=0
 

Friends

class CnvFactory< BeamEnergySvc >
 

Additional Inherited Members

- Static Public Member Functions inherited from IBeamEnergySvc
static const InterfaceID & interfaceID ()
 

Detailed Description

Definition at line 17 of file BeamEnergySvc.h.

Constructor & Destructor Documentation

◆ BeamEnergySvc()

BeamEnergySvc::BeamEnergySvc ( const std::string &  name,
ISvcLocator *  svcLoc 
)

Definition at line 22 of file BeamEnergySvc.cxx.

22 : Service(name, svcloc),
23 m_run(-1),
24 m_isRunValid(false),
25 m_beamE(0)
26{
27declareProperty("Host",m_host="bes3db2.ihep.ac.cn");
28}

◆ ~BeamEnergySvc()

BeamEnergySvc::~BeamEnergySvc ( )
virtual

Definition at line 30 of file BeamEnergySvc.cxx.

31{
32}

Member Function Documentation

◆ finalize()

StatusCode BeamEnergySvc::finalize ( )
virtual

Definition at line 67 of file BeamEnergySvc.cxx.

68{
69 MsgStream log(messageService(), name());
70 log << MSG::INFO << "@initialize()" << endreq;
71
72 StatusCode sc = Service::finalize();
73
74 return sc;
75}

◆ getbeamE()

double BeamEnergySvc::getbeamE ( )
virtual

Implements IBeamEnergySvc.

Definition at line 107 of file BeamEnergySvc.cxx.

107 {
108 if (!isRunValid()){
109 std::cerr << "ERROR in BeamEnergySvc: runNo is invalid!" << std::endl;
110 }
111 return m_beamE;
112}

◆ getBeamEnergyInfo()

void BeamEnergySvc::getBeamEnergyInfo ( )
virtual

Implements IBeamEnergySvc.

Definition at line 114 of file BeamEnergySvc.cxx.

114 {
115 MsgStream log(messageService(), name());
116 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
117 int run = eventHeader->runNumber();
118
119 if(run<0){
120 log << MSG::INFO << "This data is the MC sample with the Run Number: " << run << endreq;
121 m_isRunValid = true;
122 m_beamE = 1.8865;
123 return ;
124 //run=-run;
125 }
126 m_run = run;
127 char stmt1[400];
128
129 snprintf(stmt1, 1024,
130 "select BER_PRB, BPR_PRB "
131 "from RunParams where run_number = %d", run);
132
134 int row_no = m_dbsvc->query("run", stmt1, res);
135 if(row_no==0){
136 log << MSG::FATAL << "can not find result for BeamEnergySvc" << endreq;
137 exit(1);
138 }
139
140 m_isRunValid = true;
141
142 DatabaseRecord* records = res[0];
143 double E_E=0, E_P=0;
144 E_E = records->GetDouble("BER_PRB");
145 E_P = records->GetDouble("BPR_PRB");
146 m_beamE=(E_E+E_P)/2.0;
147
148 return;
149}
double GetDouble(std::string key)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by handle().

◆ handle()

void BeamEnergySvc::handle ( const Incident &  inc)

Definition at line 89 of file BeamEnergySvc.cxx.

89 {
90 MsgStream log( messageService(), name() );
91 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
92
93 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
94 int run = eventHeader->runNumber();
95 // if( run<0 || run>11000 ) return;
96
97 if ( inc.type() == "NewRun" ){
98 log << MSG::DEBUG << "New Run:" << run << endreq;
100 }
101}
void getBeamEnergyInfo()

◆ initialize()

StatusCode BeamEnergySvc::initialize ( )
virtual

Definition at line 34 of file BeamEnergySvc.cxx.

35{
36 MsgStream log(messageService(), name());
37 log << MSG::INFO << "@initialize()" << endreq;
38
39 StatusCode sc = Service::initialize();
40
41 if ( sc.isFailure() ) return sc;
42
43 IIncidentSvc* incsvc;
44 sc = service("IncidentSvc", incsvc);
45 int priority = 100;
46 if( sc.isSuccess() ){
47 incsvc -> addListener(this, "NewRun", priority);
48 }
49
50
51 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
52 if (sc .isFailure() ) {
53 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
54 return sc;
55 }
56
57
58 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
59 if (sc .isFailure() ) {
60 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
61 return sc;
62 }
63 m_run=0;
64 return sc;
65}

◆ isRunValid()

bool BeamEnergySvc::isRunValid ( )
virtual

Implements IBeamEnergySvc.

Definition at line 103 of file BeamEnergySvc.cxx.

103 {
104 return m_isRunValid;
105}

Referenced by getbeamE().

◆ queryInterface()

StatusCode BeamEnergySvc::queryInterface ( const InterfaceID &  riid,
void **  ppvIF 
)
virtual

Definition at line 77 of file BeamEnergySvc.cxx.

78{
79 if ( IBeamEnergySvc::interfaceID().versionMatch(riid) ) {
80 *ppvIF = dynamic_cast<IBeamEnergySvc*>(this);
81 }
82 else {
83 return Service::queryInterface(riid, ppvIF);
84 }
85 addRef();
86 return StatusCode::SUCCESS;
87}
static const InterfaceID & interfaceID()

Friends And Related Function Documentation

◆ CnvFactory< BeamEnergySvc >

friend class CnvFactory< BeamEnergySvc >
friend

Definition at line 1 of file BeamEnergySvc.h.


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