Functions | Variables
getDUNEPedestals.cc File Reference
#include "dune/RunHistory/DetPedestalDUNE.h"
#include <getopt.h>
#include <iostream>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>

Go to the source code of this file.

Functions

void PrintUsage ()
 
bool ParseCLArgs (int argc, char *argv[])
 
int main (int argc, char **argv)
 

Variables

bool gUseDB = false
 
bool gPrintPedRun = false
 
int gRun = -1
 
std::string gDetName = ""
 
std::string gCfgFile = ""
 
std::vector< uint64_tgChannelList {}
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file getDUNEPedestals.cc.

117 {
118  if (!ParseCLArgs(argc,argv)) {
119  PrintUsage();
120  return 1;
121  }
122 
124 
125  /*
126  if (gCfgFile != "")
127  ped->Configure(gCfgFile);
128  */
129 
130  if (gUseDB) {
131  ped->SetUseDB(gUseDB);
132  ped->Update(gRun);
133  }
134 
135  if (gPrintPedRun) {
136  std::cout << "Pedestal run: " << ped->VldTimeUsed() << std::endl;
137  }
138 
139  if (gChannelList.empty())
140  ped->PrintAllValues();
141  else {
142  for (size_t i=0; i<gChannelList.size(); ++i)
143  std::cout << "Channel: " << gChannelList[i]
144  << ", Mean = " << ped->PedMean(gChannelList[i])
145  << ", RMS = " << ped->PedRms(gChannelList[i])
146  << std::endl;
147  }
148 
149  delete ped;
150 
151  return 0;
152 }
void PrintUsage()
uint64_t VldTimeUsed() const
std::string gDetName
virtual float PedMean(raw::ChannelID_t ch) const
Retrieve pedestal information.
virtual float PedRms(raw::ChannelID_t ch) const
bool gPrintPedRun
int gRun
bool ParseCLArgs(int argc, char *argv[])
bool Update(uint64_t ts)
std::vector< uint64_t > gChannelList
bool gUseDB
QTextStream & endl(QTextStream &s)
bool ParseCLArgs ( int  argc,
char *  argv[] 
)

Definition at line 29 of file getDUNEPedestals.cc.

30 {
31 
32  if (argc < 2) return false;
33 
34  struct option long_options[] = {
35  {"help", 0, 0, 'h'},
36  {"run", 0, 0, 'r'},
37  {"detector", 0, 0, 'd'},
38  {"file", 0, 0, 'f'},
39  {"database", 0, 0, 'D'},
40  {"pedestalRun", 0, 0, 'P'},
41  {0,0,0,0}
42  };
43 
44  while (1) {
45  int optindx;
46 
47  int c = getopt_long(argc,argv,"r:d:f:C:DPh",long_options,&optindx);
48 
49  if (c==-1) break;
50 
51  switch(c) {
52  case 'r':
53  {
54  int run = atoi(optarg);
55  if (run < 0) {
56  std::cout << "Invalid run number." << std::endl;
57  exit(0);
58  }
59  gRun = run;
60  break;
61  }
62  case 'd':
63  {
64  gDetName = optarg;
65  break;
66  }
67  case 'D':
68  {
69  gUseDB = true;
70  break;
71  }
72  case 'P':
73  {
74  gPrintPedRun = true;
75  break;
76  }
77  case 'f':
78  {
79  gCfgFile = optarg;
80  break;
81  }
82  case 'h':
83  {
84  PrintUsage();
85  exit(0);
86  break;
87  }
88  case 'C':
89  {
90  std::vector<std::string> cList;
91  std::string channels = optarg;
92  boost::tokenizer< boost::escaped_list_separator<char> > tok(channels);
93  cList.assign(tok.begin(),tok.end());
94  for (size_t i=0; i<cList.size(); ++i) {
95  try {
96  gChannelList.push_back(boost::lexical_cast<uint64_t>(cList[i]));
97  }
98  catch (const boost::bad_lexical_cast &) {
99  std::cout << cList[i] << " does not appear to be a channel id, skipping"
100  << std::endl;
101  continue;
102  }
103  }
104  break;
105  }
106  default:
107  break;
108  }
109  }
110 
111  return true;
112 }
std::string string
Definition: nybbler.cc:12
void PrintUsage()
std::string gDetName
bool gPrintPedRun
std::string gCfgFile
int gRun
std::vector< uint64_t > gChannelList
bool gUseDB
QTextStream & endl(QTextStream &s)
unsigned int run
void PrintUsage ( )

Definition at line 17 of file getDUNEPedestals.cc.

18 {
19  std::cout << "Usage: RunInfo [options] -r|--run [run number] -d|--detector [detector name, eg, dune35t]" << std::endl;
20  std::cout << "Options:" << std::endl;
21  std::cout << "-f (--file) [fhicl file] : use fhicl config file" << std::endl;
22  std::cout << "-D (--database) : get peds from database" << std::endl;
23  std::cout << "-P (--pedestalRun) : print pedestal run" << std::endl;
24  std::cout << "-C [chan1,chan2,...] : print only specific channels" << std::endl;
25 }
QTextStream & endl(QTextStream &s)

Variable Documentation

std::string gCfgFile = ""

Definition at line 12 of file getDUNEPedestals.cc.

std::vector<uint64_t> gChannelList {}

Definition at line 13 of file getDUNEPedestals.cc.

std::string gDetName = ""

Definition at line 11 of file getDUNEPedestals.cc.

bool gPrintPedRun = false

Definition at line 9 of file getDUNEPedestals.cc.

int gRun = -1

Definition at line 10 of file getDUNEPedestals.cc.

bool gUseDB = false

Definition at line 8 of file getDUNEPedestals.cc.