RunInfoDUNE.cc
Go to the documentation of this file.
2 
3 #include "nuevdb/IFDatabase/Table.h"
4 #include <getopt.h>
5 #include <iostream>
6 
7 int gRun = -1;
10 bool gDumpSCData = false;
11 bool gDumpASICSettings = false;
12 bool gPrintComponents = false;
13 
14 //------------------------------------------------------------
15 
16 void PrintUsage()
17 {
18  std::cout << "Usage: RunInfo -d|--detector [detectorName, eg dune35t] -r|--run [run number] [options]" << std::endl;
19  std::cout << "Options:" << std::endl;
20  std::cout << "-S (--dumpSCData): dump slow controls data from database" << std::endl;
21  std::cout << "-A (--dumpASICSettings): dump ASIC settings from database" << std::endl;
22  std::cout << "-C (--components): print DAQ components" << std::endl;
23 }
24 
25 //------------------------------------------------------------
26 
27 bool ParseCLArgs(int argc, char* argv[])
28 {
29 
30  struct option long_options[] = {
31  {"help", 0, 0, 'h'},
32  {"run", 0, 0, 'r'},
33  {"detector", 0, 0, 'd'},
34  {"dumpSCData", 0, 0, 'S'},
35  {"dumpASICSettings", 0, 0, 'A'},
36  {"components", 0, 0, 'C'},
37  {0,0,0,0}
38  };
39 
40  while (1) {
41  int optindx;
42 
43  int c = getopt_long(argc,argv,"r:d:hSCA",long_options,&optindx);
44 
45  if (c==-1) break;
46 
47  switch(c) {
48  case 'r':
49  {
50  int run = atoi(optarg);
51  if (run < 0) {
52  std::cout << "Invalid run number." << std::endl;
53  exit(0);
54  }
55  gRun = run;
56  break;
57  }
58  case 'd':
59  {
60  gDetStr = optarg;
61  break;
62  }
63  case 'h':
64  {
65  PrintUsage();
66  exit(0);
67  break;
68  }
69  case 'S':
70  {
71  gDumpSCData = true;
72  break;
73  }
74  case 'A':
75  {
76  gDumpASICSettings = true;
77  break;
78  }
79  case 'C':
80  {
81  gPrintComponents = true;
82  break;
83  }
84  default:
85  break;
86  }
87  }
88 
91  return false;
92 
93  return true;
94 }
95 
96 //------------------------------------------------------------
97 
98 int main(int argc, char **argv)
99 {
100  if (!ParseCLArgs(argc,argv)) {
101  PrintUsage();
102  return 1;
103  }
104 
106 
107  std::cout << "Run " << rh->RunNumber() << ":" << std::endl;
108  std::cout << "Cfg: " << rh->CfgLabel() << std::endl;
109 
110  std::cout << "RunType: " << rh->RunTypeAsString() << std::endl;
111  std::cout << "Start time: " << rh->TStartAsString() << std::endl;
112  std::cout << "Stop time: " << rh->TStopAsString() << std::endl;
113  std::cout << "Duration: ";
114  int duration = rh->Duration();
115  int hours = duration/3600;
116  int minutes = (duration-3600*hours)/60;
117  int seconds = (duration-3600*hours-60*minutes);
118  std::cout << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << std::endl;
119 
120  if (gPrintComponents) {
121  std::cout << "Components: ";
122  std::vector<std::string> comp = rh->Components();
123  std::cout << comp[0];
124  for (size_t i=1; i<comp.size(); ++i)
125  std::cout << ", " << comp[i];
126  std::cout << std::endl;
127  }
128 
129  if (gDumpSCData) {
130  rh->DumpSCData();
131  }
132 
133  if (gDumpASICSettings) {
134  rh->DumpASICSettings();
135  }
136 
137  delete rh;
138 
139  return 0;
140 }
141 
std::string TStopAsString() const
std::string string
Definition: nybbler.cc:12
virtual uint64_t Duration() const override
static int DetNameToId(std::string detStr)
std::string TStartAsString() const
comp
Definition: dbjson.py:31
bool gDumpASICSettings
Definition: RunInfoDUNE.cc:11
int main(int argc, char **argv)
Definition: RunInfoDUNE.cc:98
int gRun
Definition: RunInfoDUNE.cc:7
second seconds
Alias for common language habits.
Definition: spacetime.h:83
int gDetId
Definition: RunInfoDUNE.cc:9
virtual int RunNumber() const override
std::vector< std::string > Components()
virtual std::string RunTypeAsString() const override
std::string CfgLabel() const
bool gDumpSCData
Definition: RunInfoDUNE.cc:10
bool gPrintComponents
Definition: RunInfoDUNE.cc:12
bool ParseCLArgs(int argc, char *argv[])
Definition: RunInfoDUNE.cc:27
QTextStream & endl(QTextStream &s)
std::string gDetStr
Definition: RunInfoDUNE.cc:8
unsigned int run
void PrintUsage()
Definition: RunInfoDUNE.cc:16