BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
MeasuredEcmsSvc Class Reference

#include <MeasuredEcmsSvc.h>

+ Inheritance diagram for MeasuredEcmsSvc:

Public Member Functions

 MeasuredEcmsSvc (const std::string &name, ISvcLocator *svcLoc)
 
virtual ~MeasuredEcmsSvc ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvIF)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
void readMeasuredEcms (int runNo)
 
void readRunParams (int runNo)
 
void readDB (int runNo)
 
int getSampleName (int runNo)
 
int getRunFrom (int runNo)
 
int getRunTo (int runNo)
 
bool isRunNoValid (int runNo)
 
double getEcms (int runNo)
 
double getEcmsErr (int runNo)
 
double getAveEcms (int runNo)
 
double getAveEcmsErr (int runNo)
 
double getPx (int runNo)
 
double getPy (int runNo)
 
double getPz (int runNo)
 
 MeasuredEcmsSvc (const std::string &name, ISvcLocator *svcLoc)
 
virtual ~MeasuredEcmsSvc ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvIF)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
void readMeasuredEcms (int runNo)
 
void readRunParams (int runNo)
 
void readDB (int runNo)
 
int getSampleName (int runNo)
 
int getRunFrom (int runNo)
 
int getRunTo (int runNo)
 
bool isRunNoValid (int runNo)
 
double getEcms (int runNo)
 
double getEcmsErr (int runNo)
 
double getAveEcms (int runNo)
 
double getAveEcmsErr (int runNo)
 
double getPx (int runNo)
 
double getPy (int runNo)
 
double getPz (int runNo)
 
- Public Member Functions inherited from IMeasuredEcmsSvc
virtual ~IMeasuredEcmsSvc ()
 
virtual void readMeasuredEcms (int runNo)=0
 
virtual void readRunParams (int runNo)=0
 
virtual void readDB (int runNo)=0
 
virtual int getSampleName (int runNo)=0
 
virtual int getRunFrom (int runNo)=0
 
virtual int getRunTo (int runNo)=0
 
virtual bool isRunNoValid (int runNo)=0
 
virtual double getEcms (int runNo)=0
 
virtual double getEcmsErr (int runNo)=0
 
virtual double getAveEcms (int runNo)=0
 
virtual double getAveEcmsErr (int runNo)=0
 
virtual ~IMeasuredEcmsSvc ()
 
virtual void readMeasuredEcms (int runNo)=0
 
virtual void readRunParams (int runNo)=0
 
virtual void readDB (int runNo)=0
 
virtual int getSampleName (int runNo)=0
 
virtual int getRunFrom (int runNo)=0
 
virtual int getRunTo (int runNo)=0
 
virtual bool isRunNoValid (int runNo)=0
 
virtual double getEcms (int runNo)=0
 
virtual double getEcmsErr (int runNo)=0
 
virtual double getAveEcms (int runNo)=0
 
virtual double getAveEcmsErr (int runNo)=0
 

Friends

class CnvFactory< MeasuredEcmsSvc >
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ MeasuredEcmsSvc() [1/2]

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

Definition at line 4 of file MeasuredEcmsSvc.cxx.

4 :Service(name, svcLoc){
5 declareProperty("RunParamsMin", RunParamsMin=11414);
6 declareProperty("RunParamsMax", RunParamsMax=23454);
7 declareProperty("MeasuredEcmsMin", MeasuredEcmsMin=23463);
8 declareProperty("MeasuredEcmsMax", MeasuredEcmsMax=38140);
9}

◆ ~MeasuredEcmsSvc() [1/2]

MeasuredEcmsSvc::~MeasuredEcmsSvc ( )
virtual

Definition at line 11 of file MeasuredEcmsSvc.cxx.

11{}

◆ MeasuredEcmsSvc() [2/2]

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

◆ ~MeasuredEcmsSvc() [2/2]

virtual MeasuredEcmsSvc::~MeasuredEcmsSvc ( )
virtual

Member Function Documentation

◆ finalize() [1/2]

StatusCode MeasuredEcmsSvc::finalize ( )
virtual

Definition at line 39 of file MeasuredEcmsSvc.cxx.

39 {
40 MsgStream log(msgSvc(), name());
41 log<<MSG::INFO<<"MeasuredEcmsSvc finalize begin here"<<endreq;
42 StatusCode status= Service::finalize();
43 if(!status.isSuccess()){
44 log<<MSG::ERROR<<"MeasuredEcmsSvc Can not finalize"<<endreq;
45 return status;
46 }
47 log<<MSG::INFO<<"MeasuredEcmsSvc finalized successfully"<<endreq;
48 return StatusCode::SUCCESS;
49}

◆ finalize() [2/2]

virtual StatusCode MeasuredEcmsSvc::finalize ( )
virtual

◆ getAveEcms() [1/2]

double MeasuredEcmsSvc::getAveEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 180 of file MeasuredEcmsSvc.cxx.

180 {
181 MsgStream log(msgSvc(), name());
182 log<<MSG::INFO<<"MeasuredEcmsSvc read the average ecms"<<endreq;
183 if(m_recallRead&&m_callRead){
184 readDB(runNo);
185 m_recallRead=false;
186 }
187 return m_aveEcms;
188}
int runNo
Definition: DQA_TO_DB.cxx:12
void readDB(int runNo)

◆ getAveEcms() [2/2]

double MeasuredEcmsSvc::getAveEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getAveEcmsErr() [1/2]

double MeasuredEcmsSvc::getAveEcmsErr ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 190 of file MeasuredEcmsSvc.cxx.

190 {
191 MsgStream log(msgSvc(), name());
192 log<<MSG::INFO<<"MeasuredEcmsSvc read the error of the average ecms"<<endreq;
193 if(m_recallRead&&m_callRead){
194 readDB(runNo);
195 m_recallRead=false;
196 }
197 return m_aveEcmsErr;
198}

◆ getAveEcmsErr() [2/2]

double MeasuredEcmsSvc::getAveEcmsErr ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getEcms() [1/2]

double MeasuredEcmsSvc::getEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 160 of file MeasuredEcmsSvc.cxx.

160 {
161 MsgStream log(msgSvc(), name());
162 log<<MSG::INFO<<"MeasuredEcmsSvc read the ecms"<<endreq;
163 if(m_recallRead&&m_callRead){
164 readDB(runNo);
165 m_recallRead=false;
166 }
167 return m_ecms;
168}

◆ getEcms() [2/2]

double MeasuredEcmsSvc::getEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getEcmsErr() [1/2]

double MeasuredEcmsSvc::getEcmsErr ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 170 of file MeasuredEcmsSvc.cxx.

170 {
171 MsgStream log(msgSvc(), name());
172 log<<MSG::INFO<<"MeasuredEcmsSvc read the error of ecms"<<endreq;
173 if(m_recallRead&&m_callRead){
174 readDB(runNo);
175 m_recallRead=false;
176 }
177 return m_ecmsErr;
178}

◆ getEcmsErr() [2/2]

double MeasuredEcmsSvc::getEcmsErr ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getPx() [1/2]

double MeasuredEcmsSvc::getPx ( int  runNo)

◆ getPx() [2/2]

double MeasuredEcmsSvc::getPx ( int  runNo)

◆ getPy() [1/2]

double MeasuredEcmsSvc::getPy ( int  runNo)

◆ getPy() [2/2]

double MeasuredEcmsSvc::getPy ( int  runNo)

◆ getPz() [1/2]

double MeasuredEcmsSvc::getPz ( int  runNo)

◆ getPz() [2/2]

double MeasuredEcmsSvc::getPz ( int  runNo)

◆ getRunFrom() [1/2]

int MeasuredEcmsSvc::getRunFrom ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 140 of file MeasuredEcmsSvc.cxx.

140 {
141 MsgStream log(msgSvc(), name());
142 log<<MSG::INFO<<"MeasuredEcmsSvc read the RunFrom"<<endreq;
143 if(m_recallRead&&m_callRead){
144 readDB(runNo);
145 m_recallRead=false;
146 }
147 return m_runFrom;
148}

◆ getRunFrom() [2/2]

int MeasuredEcmsSvc::getRunFrom ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getRunTo() [1/2]

int MeasuredEcmsSvc::getRunTo ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 150 of file MeasuredEcmsSvc.cxx.

150 {
151 MsgStream log(msgSvc(), name());
152 log<<MSG::INFO<<"MeasuredEcmsSvc read the RunTo"<<endreq;
153 if(m_recallRead&&m_callRead){
154 readDB(runNo);
155 m_recallRead=false;
156 }
157 return m_runTo;
158}

◆ getRunTo() [2/2]

int MeasuredEcmsSvc::getRunTo ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ getSampleName() [1/2]

int MeasuredEcmsSvc::getSampleName ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 130 of file MeasuredEcmsSvc.cxx.

130 {
131 MsgStream log(msgSvc(), name());
132 log<<MSG::INFO<<"MeasuredEcmsSvc read the sample name"<<endreq;
133 if(m_recallRead&&m_callRead){
134 readDB(runNo);
135 m_recallRead=false;
136 }
137 return m_sampleName;
138}

◆ getSampleName() [2/2]

int MeasuredEcmsSvc::getSampleName ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ handle() [1/2]

void MeasuredEcmsSvc::handle ( const Incident &  inc)

Definition at line 58 of file MeasuredEcmsSvc.cxx.

58 {
59 MsgStream log(messageService(), name());
60 log<<MSG::DEBUG<<"handle: "<<inc.type()<<endreq;
61 m_callRead=false; m_recallRead=true;
62 if(inc.type()=="NewRun"){
63 log<<MSG::INFO<<"RunNo is new, call the readMeasuredEcms again"<<endreq;
64 m_callRead=true;
65 }
66}

◆ handle() [2/2]

void MeasuredEcmsSvc::handle ( const Incident &  )

◆ initialize() [1/2]

StatusCode MeasuredEcmsSvc::initialize ( )
virtual

Definition at line 13 of file MeasuredEcmsSvc.cxx.

13 {
14 MsgStream log(msgSvc(), name());
15 log<<MSG::INFO<<"MeasuredEcmsSvc initialize begin here"<<endreq;
16 StatusCode status=Service::initialize();
17 if(!status.isSuccess()){
18 log<<MSG::ERROR<<"MeasuredEcmsSvc Can not initialize"<<endreq;
19 return status;
20 }
21 IIncidentSvc* incsvc;
22 status=service("IncidentSvc", incsvc);
23 int priority = 100;
24 if(status.isSuccess()) incsvc->addListener(this, "NewRun", priority);
25 status=serviceLocator()->service("DatabaseSvc", m_dbSvc, true);
26 if(!status.isSuccess()){
27 log<<MSG::ERROR<<"MeasuredEcmsSvc Unable to find DatabaseSvc"<<endreq;
28 return status;
29 }
30 status=serviceLocator()->service("EventDataSvc", m_eventSvc, true);
31 if(!status.isSuccess()){
32 log<<MSG::ERROR<<"MeasuredEcmsSvc Unable to find EventDataSvc "<<endreq;
33 return status;
34 }
35 log<<MSG::INFO<<"MeasuredEcmsSvc initialized successfully"<<endreq;
36 return StatusCode::SUCCESS;
37}

◆ initialize() [2/2]

virtual StatusCode MeasuredEcmsSvc::initialize ( )
virtual

◆ isRunNoValid() [1/2]

bool MeasuredEcmsSvc::isRunNoValid ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 200 of file MeasuredEcmsSvc.cxx.

200 {
201 MsgStream log(msgSvc(), name());
202 log<<MSG::INFO<<"MeasuredEcmsSvc judge the valid of runNo"<<endreq;
203 if(m_callRead){
204 readDB(runNo);
205 m_recallRead=false;
206 }
207 return m_runNoValid;
208}

◆ isRunNoValid() [2/2]

bool MeasuredEcmsSvc::isRunNoValid ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ queryInterface() [1/2]

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

Definition at line 51 of file MeasuredEcmsSvc.cxx.

51 {
52 if(IMeasuredEcmsSvc::interfaceID().versionMatch(riid)) *ppvIF = dynamic_cast<IMeasuredEcmsSvc*>(this);
53 else return Service::queryInterface(riid, ppvIF);
54 addRef();
55 return StatusCode::SUCCESS;
56}

◆ queryInterface() [2/2]

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

◆ readDB() [1/2]

void MeasuredEcmsSvc::readDB ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 125 of file MeasuredEcmsSvc.cxx.

125 {
126 if(std::abs(runNo)>=RunParamsMin&&std::abs(runNo)<=RunParamsMax) readRunParams(runNo);
127 if(std::abs(runNo)>=MeasuredEcmsMin&&std::abs(runNo)<=MeasuredEcmsMax) readMeasuredEcms(runNo);
128}
void readRunParams(int runNo)
void readMeasuredEcms(int runNo)

Referenced by getAveEcms(), getAveEcmsErr(), getEcms(), getEcmsErr(), getRunFrom(), getRunTo(), getSampleName(), and isRunNoValid().

◆ readDB() [2/2]

void MeasuredEcmsSvc::readDB ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ readMeasuredEcms() [1/2]

void MeasuredEcmsSvc::readMeasuredEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 68 of file MeasuredEcmsSvc.cxx.

68 {
69 MsgStream log(msgSvc(), name());
70 log<<MSG::INFO<<"MeasuredEcmsSvc begin read database MeasuredEcmsSvc"<<endreq;
71 m_sampleName=0; m_ecms=0; m_ecmsErr=0;
72 m_aveEcms=0; m_aveEcmsErr=0; m_runFrom=0;
73 m_runTo=0; m_runNoValid=false;
74 m_px=0; m_py=0; m_pz=0;
75 int runNum=std::abs(runNo);
76 if(runNo<0) log<<MSG::INFO<<"MeasuredEcmsSvc for MC events"<<endreq;
77 else log<<MSG::INFO<<"MeasuredEcmsSvc for DT events"<<endreq;
78 char stmt[400];
79 snprintf(stmt, 1024, "select sample, RunFrom, RunTo, Ecms, Ecms_err, Ave_Ecms, Ave_Ecms_err from MeasuredEcms2 where RunFrom <= %d and RunTo >= %d", runNum, runNum);
81 int rowNo=m_dbSvc->query("offlinedb", stmt, res);
82 if(rowNo==0){ log<<MSG::ERROR<<"RowNo can not be 0 for MeasuredEcmsSvc, failed to read DB"<<endreq; }
83 else{
84 DatabaseRecord* records=res[0];
85 log<<MSG::INFO<<"MeasuredEcmsSvc first read the runNo, read the MeasuredEcms database"<<runNo<<endreq;
86 m_runFrom=records->GetDouble("RunFrom");
87 m_runTo=records->GetDouble("RunTo");
88 m_sampleName=records->GetDouble("sample");
89 m_ecms=records->GetDouble("Ecms");
90 m_ecmsErr=records->GetDouble("Ecms_err");
91 m_aveEcms=records->GetDouble("Ave_Ecms");
92 m_aveEcmsErr=records->GetDouble("Ave_Ecms_err");
93 m_runNoValid=true;
94 }
95}
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by readDB().

◆ readMeasuredEcms() [2/2]

void MeasuredEcmsSvc::readMeasuredEcms ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

◆ readRunParams() [1/2]

void MeasuredEcmsSvc::readRunParams ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Definition at line 97 of file MeasuredEcmsSvc.cxx.

97 {
98 MsgStream log(msgSvc(), name());
99 log<<MSG::INFO<<"MeasuredEcmsSvc begin read database RunParams"<<endreq;
100 m_sampleName=0; m_ecms=0; m_ecmsErr=0;
101 m_aveEcms=0; m_aveEcmsErr=0; m_runFrom=0;
102 m_runTo=0; m_runNoValid=false;
103 m_px=0; m_py=0; m_pz=0;
104 int runNum=std::abs(runNo);
105 if(runNo<0) log<<MSG::INFO<<"MeasuredEcmsSvc for MC events"<<endreq;
106 else log<<MSG::INFO<<"MeasuredEcmsSvc for DT events"<<endreq;
107 char stmt1[400];
108 snprintf(stmt1, 1024, "select beam_energy, px, py, pz from RunParams where run_number = %d", runNum);
110 int row_no = m_dbSvc->query("offlinedb", stmt1, res);
111 if(row_no==0){log<<MSG::ERROR<<"RowNo can not be 0 for RunParams, failed to read DB"<<endreq;}
112 else{
113 DatabaseRecord* records = res[0];
114 log<<MSG::INFO<<"MeasuredEcmsSvc first read the runNo, read the RunParams database"<<runNo<<endreq;
115 double bE=0;
116 bE=records->GetDouble("beam_energy");
117 m_px=records->GetDouble("px");
118 m_py=records->GetDouble("py");
119 m_pz=records->GetDouble("pz");
120 m_ecms=bE*2.00;
121 m_runNoValid=true;
122 }
123}

Referenced by readDB().

◆ readRunParams() [2/2]

void MeasuredEcmsSvc::readRunParams ( int  runNo)
virtual

Implements IMeasuredEcmsSvc.

Friends And Related Function Documentation

◆ CnvFactory< MeasuredEcmsSvc >


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