Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
dune::RunHistoryDUNE Class Reference

#include <RunHistoryDUNE.h>

Inheritance diagram for dune::RunHistoryDUNE:
detinfo::RunHistory

Public Types

enum  DetId_t {
  kUnknownDet = 0, k35t, kProtoDUNE, kFarDet,
  kNearDet, kNDUNEDetectors
}
 

Public Member Functions

 RunHistoryDUNE (int detid, int runnum)
 
 RunHistoryDUNE (RunHistoryDUNE const &)=delete
 
virtual ~RunHistoryDUNE ()
 
virtual bool Update (uint64_t ts=0) override
 
virtual int RunNumber () const override
 
int DetId () const
 
virtual int NSubruns () const override
 
virtual int RunType () const override
 
virtual std::string RunTypeAsString () const override
 
virtual uint64_t TStart () const override
 
virtual uint64_t TStop () const override
 
virtual uint64_t Duration () const override
 
std::vector< std::stringShifters ()
 
std::vector< std::stringComponents ()
 
void SetNSubruns (int nsr)
 
void SetRunType (int rt)
 
void SetTStart (uint64_t t)
 
void SetTStop (uint64_t t)
 
void AddShifter (std::string sh)
 
void SetShifters (std::vector< std::string > sh)
 
std::string CfgLabel () const
 
std::string TStartAsString () const
 
std::string TStopAsString () const
 
void DumpSCData ()
 
void DumpASICSettings ()
 
- Public Member Functions inherited from detinfo::RunHistory
virtual ~RunHistory ()=default
 

Static Public Member Functions

static std::string DetIdToString (int detId)
 
static int DetNameToId (std::string detStr)
 

Protected Attributes

int fRun
 
int fNSubruns
 
int fRunType
 
int fDetId
 
uint64_t fTStart
 
uint64_t fTStop
 
std::vector< std::stringfShifter
 
std::vector< std::stringfComponents
 
std::string fDetName
 
std::string fCfgLabel
 
std::string fTStartStr
 
std::string fTStopStr
 
std::vector< SubRunDUNEfSubrun
 
std::unordered_map< std::string, int > fSCChanMap
 
std::unordered_map< int, std::stringfSCInvChanMap
 
std::unordered_map< int, ASICSettingfASICSettingsMap
 
std::unique_ptr< nutools::dbi::TablefSCDataTable
 
std::unique_ptr< nutools::dbi::TablefASICSettingsTable
 

Private Member Functions

bool LoadSCChanMap ()
 
bool LoadSCData ()
 
bool LoadASICSettings ()
 

Detailed Description

Definition at line 49 of file RunHistoryDUNE.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

dune::RunHistoryDUNE::RunHistoryDUNE ( int  detid,
int  runnum 
)

Definition at line 26 of file RunHistoryDUNE.cxx.

27  {
28  if (detid > 0 && detid < kNDUNEDetectors && run > 0) {
29  fDetId = detid;
30  fRun=run;
31  switch(fDetId) {
32  case(k35t):
33  fDetName = "dune35t";
34  break;
35  case(kProtoDUNE):
36  fDetName = "protoDUNE";
37  break;
38  case(kFarDet):
39  fDetName = "FarDet";
40  break;
41  case(kNearDet):
42  fDetName = "NearDet";
43  break;
44  default:
45  fDetName = "";
46  break;
47  }
48  }
49  else
50  abort();
51 
52  if (!Update(run)) abort();
53  fSCChanMap.clear();
54  fSCInvChanMap.clear();
55  fSCDataTable.reset();
56  }
virtual bool Update(uint64_t ts=0) override
std::unordered_map< int, std::string > fSCInvChanMap
std::unordered_map< std::string, int > fSCChanMap
std::unique_ptr< nutools::dbi::Table > fSCDataTable
unsigned int run
dune::RunHistoryDUNE::RunHistoryDUNE ( RunHistoryDUNE const &  )
delete
dune::RunHistoryDUNE::~RunHistoryDUNE ( )
virtual

Definition at line 59 of file RunHistoryDUNE.cxx.

60  {
61  }

Member Function Documentation

void dune::RunHistoryDUNE::AddShifter ( std::string  sh)
inline

Definition at line 95 of file RunHistoryDUNE.h.

95 { fShifter.push_back(sh); }
std::vector< std::string > fShifter
std::string dune::RunHistoryDUNE::CfgLabel ( ) const
inline

Definition at line 98 of file RunHistoryDUNE.h.

98 { return fCfgLabel; }
std::vector<std::string> dune::RunHistoryDUNE::Components ( )
inline

Definition at line 89 of file RunHistoryDUNE.h.

89 {return fComponents; }
std::vector< std::string > fComponents
int dune::RunHistoryDUNE::DetId ( ) const
inline

Definition at line 80 of file RunHistoryDUNE.h.

80 { return fDetId; }
static std::string dune::RunHistoryDUNE::DetIdToString ( int  detId)
inlinestatic

Definition at line 60 of file RunHistoryDUNE.h.

60  {
61  if (detId == k35t) return std::string("dune35t");
62  else return std::string("UNKNOWN_DET");
63  }
std::string string
Definition: nybbler.cc:12
static int dune::RunHistoryDUNE::DetNameToId ( std::string  detStr)
inlinestatic

Definition at line 65 of file RunHistoryDUNE.h.

65  {
66  if (detStr == "dune35t" || detStr == "DUNE35t" ||
67  detStr == "35t") return k35t;
68  else return kUnknownDet;
69  }
void dune::RunHistoryDUNE::DumpASICSettings ( )

Definition at line 135 of file RunHistoryDUNE.cxx.

136  {
138 
139  for (auto i : fASICSettingsMap) {
140  int chan = i.first%100000;
141  int asic = i.first/100000;
142  std::cout << "ASIC " << asic << ", " << chan << ": " << i.second.gain << " mV/fC, " << i.second.shape << " us, " << i.second.base << " mV" << std::endl;
143  }
144  }
std::unordered_map< int, ASICSetting > fASICSettingsMap
QTextStream & endl(QTextStream &s)
void dune::RunHistoryDUNE::DumpSCData ( )

Definition at line 111 of file RunHistoryDUNE.cxx.

112  {
113  LoadSCData();
114  LoadSCChanMap();
115 
116  fSCDataTable->FillChanRowMap();
117  int rvIdx = fSCDataTable->GetColIndex("rvalue");
118  float rv;
119 
120  std::vector<uint64_t> chanList = fSCDataTable->VldChannels();
121 
122  for (size_t ichan=0; ichan<chanList.size(); ++ichan) {
123  std::vector<nutools::dbi::Row*> vldRow = fSCDataTable->GetVldRows(chanList[ichan]);
124  std::cout << fSCInvChanMap[chanList[ichan]];
125 
126  for (size_t irow=0; irow<vldRow.size(); ++irow) {
127  vldRow[irow]->Col(rvIdx).Get(rv);
128  std::cout << ", (" << rv << "," << vldRow[irow]->VldTime()-fTStart << ")";
129  }
130  std::cout << std::endl;
131  }
132  }
std::unordered_map< int, std::string > fSCInvChanMap
std::unique_ptr< nutools::dbi::Table > fSCDataTable
QTextStream & endl(QTextStream &s)
virtual uint64_t dune::RunHistoryDUNE::Duration ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 86 of file RunHistoryDUNE.h.

86 { return fTStop-fTStart; }
bool dune::RunHistoryDUNE::LoadASICSettings ( )
private

Definition at line 147 of file RunHistoryDUNE.cxx.

148  {
149  if (fASICSettingsTable.get() != nullptr) return true;
150 
152  fASICSettingsTable->SetDetector(fDetName);
153 
154  fASICSettingsTable->SetTableName("asic_settings_by_run");
157 
158  int gainIdx = fASICSettingsTable->AddCol("gain","float");
159  int shapeIdx = fASICSettingsTable->AddCol("shape","float");
160  int baseIdx = fASICSettingsTable->AddCol("base","int");
161 
162  fASICSettingsTable->SetMinTSVld(fRun);
163  fASICSettingsTable->SetMaxTSVld(fRun);
164 
165  fASICSettingsTable->SetVerbosity(100);
166  if (! fASICSettingsTable->Load()) {
167  std::cout << "Error in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << ". Load from database failed." << std::endl;
168  return false;
169  }
170 
171  if (!fASICSettingsTable->NRow()) {
172  std::cout << "WARNING! " << __PRETTY_FUNCTION__ << ", no ASIC settings found for this run." << std::endl;
173  return false;
174  }
175 
176  fASICSettingsMap.clear();
177  float g=0.;
178  float s=0.;
179  int b=0;
180  for (int irow=0; irow<fASICSettingsTable->NRow(); ++irow) {
181  nutools::dbi::Row* r = fASICSettingsTable->GetRow(irow);
182  int chan = r->Channel();
183  r->Col(gainIdx).Get(g);
184  r->Col(shapeIdx).Get(s);
185  r->Col(baseIdx).Get(b);
186  fASICSettingsMap[chan] = ASICSetting(g,s,b);
187  }
188  return true;
189  }
std::unique_ptr< nutools::dbi::Table > fASICSettingsTable
uint64_t Channel()
Definition: Row.h:55
static const double g
Definition: Units.h:145
bool Get(T &val) const
Definition: Column.h:72
std::unordered_map< int, ASICSetting > fASICSettingsMap
static bool * b
Definition: config.cpp:1043
Column & Col(int i)
Definition: Row.h:53
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)
bool dune::RunHistoryDUNE::LoadSCChanMap ( )
private

Definition at line 64 of file RunHistoryDUNE.cxx.

65  {
66  if (!fSCChanMap.empty()) return true;
67 
69 
70  if (fDetName.empty()) {
71  std::cout << __PRETTY_FUNCTION__ << ": Error in line " << __LINE__ << ". Detector name is undefined." << std::endl;
72  return false; //std::abort();
73  }
74 
76  t.SetTableName("daq_sc_chanmap");
79 
80  int chanNameIdx = t.AddCol("chan_name","text");
81 
82  t.SetMinTSVld(1);
83  t.SetMaxTSVld(1);
84 
85  t.SetVerbosity(100);
86  if (! t.Load()) {
87  std::cout << "Error in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << ". Load from database failed." << std::endl;
88  return false; //std::abort();
89  }
90 
91  if (t.NRow() == 0) {
92  std::cout << "Error in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << ". Number of rows in table is 0. This should never be the case!" << std::endl;
93  return false;
94  }
95 
97  std::string chanName;
98  uint64_t chan;
99  for (int i=0; i<t.NRow(); ++i) {
100  row = t.GetRow(i);
101  chan = row->Channel();
102  row->Col(chanNameIdx).Get(chanName);
103  fSCChanMap[chanName] = chan;
104  fSCInvChanMap[chan] = chanName;
105  }
106 
107  return true;
108  }
std::unordered_map< int, std::string > fSCInvChanMap
std::string string
Definition: nybbler.cc:12
void SetMaxTSVld(float t)
Definition: Table.h:272
uint64_t Channel()
Definition: Row.h:55
bool Get(T &val) const
Definition: Column.h:72
std::unordered_map< std::string, int > fSCChanMap
bool SetDetector(std::string det)
Definition: Table.cpp:493
void SetTableName(std::string tname)
Definition: Table.cpp:517
unsigned __int64 uint64_t
Definition: stdint.h:136
int AddCol(std::string cname, std::string ctype)
Definition: Table.cpp:326
nutools::dbi::Row *const GetRow(int i)
Definition: Table.cpp:406
void SetMinTSVld(float t)
Definition: Table.h:271
void SetVerbosity(int i)
Definition: Table.h:100
bool SetTableType(int t)
Definition: Table.cpp:451
Column & Col(int i)
Definition: Row.h:53
QTextStream & endl(QTextStream &s)
void SetDataTypeMask(int mask)
Definition: Table.h:76
bool dune::RunHistoryDUNE::LoadSCData ( )
private

Definition at line 192 of file RunHistoryDUNE.cxx.

193  {
194  if (fSCDataTable.get() != nullptr) return true;
195 
197  fSCDataTable->SetDetector(fDetName);
198 
199  fSCDataTable->SetTableName("daq_slowcontrols");
201  fSCDataTable->SetDataTypeMask(nutools::dbi::kNone);
202 
203  fSCDataTable->AddCol("rvalue","float");
204 
205  fSCDataTable->SetMinTSVld(fTStart);
206  fSCDataTable->SetMaxTSVld(fTStop);
207 
208  fSCDataTable->SetVerbosity(100);
209  if (! fSCDataTable->Load()) {
210  std::cout << "Error in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << ". Load from database failed." << std::endl;
211  return false; //std::abort();
212  }
213 
214  std::cout << "Read in " << fSCDataTable->NRow() << " rows of slow control data for run " << fRun << std::endl;
215 
216  return true;
217  }
std::unique_ptr< nutools::dbi::Table > fSCDataTable
QTextStream & endl(QTextStream &s)
virtual int dune::RunHistoryDUNE::NSubruns ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 81 of file RunHistoryDUNE.h.

81 { return fNSubruns; }
virtual int dune::RunHistoryDUNE::RunNumber ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 79 of file RunHistoryDUNE.h.

79 { return fRun; }
virtual int dune::RunHistoryDUNE::RunType ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 82 of file RunHistoryDUNE.h.

82 { return fRunType; }
std::string dune::RunHistoryDUNE::RunTypeAsString ( ) const
overridevirtual

Implements detinfo::RunHistory.

Definition at line 281 of file RunHistoryDUNE.cxx.

282  {
283  switch(fRunType) {
285  return std::string("Production");
287  return std::string("Commissioning");
288  case(detinfo::kTestRun):
289  return std::string("Test");
290  case(detinfo::kPedestalRun):
291  return std::string("Pedestal");
293  return std::string("Calibration");
295  default:
296  return std::string("Uknown");
297  }
298  }
std::string string
Definition: nybbler.cc:12
void dune::RunHistoryDUNE::SetNSubruns ( int  nsr)
inline

Definition at line 91 of file RunHistoryDUNE.h.

91 { fNSubruns = nsr;}
void dune::RunHistoryDUNE::SetRunType ( int  rt)
inline

Definition at line 92 of file RunHistoryDUNE.h.

92 { fRunType = rt; }
void dune::RunHistoryDUNE::SetShifters ( std::vector< std::string sh)
inline

Definition at line 96 of file RunHistoryDUNE.h.

96 { fShifter = sh; }
std::vector< std::string > fShifter
void dune::RunHistoryDUNE::SetTStart ( uint64_t  t)
inline

Definition at line 93 of file RunHistoryDUNE.h.

void dune::RunHistoryDUNE::SetTStop ( uint64_t  t)
inline

Definition at line 94 of file RunHistoryDUNE.h.

std::vector<std::string> dune::RunHistoryDUNE::Shifters ( )
inline

Definition at line 88 of file RunHistoryDUNE.h.

88 { return fShifter; }
std::vector< std::string > fShifter
virtual uint64_t dune::RunHistoryDUNE::TStart ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 84 of file RunHistoryDUNE.h.

84 { return fTStart; }
std::string dune::RunHistoryDUNE::TStartAsString ( ) const
inline

Definition at line 99 of file RunHistoryDUNE.h.

99 { return fTStartStr; }
virtual uint64_t dune::RunHistoryDUNE::TStop ( ) const
inlineoverridevirtual

Implements detinfo::RunHistory.

Definition at line 85 of file RunHistoryDUNE.h.

85 { return fTStop; }
std::string dune::RunHistoryDUNE::TStopAsString ( ) const
inline

Definition at line 100 of file RunHistoryDUNE.h.

100 { return fTStopStr; }
bool dune::RunHistoryDUNE::Update ( uint64_t  ts = 0)
overridevirtual

Implements detinfo::RunHistory.

Definition at line 220 of file RunHistoryDUNE.cxx.

221  {
222  if (run == 0) return false;
223 
224  fSCDataTable.reset();
225  fASICSettingsTable.reset();
226 
227  std::string tableName = "run_summary";
229 
231  t.SetTableName(tableName);
233 
234  int runIdx = t.AddCol("run", "integer");
235  int cfgLabelIdx = t.AddCol("configuration_label", "integer");
236  int runTypeIdx = t.AddCol("run_type", "text");
237  int compListIdx = t.AddCol("component_list", "text");
238  int startIdx = t.AddCol("start", "timestamp");
239  int stopIdx = t.AddCol("stop", "timestamp");
240 
241  t.SetValidityRange("run",run);
242 
243  // t.SetVerbosity(100);
244  t.SetTimeQueries(false);
245  t.SetTimeParsing(false);
246  t.Load();
247 
248  if (t.NRow() != 1)
249  abort();
250 
251  std::string runTypeStr, compList;
252  int runNum=0;
253 
254  nutools::dbi::Row* row = t.GetRow(0);
255  row->Col(runIdx).Get(runNum);
256  row->Col(cfgLabelIdx).Get(fCfgLabel);
257  row->Col(compListIdx).Get(compList);
258  row->Col(runTypeIdx).Get(runTypeStr);
259  row->Col(startIdx).Get(fTStartStr);
260  row->Col(stopIdx).Get(fTStopStr);
261 
262  if (runNum != int(run)) abort();
263 
264  boost::tokenizer< boost::escaped_list_separator<char> > tok(compList);
265  fComponents.assign(tok.begin(),tok.end());
266 
267  fTStart = fTStop = 0;
268  time_t tval;
270  fTStart = tval;
271  if (fTStopStr != "" && fTStopStr != "None") {
273  fTStop = tval;
274  }
275 
276  return true;
277 
278  }
void SetTimeQueries(bool f)
Definition: Table.h:305
std::string string
Definition: nybbler.cc:12
std::unique_ptr< nutools::dbi::Table > fASICSettingsTable
bool Get(T &val) const
Definition: Column.h:72
void SetTimeParsing(bool f)
Definition: Table.h:306
bool SetValidityRange(std::string cname, T start, T end)
Definition: Table.h:218
std::unique_ptr< nutools::dbi::Table > fSCDataTable
bool SetDetector(std::string det)
Definition: Table.cpp:493
void SetTableName(std::string tname)
Definition: Table.cpp:517
static bool TimeAsStringToTime_t(std::string ts, time_t &t)
Definition: Util.cpp:81
int AddCol(std::string cname, std::string ctype)
Definition: Table.cpp:326
nutools::dbi::Row *const GetRow(int i)
Definition: Table.cpp:406
std::vector< std::string > fComponents
bool SetTableType(int t)
Definition: Table.cpp:451
Column & Col(int i)
Definition: Row.h:53
unsigned int run
std::string tableName

Member Data Documentation

std::unordered_map<int,ASICSetting> dune::RunHistoryDUNE::fASICSettingsMap
protected

Definition at line 130 of file RunHistoryDUNE.h.

std::unique_ptr<nutools::dbi::Table> dune::RunHistoryDUNE::fASICSettingsTable
protected

Definition at line 133 of file RunHistoryDUNE.h.

std::string dune::RunHistoryDUNE::fCfgLabel
protected

Definition at line 123 of file RunHistoryDUNE.h.

std::vector<std::string> dune::RunHistoryDUNE::fComponents
protected

Definition at line 121 of file RunHistoryDUNE.h.

int dune::RunHistoryDUNE::fDetId
protected

Definition at line 115 of file RunHistoryDUNE.h.

std::string dune::RunHistoryDUNE::fDetName
protected

Definition at line 122 of file RunHistoryDUNE.h.

int dune::RunHistoryDUNE::fNSubruns
protected

Definition at line 113 of file RunHistoryDUNE.h.

int dune::RunHistoryDUNE::fRun
protected

Definition at line 112 of file RunHistoryDUNE.h.

int dune::RunHistoryDUNE::fRunType
protected

Definition at line 114 of file RunHistoryDUNE.h.

std::unordered_map<std::string,int> dune::RunHistoryDUNE::fSCChanMap
protected

Definition at line 128 of file RunHistoryDUNE.h.

std::unique_ptr<nutools::dbi::Table> dune::RunHistoryDUNE::fSCDataTable
protected

Definition at line 132 of file RunHistoryDUNE.h.

std::unordered_map<int,std::string> dune::RunHistoryDUNE::fSCInvChanMap
protected

Definition at line 129 of file RunHistoryDUNE.h.

std::vector<std::string> dune::RunHistoryDUNE::fShifter
protected

Definition at line 120 of file RunHistoryDUNE.h.

std::vector<SubRunDUNE> dune::RunHistoryDUNE::fSubrun
protected

Definition at line 127 of file RunHistoryDUNE.h.

uint64_t dune::RunHistoryDUNE::fTStart
protected

Definition at line 117 of file RunHistoryDUNE.h.

std::string dune::RunHistoryDUNE::fTStartStr
protected

Definition at line 124 of file RunHistoryDUNE.h.

uint64_t dune::RunHistoryDUNE::fTStop
protected

Definition at line 118 of file RunHistoryDUNE.h.

std::string dune::RunHistoryDUNE::fTStopStr
protected

Definition at line 125 of file RunHistoryDUNE.h.


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