QwAnalysis
QwParityDB.h
Go to the documentation of this file.
1 /*!
2  * \file QwDatabase.h
3  * \brief A class for handling connections to the Qweak database.
4  *
5  * \author Damon Spayde
6  * \date 2010-01-07
7  */
8 
9 #ifndef QWPARITYDB_HH
10 #define QWPARITYDB_HH
11 
12 // System headers
13 #include <map>
14 #include <vector>
15 #include <string>
16 #include <typeinfo>
17 
18 // Third Party Headers
19 #include <mysql++.h>
20 
21 // ROOT headers
22 #include "TString.h"
23 
24 // Qweak headers
25 #include "QwTypes.h"
26 #include "QwLog.h"
27 #include "QwColor.h"
28 #include "QwOptions.h"
29 #include "QwDatabase.h"
30 #include "QwSubsystemArrayParity.h"
31 
32 //#include "QwParitySSQLS.h"
33 #include "QwDBInterface.h"
34 
35 // Forward declarations
36 class QwEventBuffer;
37 
38 /**
39  * \class QwDatabase
40  * \ingroup QwAnalysis
41  * \brief A database interface class
42  *
43  * This class provides the connection to the Qweak database to other objects
44  * in the Qweak analyzer. A static global object gQwDatabase is used to
45  * provide these services.
46  *
47  */
48 
49 class QwParityDB: public QwDatabase {
50  public:
51 
52  QwParityDB(); //!< Simple constructor
53  QwParityDB(QwOptions &options); //!< Constructor with QwOptions object
54 
55  virtual ~QwParityDB(); //!< Destructor
56 
57  void SetupOneRun(QwEventBuffer& qwevt); //<! Initialize run ID, runlet ID, and analysis ID using data from CODA event buffer
59 
60  UInt_t GetMonitorID(const string& name, Bool_t zero_id_is_error=kTRUE); //<! Get monitor_id for beam monitor name
61  UInt_t GetMainDetectorID(const string& name, Bool_t zero_id_is_error=kTRUE); //<! Get main_detector_id for main detector name
62  UInt_t GetLumiDetectorID(const string& name, Bool_t zero_id_is_error=kTRUE); //<! Get lumi_detector_id for lumi detector name
63  const string GetMeasurementID(const Int_t index);
64  UInt_t GetSlowControlDetectorID(const string& name); //<! Get slow_controls_data_id for epics name
65  UInt_t GetErrorCodeID(const string& name); //<! Get error_code_id for error code name
66 
67  UInt_t GetRunNumber() {return fRunNumber;} //<! Run number getter
68  UInt_t GetSegmentNumber() {return fSegmentNumber;} //<! CODA File segment number getter
69  UInt_t GetRunID() {return fRunID;} //<! Run ID getter
70  UInt_t GetRunletID() {return fRunletID;} //<! Runlet ID getter
71  UInt_t GetAnalysisID() {return fAnalysisID;}; //<! Get analysis ID
72 
73 
74  UInt_t GetRunID(QwEventBuffer& qwevt); //<! Get run ID using data from CODA event buffer
75  UInt_t GetRunletID(QwEventBuffer& qwevt); //<! Get runlet ID using data from CODA event buffer
76  UInt_t GetAnalysisID(QwEventBuffer& qwevt); //<! Get analysis ID using data from CODA event buffer
77  Bool_t SetRunNumber(const UInt_t runnum); //<! Run number setter
78  Bool_t SetSegmentNumber(const UInt_t segment); //<! CODA file segment number setter
79  static void DefineAdditionalOptions(QwOptions& options); //!< Defines QwParityDB-specific class options for QwOptions
80  void ProcessAdditionalOptions(QwOptions &options); //!< Processes the options contained in the QwOptions object.
81 
82  private:
83 
84  UInt_t SetRunID(QwEventBuffer& qwevt); //<! Set fRunID using data from CODA event buffer
85  UInt_t SetRunletID(QwEventBuffer& qwevt); //<! Set fRunletID using data from CODA event buffer
86  UInt_t SetAnalysisID(QwEventBuffer& qwevt); //<! Set fAnalysisID using data from CODA event buffer
87  void StoreMonitorIDs(); //<! Retrieve monitor IDs from database and populate fMonitorIDs
88  void StoreMainDetectorIDs(); //<! Retrieve main detector IDs from database and populate fMainDetectorIDs
89  void StoreLumiDetectorIDs(); //<! Retrieve LUMI monitor IDs from database and populate fLumiDetectorIDs
90  void StoreMeasurementIDs();
91  void StoreSlowControlDetectorIDs(); //<! Retrieve slow controls data IDs from database and populate fSlow_Controls_DataIDs
92  void StoreErrorCodeIDs(); //<! Retrieve error code IDs from database and populate fErrorCodeIDs
93 
94  UInt_t fRunNumber; //!< Run number of current run
95  Int_t fSegmentNumber; //!< CODA file segment number of current run
96  UInt_t fRunID; //!< run_id of current run
97  UInt_t fRunletID; //!< runlet_id of current run
98  UInt_t fAnalysisID; //!< analysis_id of current analysis pass
99  bool fDisableAnalysisCheck; //!< Flag to disable pre-existing analysis_id check
100 
101  static std::map<string, unsigned int> fMonitorIDs; //!< Associative array of beam monitor IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.
102  static std::map<string, unsigned int> fMainDetectorIDs; //!< Associative array of main detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.
103  static std::map<string, unsigned int> fLumiDetectorIDs; //!< Associative array of LUMI detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.
104  static std::map<string, unsigned int> fSlowControlDetectorIDs; //!< Associative array of slow controls data IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.
105  static std::map<string, unsigned char> fErrorCodeIDs; //!< Associative array of error code IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.
106  static std::vector<string> fMeasurementIDs;
107 
108  friend class StoreMonitorID;
109  friend class StoreMainDetectorID;
110  friend class StoreLumiDetectorID;
111  friend class StoreMeasurementID;
113  friend class StoreErrorCodeID;
114 };
115 
116 
117 #endif
UInt_t GetRunletID()
Definition: QwParityDB.h:70
UInt_t GetErrorCodeID(const string &name)
Definition: QwParityDB.cc:725
QwParityDB()
Simple constructor.
Definition: QwParityDB.cc:90
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
UInt_t GetMonitorID(const string &name, Bool_t zero_id_is_error=kTRUE)
Definition: QwParityDB.cc:618
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
void StoreMonitorIDs()
Definition: QwParityDB.cc:638
void StoreMainDetectorIDs()
Definition: QwParityDB.cc:682
UInt_t SetRunID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:200
UInt_t GetMainDetectorID(const string &name, Bool_t zero_id_is_error=kTRUE)
Definition: QwParityDB.cc:661
const string GetMeasurementID(const Int_t index)
Definition: QwParityDB.cc:833
bool fDisableAnalysisCheck
Flag to disable pre-existing analysis_id check.
Definition: QwParityDB.h:99
static std::vector< string > fMeasurementIDs
Definition: QwParityDB.h:106
An options class.
Definition: QwOptions.h:133
Bool_t SetRunNumber(const UInt_t runnum)
Definition: QwParityDB.cc:158
UInt_t SetAnalysisID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:429
A database interface class.
Definition: QwDatabase.h:45
A class for handling connections to the Qweak database.
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
UInt_t GetLumiDetectorID(const string &name, Bool_t zero_id_is_error=kTRUE)
Definition: QwParityDB.cc:790
static std::map< string, unsigned int > fSlowControlDetectorIDs
Associative array of slow controls data IDs. This declaration will be a problem if QwDatabase is used...
Definition: QwParityDB.h:104
UInt_t GetAnalysisID()
Definition: QwParityDB.h:71
static std::map< string, unsigned int > fLumiDetectorIDs
Associative array of LUMI detector IDs. This declaration will be a problem if QwDatabase is used to c...
Definition: QwParityDB.h:103
UInt_t SetRunletID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:313
Virtual base class for the parity subsystems.
UInt_t GetRunID()
Definition: QwParityDB.h:69
A logfile class, based on an identical class in the Hermes analyzer.
static void DefineAdditionalOptions(QwOptions &options)
Defines QwParityDB-specific class options for QwOptions.
Definition: QwParityDB.cc:877
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
void StoreLumiDetectorIDs()
Definition: QwParityDB.cc:808
void StoreSlowControlDetectorIDs()
Definition: QwParityDB.cc:744
void StoreErrorCodeIDs()
Definition: QwParityDB.cc:767
void FillParameterFiles(QwSubsystemArrayParity &subsys)
Definition: QwParityDB.cc:563
void SetupOneRun(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:136
void StoreMeasurementIDs()
Definition: QwParityDB.cc:848
UInt_t GetRunNumber()
Definition: QwParityDB.h:67
An options class which parses command line, config file and environment.
virtual ~QwParityDB()
Destructor.
Definition: QwParityDB.cc:126
UInt_t GetSegmentNumber()
Definition: QwParityDB.h:68
static std::map< string, unsigned char > fErrorCodeIDs
Associative array of error code IDs. This declaration will be a problem if QwDatabase is used to conn...
Definition: QwParityDB.h:105
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
static std::map< string, unsigned int > fMonitorIDs
Associative array of beam monitor IDs. This declaration will be a problem if QwDatabase is used to co...
Definition: QwParityDB.h:101
UInt_t GetSlowControlDetectorID(const string &name)
Definition: QwParityDB.cc:706
void ProcessAdditionalOptions(QwOptions &options)
Processes the options contained in the QwOptions object.
Definition: QwParityDB.cc:891
Bool_t SetSegmentNumber(const UInt_t segment)
static std::map< string, unsigned int > fMainDetectorIDs
Associative array of main detector IDs. This declaration will be a problem if QwDatabase is used to c...
Definition: QwParityDB.h:102