RunHistory.h
Go to the documentation of this file.
1 #ifndef _DBUTILS_RUNHISTORY_H
2 #define _DBUTILS_RUNHISTORY_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <ctime>
8 #include <stdint.h> /* uint64_t */
9 
10 #include <NovaDatabase/Util.h>
11 #include <NovaDatabase/Table.h>
12 #include <DatabaseUtils/DAQConfig/PixelEnableMasks.h>
13 #include <DatabaseUtils/DAQConfig/PixelThresholds.h>
14 
15 namespace db = nova::database;
16 namespace daqcfg = dbutils::daqconfig;
17 
18 namespace dbutils {
19 
20 /**
21  * Utilities for accessing DB via kerberos
22  *
23  * @author Jonathan Paley
24  * @version $Revision: 1.9.14.1 $ $Date: 2019/09/27 00:07:04 $
25  */
26 
27  class RunHistory {
28 
29  public:
30 
31  class FEB {
32  public:
33  FEB() {};
34  ~FEB() {};
35 
38  int loc;
40  int pixelMask;
41  int pixelThresh[32];
42  int apdV;
43  bool isEnabled;
44  bool isCooled;
46  float temperature;
47  };
48 
49  class DCM {
50  public:
51  DCM() {};
52  ~DCM() {};
53 
56  int64_t febMask;
57  std::map<int,FEB> feb;
58  };
59 
60  class BNEVB {
61  public:
62  BNEVB() {};
63  ~BNEVB() {};
64 
67  };
68 
70  RunHistory(int run, int detid);
71  ~RunHistory();
72 
73  void Load();
74  void SetDBInfo(std::string dbname="", std::string dbhost="",
76  void SetRunNumber(int run) {_runNumber = run; }
78 
79  void Dump();
80 
81  int RunNumber() const { return _runNumber; }
82  int NSubruns() const { return _nsubrun; }
83  std::string Detector() const { return _detector; }
84 
85  time_t TStart() const;
86  time_t TStop() const;
87  std::string TStartAsString() const { return _tStart;}
88  std::string TStopAsString() const { return _tEnd;}
89 
90  int Duration() const { return TStop()-TStart(); } ///< in units of seconds
91  int NTriggers() const { return _nTotTrig; }
92 
93  int NDCMs() const { return _dcmList.size(); }
94  int NBNEVBs() const { return _bnevbList.size(); }
95  int NActiveChannels() const { return _nActiveChannels; }
96  int NTotalChannels() const { return _nTotalChannels; }
97  int NTotalFEBs() const { return _nTotalFEBs; }
98  int NMaskedOffFEBs() const { return _nMaskedOffFEBs; }
99  const DCM GetDCM(int idcm) { return _dcmList[idcm]; }
100 
101  int NDCMInstalled() const { return _nInstalledDCMs; }
102  int NFEBInstalled() const { return _nInstalledFEBs; }
103  int NAPDInstalled() const { return _nInstalledAPDs; }
104 
105  bool FEBEnableMask(const std::string& dcmName, int64_t& febMask);
106  bool PixelEnableMask(const std::string& dcmName,
107  const int& febId, int32_t& pixelMask);
108  bool PixelThresholdsForFEB(const std::string& dcmName,
109  const int& febId,
110  std::vector<int16_t>& thresholdList);
111 
112  private:
113 
115  int _nsubrun;
124 
128  std::vector<int> _nEvtTrig;
129  std::vector<DCM> _dcmList;
130  std::vector<BNEVB> _bnevbList;
131 
132  int64_t _gCfgId;
133 
134  std::unique_ptr<db::Table> runsTable;
135  std::unique_ptr<db::Table> resTable;
136  std::unique_ptr<db::Table> hwposTable;
137  std::unique_ptr<daqcfg::PixelEnableMasks> _pixMaskPtr;
138  std::unique_ptr<daqcfg::PixelThresholds> _pixThreshPtr;
139 
140  }; // end of class Krb5
141 } // end of namespace dbutils
142 
143 #endif
std::string TStartAsString() const
Definition: RunHistory.h:87
std::string TStopAsString() const
Definition: RunHistory.h:88
std::map< int, FEB > feb
Definition: RunHistory.h:57
std::unique_ptr< db::Table > hwposTable
Definition: RunHistory.h:136
void SetDetector(std::string det)
std::string _tStart
Definition: RunHistory.h:126
std::unique_ptr< daqcfg::PixelThresholds > _pixThreshPtr
Definition: RunHistory.h:138
int NTotalChannels() const
Definition: RunHistory.h:96
std::unique_ptr< db::Table > resTable
Definition: RunHistory.h:135
time_t TStop() const
Definition: RunHistory.cpp:252
int NSubruns() const
Definition: RunHistory.h:82
const DCM GetDCM(int idcm)
Definition: RunHistory.h:99
int NDCMs() const
Definition: RunHistory.h:93
time_t TStart() const
Definition: RunHistory.cpp:242
int RunNumber() const
Definition: RunHistory.h:81
int NDCMInstalled() const
Definition: RunHistory.h:101
int NActiveChannels() const
Definition: RunHistory.h:95
int Duration() const
in units of seconds
Definition: RunHistory.h:90
std::vector< BNEVB > _bnevbList
Definition: RunHistory.h:130
int NMaskedOffFEBs() const
Definition: RunHistory.h:98
int NTriggers() const
Definition: RunHistory.h:91
std::unique_ptr< db::Table > runsTable
Definition: RunHistory.h:134
void SetDBInfo(std::string dbname="", std::string dbhost="", std::string user="", std::string port="")
Definition: RunHistory.cpp:83
void SetRunNumber(int run)
Definition: RunHistory.h:76
Definition: run.py:1
std::vector< DCM > _dcmList
Definition: RunHistory.h:129
std::string _tEnd
Definition: RunHistory.h:127
RunHistory(int run, std::string det)
Definition: RunHistory.cpp:14
std::unique_ptr< daqcfg::PixelEnableMasks > _pixMaskPtr
Definition: RunHistory.h:137
int NAPDInstalled() const
Definition: RunHistory.h:103
int NFEBInstalled() const
Definition: RunHistory.h:102
bool PixelEnableMask(const std::string &dcmName, const int &febId, int32_t &pixelMask)
Definition: RunHistory.cpp:301
std::vector< int > _nEvtTrig
Definition: RunHistory.h:128
int NTotalFEBs() const
Definition: RunHistory.h:97
int port
Definition: client_test.C:9
bool PixelThresholdsForFEB(const std::string &dcmName, const int &febId, std::vector< int16_t > &thresholdList)
Definition: RunHistory.cpp:317
bool FEBEnableMask(const std::string &dcmName, int64_t &febMask)
Definition: RunHistory.cpp:285
std::string _detector
Definition: RunHistory.h:125
std::string Detector() const
Definition: RunHistory.h:83
enum BeamMode string
int NBNEVBs() const
Definition: RunHistory.h:94