duneRunData.cxx
Go to the documentation of this file.
1 // duneRunData.cxx
2 //
3 // David Adams
4 // May 2018
5 //
6 // Executable that displays the run data for a run.
7 
8 #include <string>
9 #include <iostream>
10 #include <vector>
11 #include <sstream>
12 #include <memory>
15 
16 using std::string;
17 using std::cout;
18 using std::endl;
19 using std::istringstream;
20 
21 int main(int argc, char** argv) {
22  const string myname = "duneRunData: ";
23  bool help = false;
24  unsigned int irun = 0;
25  bool verbose = false;
26  string fname;
27  if ( argc > 1 ) {
28  for ( int iarg=1; iarg< argc; ++iarg ) {
29  string sarg = argv[iarg];
30  if ( sarg == "-h" ) {
31  help = true;
32  break;
33  }
34  if ( sarg == "-v" ) verbose = true;
35  }
36  if ( ! help ) {
37  string sarg = argv[argc-1];
38  istringstream ssarg(sarg);
39  ssarg >> irun;
40  if ( irun == 0 ) {
41  cout << myname << "ERROR: Last field does not appear to be a number: \""
42  << sarg << "\"" << endl;
43  return 1;
44  }
45  }
46  } else {
47  help = true;
48  }
49  if ( help ) {
50  cout << "Usage: duneRunData [-h] [-v] [-c FCLFILE] RUN" << endl;
51  cout << " Displays the run info for a run." << endl;
52  cout << " -h - Display this message." << endl;
53  cout << " -v - Verbose display including info about fcl file and run data tool." << endl;
54  return 0;
55  }
56  string tname = "protoduneRunDataTool";
57  if ( ! verbose ) cout.setstate(std::ios_base::failbit); // Turn off cout
58  cout << endl;
59  cout << myname << "Fetching tool manager." << endl;
61  cout << endl;
62  cout << myname << "Fetching run data tool." << endl;
63  const RunDataTool* prdt = ptm->getShared<RunDataTool>(tname);
64  cout << endl;
65  if ( ! verbose ) cout.clear(); // Turn cout back on.
66  if ( prdt == nullptr ) {
67  cout << myname << "ERROR: Unable to find RunDataTool " << tname << endl;
68  return 1;
69  }
70  RunData rdat = prdt->runData(irun);
71  if ( rdat.isValid() ) {
72  cout << rdat << endl;
73  } else {
74  cout << myname << "Unable to find run " << irun << endl;
75  return 2;
76  }
77  return 0;
78 }
std::string string
Definition: nybbler.cc:12
bool isValid() const
Definition: RunData.h:48
int main(int argc, char **argv)
Definition: duneRunData.cxx:21
virtual RunData runData(Index run, Index subRun=0) const =0
verbose
Definition: train.py:477
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)