getLinConstsProtoDUNE.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 
11 //------------------------------------------------------------
12 
13 void PrintUsage()
14 {
15  std::cout << "Usage: getLinConstsProtoDUNE -r|--run [run number] -d|--datatype [data|mc] -f|--file [csv file] " << std::endl;
16 }
17 
18 //------------------------------------------------------------
19 
20 bool ParseCLArgs(int argc, char* argv[])
21 {
22 
23  struct option long_options[] = {
24  {"help", 0, 0, 'h'},
25  {"run", 0, 0, 'r'},
26  {"datatype", 0, 0, 'd'},
27  {"file", 0, 0, 'f'},
28  {0,0,0,0}
29  };
30 
31  while (1) {
32  int optindx;
33 
34  int c = getopt_long(argc,argv,"hr:d:f:",long_options,&optindx);
35 
36  if (c==-1) break;
37 
38  switch(c) {
39  case 'r':
40  {
41  int run = atoi(optarg);
42  if (run < 0) {
43  std::cout << "Invalid run number." << std::endl;
44  exit(0);
45  }
46  gRun = run;
47  break;
48  }
49  case 'd':
50  {
51  gDataType = optarg;
52  break;
53  }
54  case 'f':
55  {
56  gCSVFile = optarg;
57  break;
58  }
59  case 'h':
60  default:
61  {
62  return false;
63  }
64  }
65  }
66 
67  if (gRun<0)
68  return false;
69 
70  if ( gDataType != "mc" && gDataType != "data")
71  return false;
72 
73  return true;
74 }
75 
76 //------------------------------------------------------------
77 
78 int main(int argc, char **argv)
79 {
80  if (!ParseCLArgs(argc,argv)) {
81  PrintUsage();
82  return 1;
83  }
84 
86 
87  linCalib->SetIsMC((gDataType == "mc"));
88  linCalib->SetUseCondb(true);
89  if (! gCSVFile.empty())
90  linCalib->SetCSVFileName(gCSVFile);
91 
92  linCalib->Update(gRun);
93 
94  calib::LinConsts_t lc = linCalib->GetLinConsts(100);
95  std::cout << "Linearity constants correction for channel 100:"
96  << std::endl;
97  std::cout << "\tGain = " << lc.gain
98  << "\n\tOffset = " << lc.offset << std::endl;
99 
100  delete linCalib;
101 
102  return 0;
103 }
104 
int gRun
std::string gCSVFile
std::string string
Definition: nybbler.cc:12
void PrintUsage()
bool Update(uint64_t ts=0)
std::string gDataType
LinConsts_t GetLinConsts(int chanId)
void SetCSVFileName(std::string f)
bool ParseCLArgs(int argc, char *argv[])
QTextStream & endl(QTextStream &s)
int main(int argc, char **argv)