BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
MeasuredEcmsSvc.h
Go to the documentation of this file.
1/***********************************************************************
2 * BES III Software *
3 * Copyright(C) - BES III Collaboration *
4 * *
5 * Author: The BESIII Collaboration *
6 * Contributor: Lianjin Wu *
7 * *
8 ***********************************************************************/
9
10#pragma once
11#ifndef Utilities_MeasuredEcmsSvc_H
12#define Utilities_MeasuredEcmsSvc_H
13
15
16class IDatabaseSvc;
17
18template <class TYPE> class CnvFactory;
19
20/** Class to read the data information from database,
21 * such as ECMS, ECMS Error ... ( beam_energy = ECMS / 2.0).
22 * Access to almost all the XYZ, 3773, and 4180 data.
23 */
24class MeasuredEcmsSvc : public Service, virtual public IMeasuredEcmsSvc, virtual public IIncidentListener {
25
26 friend class CnvFactory<MeasuredEcmsSvc>;
27
28 public:
29
30 /** Constructor */
31 MeasuredEcmsSvc(const std::string& name, ISvcLocator* svcLoc);
32
33 /** Destructor */
34 virtual ~MeasuredEcmsSvc();
35
36 /** Query interface */
37 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
38
39 /** Initialize */
40 virtual StatusCode initialize();
41
42 /** Finalize */
43 virtual StatusCode finalize();
44
45 /** Handle.
46 * Process after initialization
47 */
48 void handle(const Incident&);
49
50 /** Return true or false for runNo */
51 bool isRunNoValid() { return m_isRunNoValid; }
52
53 /** Return Ecms ( Ecms = beam_energy * 2 ) */
54 double getEcms();
55
56 /** Return beam energy */
57 double getBeamEnergy() { return (double)getEcms() / 2.00; }
58
59 /** Return error for Ecms */
60 double getEcmsError() { return (m_rowNo1 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("Ecms_err") : 0.; }
61
62 /** Return average Ecms */
63 double getAverageEcms() { return (m_rowNo1 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("Ave_Ecms") : 0.; }
64
65 /** Return average Ecms error */
66 double getAverageEcmsError() { return (m_rowNo1 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("Ave_Ecms_err") : 0.; }
67
68 /** Return sample name */
69 double getSampleName() { return (m_rowNo1 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("sample") : 0.; }
70
71 /** Return x momentum */
72 double getPx() { return (m_rowNo2 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("px") : 0.011; }
73
74 /** Return y momentum */
75 double getPy() { return (m_rowNo2 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("py") : 0.; }
76
77 /** Return z momentum */
78 double getPz() { return (m_rowNo2 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("pz") : 0.; }
79
80 /** Return beam energy error */
81 double getBeamEnergyError() { return (m_rowNo2 != 0) ? (double)m_dbRecordVector[m_sele]->GetDouble("beam_energy_err") : 0.; }
82
83 /** Return Ecms depend on runNo only.
84 * Here RunNo. can be set independ on event.
85 */
86 double getEcms(int runNo);
87
88 /** Return beam energy depend on runNo only.
89 * Here RunNo. can be set independ on event.
90 */
91 double getBeamEnergy(int runNo) { return (double)getEcms(runNo) / 2.00; }
92
93
94 /** Return the string depend on the parameters
95 * @param runNo runNo. input (independent)
96 * @param tab table name in database, such as MeasuredEcms2, RunParams
97 * @param col the variable name which you want to read, such as Ecms
98 * @param min_col the down limits variable name, such as Run_From
99 * @param max_col the upper limits variable name, such as Run_To
100 */
101 std::string getRecord(int runNo, char *tab, char *col, char *min_col, char *max_col);
102
106 std::map<int,int> m_mapBeamE;
108
109 protected:
110
111 /** Read database table */
112 void readDBTable(int runNo);
113
114 /** trigger based on runNo
115 * @option 1 MeasuredEcms2 table for XYZ (Charmonium data)
116 * @option 2 RunParams table for 3773, 4180 (Charm data)
117 */
118 int triggerDBTable(int runNo);
119
120 void readDBTable(int runFrom, int runTo);
121
122
123 private:
124
125 IDataProviderSvc *m_eventSvc;
126 IDatabaseSvc *m_dbSvc;
127 DatabaseRecordVector m_dbRecordVector;
128
129 int m_runNo; /**< runNo. read from event */
130 int m_tableOption; /**< triggerDBTable for (1) MeasuredEcms2 and (2) RunParams */
131 bool m_isRunNoValid; /**< estimate whether the runNo valid */
132 int m_rowNo1; /**< read MeasuredEcms2 */
133 int m_rowNo2; /**< read RunParams */
134
135 int m_runflag;
136};
137
138#endif
int runNo
Definition: DQA_TO_DB.cxx:12
double getAverageEcmsError()
double getBeamEnergyError()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
double getSampleName()
double getAverageEcms()
std::map< int, int > m_mapBeamE
double getEcmsError()
virtual ~MeasuredEcmsSvc()
void handle(const Incident &)
double getBeamEnergy(int runNo)
int triggerDBTable(int runNo)
virtual StatusCode initialize()
virtual StatusCode finalize()
std::string getRecord(int runNo, char *tab, char *col, char *min_col, char *max_col)
void readDBTable(int runNo)
double getBeamEnergy()