21 void Usage(
string mess);
43 int main(
int narg,
char *argv[])
58 void Usage(
string mess=
"")
61 cout <<
"Usage:" << endl;
63 cout <<
" hdevio [options] file.evio [file2.evio ...]" << endl;
65 cout <<
"options:" << endl;
66 cout <<
" -h, --help Print this usage statement" << endl;
67 cout <<
" -w Make histogram of population by word type" << endl;
68 cout <<
" -r file.root Set name of ROOT file to save histo to. " << endl;
69 cout <<
" (implies -w)" << endl;
70 cout <<
" -m max_events Max. EVIO events (not physics events) to process." << endl;
71 cout <<
" -i ignore_events Num. EVIO events (not physics events) to ignore at start." << endl;
72 cout <<
" -b block_size EVIO events to add for daq_block_size histo." << endl;
73 cout <<
" -e Write details of bad event tag location to file" << endl;
74 cout <<
" -n max_buff Max. events to keep timing info for (only valid)" << endl;
75 cout <<
" with -w option)" << endl;
76 cout <<
" -s Save file block/event map" << endl;
77 cout <<
" -blocksonly Save only block map not events. (Only use with -s)" << endl;
78 cout <<
" -f file.map Set name of file to save block/event to. " << endl;
79 cout <<
" (implies -s)" << endl;
81 cout <<
"n.b. When using the -i (ignore) flag, the total number of events" << endl;
82 cout <<
" read in will be the sum of how many are ignored and the \"max\"" << endl;
83 cout <<
" events with only the last max_events being processed." << endl;
86 if(mess !=
"") cout << endl << mess << endl << endl;
97 if(narg<2)
Usage(
"You must supply a filename!");
99 for(
int i=1; i<narg; i++){
100 string arg = argv[i];
101 string next = (i+1)<narg ? argv[i+1]:
"";
103 if(arg ==
"-h" || arg ==
"--help")
Usage();
108 else if(arg ==
"-b"){
BLOCK_SIZE = atoi(next.c_str()); i++;}
114 else if(arg[0] ==
'-') {cout <<
"Unknown option \""<<arg<<
"\" !" << endl; exit(-1);}
125 for(uint32_t i=0; i<
filenames.size(); i++){
127 cout <<
"Processing file " << (i+1) <<
"/" <<
filenames.size() <<
" : " << filename << endl;
131 cout << hdevio->
err_mess.str() << endl;
139 time_t end_time = time(NULL);
142 ofstream ofs(
"hdevio_scan.err");
144 ofs <<
"# hdevio_scan report for " << filename << endl;
146 ofs <<
"# The following list is for each EVIO event that contained an" << endl;
147 ofs <<
"# unknown top-level bank tag. Since any corruption may have" << endl;
148 ofs <<
"# started in the previous event, locations for that are also" << endl;
149 ofs <<
"# provided (when available)." <<endl;
150 ofs <<
"# columns are:" << endl;
151 ofs <<
"# 1 block number in file (starting from 0)" << endl;
152 ofs <<
"# 2 block offset in file (hex)" <<endl;
153 ofs <<
"# 3 block number of previous event" << endl;
154 ofs <<
"# 4 block offset of previous event" <<endl;
155 ofs <<
"# 5 event number in block (starting from 1)" << endl;
156 ofs <<
"# 6 number of events in block" << endl;
157 ofs <<
"# 7 event offset in file (hex)" <<endl;
158 ofs <<
"# 8 event length (inclusive)" <<endl;
159 ofs <<
"# 9 event header (hex) <-- This value is what indicates a corrupt event" <<endl;
160 ofs <<
"# 10 event number of previous event" << endl;
161 ofs <<
"# 11 event offset of previous event" <<endl;
162 ofs <<
"# 12 event length of previous event" <<endl;
163 ofs <<
"# 13 event header of previous event" <<endl;
165 ofs <<
"# 1 2 3 4 5 6 7 8 9 10 11 12 13" <<endl;
178 sprintf(str,
"%04u 0x%08x %04d 0x%08x %3u/%3u 0x%08x %10u 0x%08x %03d 0x%08x %10u 0x%08x"
180 , (
unsigned int)br.pos
182 , br_prev!=NULL ? (
unsigned int)br_prev->
pos:0
184 , (
unsigned int)br.evio_events.size()
185 , (
unsigned int)er.
pos
189 , er_prev!=NULL ? (
unsigned int)er_prev->
pos:0
190 , er_prev!=NULL ? (
unsigned int)er_prev->
event_len:0
191 , er_prev!=NULL ? (
unsigned int)er_prev->
event_header:0);
210 cout << (end_time -
start_time) <<
" sec " << endl;
220 cout <<
"Mapping will be limited to first " <<
MAX_EVIO_EVENTS <<
" events per input file" << endl;
223 TFile *rootfile =
new TFile(
ROOT_FILENAME.c_str(),
"RECREATE");
230 for(uint32_t i=0; i<
filenames.size(); i++){
234 cout <<
"Processing file " << (i+1) <<
"/" <<
filenames.size() <<
" : " << filename << endl;
237 cout << hdevio->
err_mess.str() << endl;
242 uint32_t buff_len = 1000;
243 uint32_t *buff =
new uint32_t[buff_len];
254 buff =
new uint32_t[buff_len];
257 cout << endl <<
" end of file" << endl;
262 cout << hdevio->
err_mess.str() << endl;
268 if((++Nevents % 1000) == 0) {
270 cout <<
" " << Nevents <<
"/" <<
MAX_EVIO_EVENTS <<
" (" << percent_done <<
"%) processed \r"; cout.flush();
bool GENERATE_ERROR_REPORT
sprintf(text,"Post KinFit Cut")
vector< EVIOBlockRecord > & GetEVIOBlockRecords(void)
void ParseCommandLineArguments(int &narg, char *argv[])
bool readNoFileBuff(uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
void SaveFileMap(string fname="")
uint32_t MAX_HISTORY_BUFF_SIZE
void PrintFileSummary(void)
uint64_t SKIP_EVIO_EVENTS
uint32_t max_history_buff_size
void Usage(JApplication &app)
int main(int argc, char *argv[])
vector< string > filenames