BOSS 8.0.0
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
14# include "MeasuredEcmsSvc/IMeasuredEcmsSvc.h"
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 */
24// class MeasuredEcmsSvc : public Service, virtual public IMeasuredEcmsSvc, virtual public
25// IIncidentListener {
26class MeasuredEcmsSvc : public extends<Service, IMeasuredEcmsSvc>,
27 virtual public IIncidentListener {
28 friend class CnvFactory<MeasuredEcmsSvc>;
29
30public:
31 /** Constructor */
32 MeasuredEcmsSvc( const std::string& name, ISvcLocator* svcLoc );
33
34 /** Destructor */
35 virtual ~MeasuredEcmsSvc();
36
37 /** Query interface */
38 // virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
39
40 /** Initialize */
41 virtual StatusCode initialize();
42
43 /** Finalize */
44 virtual StatusCode finalize();
45
46 /** Handle.
47 * Process after initialization
48 */
49 void handle( const Incident& );
50
51 /** Return true or false for runNo */
52 bool isRunNoValid() { return m_isRunNoValid; }
53
54 /** Return Ecms ( Ecms = beam_energy * 2 ) */
55 double getEcms();
56
57 /** Return beam energy */
58 double getBeamEnergy() { return (double)getEcms() / 2.00; }
59
60 /** Return error for Ecms */
61 double getEcmsError() {
62 return ( m_rowNo1 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "Ecms_err" ) : 0.;
63 }
64
65 /** Return average Ecms */
66 double getAverageEcms() {
67 return ( m_rowNo1 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "Ave_Ecms" ) : 0.;
68 }
69
70 /** Return average Ecms error */
72 return ( m_rowNo1 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "Ave_Ecms_err" )
73 : 0.;
74 }
75
76 /** Return sample name */
77 double getSampleName() {
78 return ( m_rowNo1 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "sample" ) : 0.;
79 }
80
81 /** Return x momentum */
82 double getPx() {
83 return ( m_rowNo2 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "px" ) : 0.011;
84 }
85
86 /** Return y momentum */
87 double getPy() {
88 return ( m_rowNo2 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "py" ) : 0.;
89 }
90
91 /** Return z momentum */
92 double getPz() {
93 return ( m_rowNo2 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "pz" ) : 0.;
94 }
95
96 /** Return beam energy error */
98 return ( m_rowNo2 != 0 ) ? (double)m_dbRecordVector[m_sele]->GetDouble( "beam_energy_err" )
99 : 0.;
100 }
101
102 /** Return Ecms depend on runNo only.
103 * Here RunNo. can be set independ on event.
104 */
105 double getEcms( int runNo );
106
107 /** Return beam energy depend on runNo only.
108 * Here RunNo. can be set independ on event.
109 */
110 double getBeamEnergy( int runNo ) { return (double)getEcms( runNo ) / 2.00; }
111
112 /** Return the string depend on the parameters
113 * @param runNo runNo. input
114 * (independent)
115 * @param tab table name in database,
116 * such as MeasuredEcms2, RunParams
117 * @param col the variable name which
118 * you want to read, such as Ecms
119 * @param min_col the down limits variable name,
120 * such as Run_From
121 * @param max_col the upper limits variable name, such as Run_To
122 */
123 std::string getRecord( int runNo, char* tab, char* col, char* min_col, char* max_col );
124
128 std::map<int, int> m_mapBeamE;
130
131protected:
132 /** Read database table */
133 void readDBTable( int runNo );
134
135 /** trigger based on runNo
136 * @option 1 MeasuredEcms2 table for XYZ (Charmonium data)
137 * @option 2 RunParams table for 3773, 4180 (Charm data)
138 */
139 int triggerDBTable( int runNo );
140
141 void readDBTable( int runFrom, int runTo );
142
143private:
144 IDataProviderSvc* m_eventSvc;
145 IDatabaseSvc* m_dbSvc;
146 DatabaseRecordVector m_dbRecordVector;
147
148 int m_runNo; /**< runNo. read from event */
149 int m_tableOption; /**< triggerDBTable for (1) MeasuredEcms2 and (2) RunParams */
150 bool m_isRunNoValid; /**< estimate whether the runNo valid */
151 int m_rowNo1; /**< read MeasuredEcms2 */
152 int m_rowNo2; /**< read RunParams */
153
154 int m_runflag;
155};
156
157#endif
int runNo
Definition DQA_TO_DB.cxx:13
double getAverageEcmsError()
double getBeamEnergyError()
double getAverageEcms()
std::map< int, int > m_mapBeamE
virtual ~MeasuredEcmsSvc()
void handle(const Incident &)
double getBeamEnergy(int runNo)
int triggerDBTable(int runNo)
virtual StatusCode initialize()
MeasuredEcmsSvc(const std::string &name, ISvcLocator *svcLoc)
virtual StatusCode finalize()
std::string getRecord(int runNo, char *tab, char *col, char *min_col, char *max_col)
void readDBTable(int runNo)