#include "ODBCheck.hh"
#include <iostream>
#include <sstream>
#include "TROOT.h"
#include "TPluginManager.h"
Go to the source code of this file.
Functions | |
void | usage () |
Prints the usage message. | |
void | help () |
bool | parse_args (int argc, char *argv[], std::vector< int > &runs, std::string &data_dir, std::string &corr_dir) |
Homemade argument parser. | |
int | main (int argc, char *argv[]) |
The program loops through all runs passed to it and produces correction filees and saves them to a target directory. | |
Variables | |
TROOT * | gROOT |
Definition in file odb_check.cc.
void help | ( | ) |
Prints the usage message and some information on the arguments.
Definition at line 22 of file odb_check.cc.
References usage().
Referenced by parse_args().
00022 { 00023 using namespace std; 00024 usage(); 00025 cout << 00026 "odb_check: Read in shapes histogram from alcapana output files," << endl << 00027 " estimate certain values, and then output to corrections file." << endl << 00028 " -d : Followed by place where hist directory and corr directory are." << endl << 00029 " The corrections files are saved to data_dir/corr/ if" << endl << 00030 " -c flag is no specified." << endl << 00031 " -c : The directory where the correction files are stored. If not specified," << endl << 00032 " data_dir/corr/ is assumed." << endl << 00033 " -r : Followed by two numbers indicating a range of runs to process." << endl << 00034 " run1... : Any arguments not associated with a flag are assumed to be run" << endl << 00035 " numbers to process." << endl; 00036 }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
The program loops through all runs passed to it and produces correction filees and saves them to a target directory.
odb_check looks at histograms produced by alcapana and the ODB files saved during the run and finds inconsistencies and attempts to correct them. See the WireMap for and indication of what gets read in from the ODB. See the DataDir for an idea of what files are read in and produced. See PulseEstimate to see what how the estimates are made. And finally see ODBCheck to get a feel for how this all comes together.
Definition at line 135 of file odb_check.cc.
References ODBCheck::Check(), gROOT, parse_args(), and ODBCheck::SetDirs().
00135 { 00136 // First and foremost, check that we can read in files 00137 if(gROOT->GetPluginManager()->FindHandler("TVirtualStreamerInfo") == NULL) 00138 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo","*","TStreamerInfo","RIO","TStreamerInfo()"); 00139 00140 // Next, process command line arguments 00141 std::vector<int> runs; 00142 std::string data_dir; 00143 std::string corr_dir; 00144 00145 if (!parse_args(argc, argv, runs, data_dir, corr_dir)) 00146 return 1; 00147 00148 ODBCheck x; 00149 std::string raw_dir = data_dir + "raw/"; 00150 std::string odb_dir = data_dir + "odb/"; 00151 std::string hist_dir = data_dir + "hist/"; 00152 x.SetDirs(raw_dir, odb_dir, hist_dir, corr_dir); 00153 for (int r = 0; r < (int)runs.size(); ++r) { 00154 std::cout << "Checking run " << runs[r] << "..." << std::endl; 00155 x.Check(runs[r]); 00156 } 00157 }
bool parse_args | ( | int | argc, | |
char * | argv[], | |||
std::vector< int > & | runs, | |||
std::string & | data_dir, | |||
std::string & | corr_dir | |||
) |
Homemade argument parser.
Definition at line 39 of file odb_check.cc.
References help(), and usage().
Referenced by main().
00039 { 00040 if (argc == 1) { 00041 help(); 00042 return false; 00043 } 00044 for (int i = 1; i < argc; ++i) { 00045 std::string iarg(argv[i]); 00046 if (iarg == "-h" || iarg == "--help") { 00047 help(); 00048 return false; 00049 } else if (iarg == "--usage") { 00050 usage(); 00051 return false; 00052 } else if (iarg == "-d") { 00053 if (++i != argc) { 00054 data_dir = std::string(argv[i]); 00055 if (data_dir[data_dir.size() - 1] != '/') 00056 data_dir += '/'; 00057 continue; 00058 } else { 00059 std::cout << "ERROR: Nothing following -d flag!" << std::endl; 00060 return false; 00061 } 00062 } else if (iarg == "-c") { 00063 if (++i != argc) { 00064 corr_dir = std::string(argv[i]); 00065 if (corr_dir[corr_dir.size() - 1] != '/') 00066 corr_dir += '/'; 00067 continue; 00068 } else { 00069 std::cout << "ERROR: Nothing following -c flag!" << std::endl; 00070 } 00071 } else if (iarg == "-r") { 00072 std::stringstream ss; 00073 int rlow, rhigh; 00074 if (i + 2 >= argc) { 00075 std::cout << "ERROR: Not enough arguments following -r flag!" << std::endl; 00076 return false; 00077 } 00078 ss << argv[i + 1] << " " << argv[i + 2]; 00079 ss >> rlow >> rhigh; 00080 i += 2; 00081 if (rlow == 0 || rhigh == 0) { 00082 std::cout << 00083 "ERROR: Either 0 or a non-numerical value was passed as a run number." << std::endl << 00084 " Neither can be processed." << std::endl; 00085 return false; 00086 } else if (rlow >= rhigh) { 00087 std::cout << "ERROR: The first run following the -r option must be smaller than the second!" << std::endl; 00088 return false; 00089 } else if (rlow < 0) { 00090 std::cout << "ERROR: Cannot process negative run number!" << std::endl; 00091 return false; 00092 } 00093 for (int r = rlow; r <= rhigh; ++r) 00094 runs.push_back(r); 00095 } else { 00096 std::stringstream ss; 00097 int r; 00098 ss << iarg; 00099 ss >> r; 00100 if (r == 0) { 00101 std::cout << 00102 "ERROR: Either 0 or a non-numerical value was passed as a run number." << std::endl << 00103 " Neither can be processed." << std::endl; 00104 return false; 00105 } else if (r < 0) { 00106 std::cout << "ERROR: Cannot process negative run number!" << std::endl; 00107 return false; 00108 } 00109 runs.push_back(r); 00110 } 00111 } 00112 if (runs.size() == 0) { 00113 std::cout << "ERROR: No runs to process!" << std::endl; 00114 return false; 00115 } else if (data_dir.size() == 0) { 00116 std::cout << "ERROR: No data directory indicated!" << std::endl; 00117 return false; 00118 } 00119 if (corr_dir.size() == 0) 00120 corr_dir = data_dir + "corr/"; 00121 return true; 00122 }
void usage | ( | ) |
Prints the usage message.
Definition at line 15 of file odb_check.cc.
Referenced by help(), and parse_args().
TROOT* gROOT |