Bug Summary

File:/home/sdobbs/work/clang/halld_recon/src/programs/Utilities/hdskims/hdskims.cc
Warning:line 552, column 2
Value stored to 'iptr' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name hdskims.cc -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0 -D HAVE_EVIO -D HAVE_CCDB -D HAVE_RCDB -D HAVE_TMVA=1 -D RCDB_MYSQL=1 -D RCDB_SQLITE=1 -D SQLITE_USE_LEGACY_STRUCT=ON -I .Linux_CentOS7.7-x86_64-gcc4.8.5/programs/Utilities/hdskims -I programs/Utilities/hdskims -I . -I libraries -I libraries/include -I /w/halld-scifs17exp/home/sdobbs/clang/halld_recon/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/evio/evio-4.4.6/Linux-x86_64/include -I external/xstream/include -I /usr/include/tirpc -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/root/root-6.08.06/include -I /w/halld-scifs17exp/halld2/home/sdobbs/Software/jana/jana_0.8.2/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/ccdb/ccdb_1.06.06/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/rcdb/rcdb_0.06.00/cpp/include -I /usr/include/mysql -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlitecpp/SQLiteCpp-2.2.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlite/sqlite-3.13.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/hdds/hdds-4.9.0/Linux_CentOS7.7-x86_64-gcc4.8.5/src -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/xerces-c/xerces-c-3.1.4/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward -internal-isystem /usr/local/include -internal-isystem /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /home/sdobbs/work/clang/halld_recon/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-01-21-110224-160369-1 -x c++ programs/Utilities/hdskims/hdskims.cc
1
2#include <unistd.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <time.h>
6
7#include <iostream>
8#include <fstream>
9#include <string>
10#include <vector>
11#include <stack>
12#include <thread>
13#include <sstream>
14#include <numeric>
15
16using namespace std;
17
18#include <TFile.h>
19
20#include "HDEVIOWriter.h"
21
22#undef _DBG_cout<<"programs/Utilities/hdskims/hdskims.cc"<<":"
<<22<<" "
23#undef _DBG__cout<<"programs/Utilities/hdskims/hdskims.cc"<<":"
<<23<<endl
24
25#include <DAQ/HDEVIO.h>
26
27
28enum EventType_t {
29 kUNKNOWN_EVENT,
30 kEPICS_EVENT,
31 kBOR_EVENT,
32 kCONTROL_EVENT,
33 kCODA_PHYSICS_EVENT,
34 kCDAQ_PHYSICS_EVENT
35};
36
37
38void Usage(string mess);
39
40void ParseCommandLineArguments(int narg, char *argv[]);
41
42void MakeSkim(string &fname);
43
44bool ProcessEvent(uint32_t *buff, uint32_t buff_len);
45
46void GetEventInfo(uint32_t *buff, uint32_t buff_len, EventType_t &type, uint32_t &Mevents);
47
48void GetTrigMasks(uint32_t *buff, uint32_t buff_len, uint32_t Mevents, vector <uint32_t> &trig_masks,
49 vector <uint32_t> &fp_trig_masks);
50
51
52vector <string> filenames;
53string USER_OFILENAME = "";
54uint64_t MAX_EVIO_EVENTS = 50000;
55uint64_t SKIP_EVIO_EVENTS = 0;
56uint64_t Nevents = 0;
57uint64_t Nevents_saved = 0;
58bool WRITE_SQL_FILE = false;
59bool FP_IGNORE[32];
60
61uint32_t NGTP_TOTAL[32];
62uint32_t NFP_TOTAL[32];
63
64uint32_t NEVIO_BLOCKS_TOTAL = 0;
65uint32_t NEVENTS_TOTAL = 0;
66uint32_t NEVENTS_BY_TYPE[16];
67
68uint32_t RUN_NUMBER = 0; // will be reset and overwritten for each file processed
69uint64_t FIRST_EVENT_NUMBER = 0; // will be reset and overwritten for each file processed
70uint64_t LAST_EVENT_NUMBER = 0; // will be reset and overwritten for each file processed
71
72//----------------
73// main
74//----------------
75int main(int narg, char *argv[]) {
76
77 ParseCommandLineArguments(narg, argv);
78
79 // Loop over input files
80 for (auto fname : filenames) MakeSkim(fname);
81
82 return 0;
83}
84
85//----------------
86// Usage
87//----------------
88void Usage(string mess = "") {
89 cout << endl;
90 cout << "Usage:" << endl;
91 cout << endl;
92 cout << " hdskims [options] file.evio [file2.evio ...]" << endl;
93 cout << endl;
94 cout << "options:" << endl;
95 cout << " -h, --help Print this usage statement" << endl;
96 cout << " -m max_events Max. EVIO events (not physics events) to process." << endl;
97 cout << " -i ignore_events Num. EVIO events (not physics events) to ignore at start." << endl;
98 cout << " -o outfilename Output filename (only use with single input file!)." << endl;
99 cout << " --sql Write SQL for entering into skiminfo table to an outputfile" << endl;
100 cout << " (name will be same as outputfile but with .sql extension)" << endl;
101 cout << endl;
102 cout << "n.b. When using the -i (ignore) flag, the total number of events" << endl;
103 cout << " read in will be the sum of how many are ignored and the \"max\"" << endl;
104 cout << " events with only the last max_events being processed." << endl;
105 cout << endl;
106
107 if (mess != "") cout << endl << mess << endl << endl;
108
109 exit(0);
110}
111
112//----------------
113// ParseCommandLineArguments
114//----------------
115void ParseCommandLineArguments(int narg, char *argv[]) {
116
117 if (narg < 2) Usage("You must supply a filename!");
118
119 // By default, all FP triggers can cause a block to be written out
120 for(int itrig=0; itrig<32; itrig++) FP_IGNORE[itrig] = false;
121
122 for (int i = 1; i < narg; i++) {
123 string arg = argv[i];
124 string next = (i + 1) < narg ? argv[i + 1] : "";
125
126 if (arg == "-h" || arg == "--help") Usage();
127 else if (arg == "-i") {
128 SKIP_EVIO_EVENTS = atoi(next.c_str());
129 i++;
130 }
131 else if (arg == "-m") {
132 MAX_EVIO_EVENTS = atoi(next.c_str());
133 i++;
134 }
135 else if (arg == "-o") {
136 USER_OFILENAME = next.c_str();
137 i++;
138 }
139 else if (arg == "-fp") {
140 int itrig = atoi(next.c_str());
141 if(itrig<0 || itrig>=32){
142 cerr<<"ERROR: argument to -fp option must be number in 0-31 range" << endl;
143 exit(-1);
144 }
145 FP_IGNORE[itrig] = true;
146 i++;
147 }
148 else if (arg == "-sql" || arg == "--sql") {
149 WRITE_SQL_FILE = true;
150 }
151 else if (arg[0] == '-') {
152 cout << "Unknown option \"" << arg << "\" !" << endl;
153 exit(-1);
154 }
155 else filenames.push_back(arg);
156 }
157
158 if ((filenames.size() > 1) && (USER_OFILENAME.length() > 0)) {
159 Usage("ERROR: You may only use the -o option with a single input file! (otherwise output skim files will overwrite one another)");
160 }
161
162 cout << "The following FP triggers will be saved: ";
163 for(int itrig=0; itrig<16; itrig++) if(!FP_IGNORE[itrig]) cout << itrig << ",";
164 cout << endl;
165}
166
167
168//----------------
169// MakeSkim
170//----------------
171void MakeSkim(string &filename) {
172 string ofilename = filename;
173 auto pos = ofilename.find(".evio");
174 ofilename.erase(pos);
175 ofilename += "_skims.evio";
176 pos = ofilename.find_last_of('/');
177 if (pos != string::npos) ofilename.erase(0, pos + 1);
178
179 if (USER_OFILENAME.length() > 0) ofilename = USER_OFILENAME;
180
181 // Reset globals used to capture run and event info
182 RUN_NUMBER = 0;
183 FIRST_EVENT_NUMBER = 0;
184 LAST_EVENT_NUMBER = 0;
185 for( int itype=0; itype<16; itype++) NEVENTS_BY_TYPE[itype] = 0;
186 for (int ibit = 0; ibit < 32; ibit++) NFP_TOTAL[ibit] = NGTP_TOTAL[ibit] = 0;
187
188 // Open EVIO input file
189 cout << "Processing file: " << filename << " -> " << ofilename << endl;
190 HDEVIO *hdevio = new HDEVIO(filename);
191 if (!hdevio->is_open) {
192 cout << hdevio->err_mess.str() << endl;
193 return;
194 }
195 auto Nwords_in_input_file = hdevio->GetNWordsLeftInFile();
196
197 // Open EVIO output file
198 HDEVIOWriter evioout(ofilename);
199 std::thread thr(HDEVIOOutputThread, &evioout);
200
201 // Read all events in file
202 vector <uint32_t> *vbuff = evioout.GetBufferFromPool();
203 bool done = false;
204 while (!done) {
205
206 uint32_t *buff = vbuff->data();
207 uint32_t buff_len = vbuff->capacity();
208 vbuff->resize(buff_len); // we do this here so when we resize below, it does not re-initialize the contents
209 hdevio->readNoFileBuff(buff, buff_len);
210
211 switch (hdevio->err_code) {
212 case HDEVIO::HDEVIO_OK:
213 if (Nevents >= SKIP_EVIO_EVENTS) {
214 if (ProcessEvent(buff, buff_len)) {
215 vbuff->resize((*vbuff)[0] + 1);
216 evioout.AddBufferToOutput(vbuff); // HDEVIOWriter takes ownership of buffer
217 vbuff = evioout.GetBufferFromPool(); // get a new buffer
218 Nevents_saved++;
219 }
220 }
221 break;
222 case HDEVIO::HDEVIO_USER_BUFFER_TOO_SMALL:
223 vbuff->reserve(hdevio->last_event_len);
224 break;
225 case HDEVIO::HDEVIO_EOF:
226 cout << endl << " end of file" << endl;
227 done = true;
228 break;
229 default:
230 cout << endl;
231 cout << hdevio->err_mess.str() << endl;
232 done = true;
233 break;
234 }
235
236 if ((++Nevents % 1000) == 0) {
237 auto Nleft = hdevio->GetNWordsLeftInFile();
238 auto Nread = Nwords_in_input_file - Nleft;
239 int percent_done = (100 * Nread) / Nwords_in_input_file;
240 int percent_saved = (100 * Nevents_saved ) / Nevents;
241 cout << " " << Nread << "/" << Nwords_in_input_file << " (" << percent_done << "%) processed - " << percent_saved << "% saved \r";
242 cout.flush();
243 }
244 if (Nevents > (SKIP_EVIO_EVENTS + MAX_EVIO_EVENTS)) break;
245 }
246 cout << endl;
247
248 // Close EVIO files
249 delete hdevio;
250 evioout.ReturnBufferToPool(vbuff);
251 evioout.Quit();
252 thr.join();
253
254 // Extract file number from file name (run number extracted from EVIO already)
255 uint32_t file_number = 999;
256 auto len = filename.length();
257 if( len>8 ){
258 auto filenumstr = filename.substr(len-8, 3);
259 file_number = atoi(filenumstr.c_str());
260 }
261
262 // Get host name
263 char host[256]="unknown";
264 gethostname( host, 256) ;
265
266 auto NFCAL_BCAL_TOTAL = NGTP_TOTAL[ 0];
267 auto NBCAL_TOTAL = NGTP_TOTAL[ 2];
268 auto NPS_TOTAL = NGTP_TOTAL[ 3];
269 auto NFCAL_BCAL_ST_TOTAL = NGTP_TOTAL[ 4];
270
271 auto NFCAL_LED_TOTAL = NFP_TOTAL[ 2];
272 auto NCCAL_LED1_TOTAL = NFP_TOTAL[ 4];
273 auto NCCAL_LED2_TOTAL = NFP_TOTAL[ 5];
274 auto NBCAL_LED_US_TOTAL = NFP_TOTAL[ 8];
275 auto NBCAL_LED_DS_TOTAL = NFP_TOTAL[ 9];
276 auto Nrandom_TOTAL = NFP_TOTAL[11];
277 auto NDIRC_LED_TOTAL = NFP_TOTAL[14];
278
279 cout << "===== Summary for " << filename << ":" << endl;
280 cout << " RUN: " << RUN_NUMBER << endl;
281 cout << " FILE: " << file_number << endl;
282 cout << " NFCAL_BCAL_TOTAL: " << NFCAL_BCAL_TOTAL << endl;
283 cout << " NBCAL_TOTAL: " << NBCAL_TOTAL << endl;
284 cout << " NPS_TOTAL: " << NPS_TOTAL << endl;
285 cout << " NFCAL_BCAL_ST_TOTAL: " << NFCAL_BCAL_ST_TOTAL << endl;
286 cout << endl;
287 cout << " NBCAL_LED_US_TOTAL: " << NBCAL_LED_US_TOTAL << endl;
288 cout << " NBCAL_LED_DS_TOTAL: " << NBCAL_LED_DS_TOTAL << endl;
289 cout << " Nrandom_TOTAL: " << Nrandom_TOTAL << endl;
290 cout << " NFCAL_LED_TOTAL: " << NFCAL_LED_TOTAL << endl;
291 cout << " NCCAL_LED1_TOTAL: " << NCCAL_LED1_TOTAL << endl;
292 cout << " NCCAL_LED2_TOTAL: " << NCCAL_LED2_TOTAL << endl;
293 cout << " NDIRC_LED_TOTAL: " << NDIRC_LED_TOTAL << endl;
294 cout << endl;
295 cout << " NEVIO_BLOCKS_TOTAL: " << NEVIO_BLOCKS_TOTAL << endl;
296 cout << " NEVENTS_TOTAL: " << NEVENTS_TOTAL << endl;
297 cout << "NCODA_PHYSICS_EVENTS: " << NEVENTS_BY_TYPE[kCODA_PHYSICS_EVENT] << endl;
298 cout << "NCDAQ_PHYSICS_EVENTS: " << NEVENTS_BY_TYPE[kCDAQ_PHYSICS_EVENT] << endl;
299 cout << " NBOR_EVENTS: " << NEVENTS_BY_TYPE[kBOR_EVENT] << endl;
300 cout << " NEPICS_EVENTS: " << NEVENTS_BY_TYPE[kEPICS_EVENT] << endl;
301 cout << " NCONTROL_EVENTS: " << NEVENTS_BY_TYPE[kCONTROL_EVENT] << endl;
302
303 // Form SQL commands to upsert this into the skiminfo table.
304 stringstream ss;
305 ss << "INSERT INTO skiminfo (run,file,num_physics_events,num_bor_events,num_epics_events,num_control_events,first_event,last_event,skim_host)";
306 ss << " VALUES(" << RUN_NUMBER << "," << file_number;
307 ss << "," << NEVENTS_BY_TYPE[kCODA_PHYSICS_EVENT]+NEVENTS_BY_TYPE[kCDAQ_PHYSICS_EVENT];
308 ss << "," << NEVENTS_BY_TYPE[kBOR_EVENT];
309 ss << "," << NEVENTS_BY_TYPE[kEPICS_EVENT];
310 ss << "," << NEVENTS_BY_TYPE[kCONTROL_EVENT];
311 ss << "," << FIRST_EVENT_NUMBER;
312 ss << "," << LAST_EVENT_NUMBER;
313 ss << ",'" << host << "'";
314 ss << ")";
315 ss << " ON DUPLICATE KEY UPDATE ";
316 ss << " num_physics_events=VALUES(num_physics_events)";
317 ss << " ,num_bor_events=VALUES(num_bor_events)";
318 ss << " ,num_epics_events=VALUES(num_epics_events)";
319 ss << " ,num_control_events=VALUES(num_control_events)";
320 ss << " ,first_event=VALUES(first_event)";
321 ss << " ,last_event=VALUES(last_event)";
322 ss << " ,skim_host=VALUES(skim_host)";
323 ss << ";" << endl;
324
325 ss << "UPDATE skiminfo SET ";
326 for(int itrig=0; itrig<16; itrig++){
327 if( itrig!=0 ) ss << ",";
328 ss << "NFP" << itrig << "=" << NFP_TOTAL[itrig] ;
329 ss << ",NGTP" << itrig << "=" << NGTP_TOTAL[itrig] ;
330 }
331 ss << " WHERE run=" << RUN_NUMBER << " AND file=" << file_number << ";" << endl;
332
333 // Write SQL to file
334 if( WRITE_SQL_FILE ) {
335 string sqlfilename = ofilename;
336 pos = sqlfilename.find(".evio");
337 sqlfilename.erase(pos);
338 sqlfilename += ".sql";
339 cout << "Writing SQL to: " << sqlfilename << endl;
340 ofstream sqlfile(sqlfilename);
341 sqlfile << ss.str();
342 sqlfile.close();
343 }
344}
345
346//------------------------------------------------------------------
347// ProcessEvent
348//
349// Scan event in the given buffer and decide whether to write the
350// event to the output file. Returns true if it should be written
351// and false if it shouldn't.
352//
353// This will also accumulate statistics on how many events and
354// triggers there are.
355//------------------------------------------------------------------
356bool ProcessEvent(uint32_t *buff, uint32_t buff_len) {
357 EventType_t event_type;
358 uint32_t Mevents;
359 GetEventInfo(buff, buff_len, event_type, Mevents);
360
361// cout << "Processing buffer: " << " type: " << event_type << " M: " << Mevents << endl;
362
363 if (event_type == kCODA_PHYSICS_EVENT) {
364 vector <uint32_t> trig_masks;
365 vector <uint32_t> fp_trig_masks;
366 GetTrigMasks(buff, buff_len, Mevents, trig_masks, fp_trig_masks);
367
368 uint32_t NFP[32];
369 uint32_t NGTP[32];
370 for ( int ibit = 0; ibit < 32; ibit++) NFP[ibit] = NGTP[ibit] = 0;
371
372 for (auto fp_trig_mask : fp_trig_masks) {
373 for (int ibit = 0; ibit < 32; ibit++) NFP[ibit] += ((fp_trig_mask >> ibit) & 0x01);
374 }
375
376 for (auto trig_mask : trig_masks) {
377 for (int ibit = 0; ibit < 32; ibit++) NGTP[ibit] += ((trig_mask >> ibit) & 0x01);
378 }
379
380 NEVENTS_TOTAL += Mevents;
381
382 for(int ibit = 0; ibit < 32; ibit++){
383 NGTP_TOTAL[ibit] += NGTP[ibit];
384 NFP_TOTAL[ibit] += NFP[ibit];
385 }
386
387 auto NFP_TOT = 0;
388 for(int itrig=0; itrig<32; itrig++){
389 if( FP_IGNORE[itrig] ) continue; // Allow user to specify certain FP triggers not to cause block to be written
390 NFP_TOT += NFP[itrig];
391 }
392 //auto NFP = NBCAL_LED_US + NBCAL_LED_DS + Nrandom + NFCAL_LED + NCCAL_LED1 + NCCAL_LED2 + NDIRC_LED;
393 if (NFP_TOT > 0) {
394 NEVIO_BLOCKS_TOTAL++;
395 return true; // Tell caller to write this event to file
396 }
397 return false; // Tell caller not to write this event to file
398 }
399
400 return true; // write out all non-physics events
401}
402
403//----------------
404// GetEventType
405//----------------
406void GetEventInfo(uint32_t *buff, uint32_t buff_len, EventType_t &type, uint32_t &Mevents) {
407 type = kUNKNOWN_EVENT;
408 Mevents = 1;
409
410 uint32_t event_head = buff[1];
411 uint32_t tag = (event_head >> 16) & 0xFFFF;
412 type = kUNKNOWN_EVENT;
413 switch (tag) {
414 case 0x0060:
415 type = kEPICS_EVENT;
416 break;
417 case 0x0070:
418 type = kBOR_EVENT;
419 break;
420
421 case 0xFFD0:
422 case 0xFFD1:
423 case 0xFFD2:
424 case 0xFFD3:
425 case 0xFFD4:
426 type = kCONTROL_EVENT;
427 break;
428
429 case 0xFF58:
430 case 0xFF78:
431 case 0xFF50:
432 case 0xFF70:
433 type = kCODA_PHYSICS_EVENT;
434 Mevents = event_head & 0xFF;
435 break;
436
437 case 0xFF32:
438 case 0xFF33:
439 type = kCDAQ_PHYSICS_EVENT;
440 break;
441 }
442
443 NEVENTS_BY_TYPE[ type ] += Mevents;
444}
445
446//----------------
447// GetFPmasks
448//----------------
449void GetTrigMasks(uint32_t *buff, uint32_t buff_len, uint32_t Mevents, vector <uint32_t> &trig_masks,
450 vector <uint32_t> &fp_trig_masks) {
451
452 // sanity check:
453 if (Mevents == 0) {
454 stringstream ss;
455 ss << "ERROR: GetFPmasks called with Mevents=0 ! " << endl;
456 return;
457 }
458
459 uint32_t *iptr = buff;
460 uint32_t physics_event_len = *iptr++;
461 uint32_t *iend_physics_event = &iptr[physics_event_len];
462 iptr++;
463
464 // Built Trigger Bank
465 //uint32_t built_trigger_bank_len = *iptr;
466 //uint32_t *iend_built_trigger_bank = &iptr[built_trigger_bank_len+1];
467
468 iptr++; // advance past length word
469 uint32_t mask = 0xFF202000;
470 if (((*iptr) & mask) != mask) {
471 stringstream ss;
472 ss << "Bad header word in Built Trigger Bank: " << hex << *iptr;
473 return;
474 }
475
476 uint32_t tag = (*iptr) >> 16; // 0xFF2X
477 uint32_t Nrocs = (*iptr++) & 0xFF;
478
479 //-------- Common data (64bit)
480 uint32_t common_header64 = *iptr++;
481 uint32_t common_header64_len = common_header64 & 0xFFFF;
482 uint64_t *iptr64 = (uint64_t*)iptr;
483 iptr = &iptr[common_header64_len];
484
485 // First and last event numbers
486 uint64_t first_event_num = *iptr64++;
487 uint64_t last_event_num = first_event_num + (uint64_t)Mevents - 1;
488 if( FIRST_EVENT_NUMBER==0 ) FIRST_EVENT_NUMBER = first_event_num;
489 if( LAST_EVENT_NUMBER<last_event_num ) LAST_EVENT_NUMBER = last_event_num;
490
491 // Hi and lo 32bit words in 64bit numbers seem to be
492 // switched for events read from ET, but not read from
493 // file. We only read from file here so never swap.
494 // if(event_source->source_type==event_source->kETSource) first_event_num = (first_event_num>>32) | (first_event_num<<32);
495
496 // Average timestamps
497 //uint32_t Ntimestamps = (common_header64_len / 2) - 1;
498 //if (tag & 0x2) Ntimestamps--; // subtract 1 for run number/type word if present
499 //vector <uint64_t> avg_timestamps;
500 //for(uint32_t i=0; i<Ntimestamps; i++) avg_timestamps.push_back(*iptr64++);
501
502 // run number and run type
503 //uint32_t run_type = 0;
504 if (tag & 0x02) {
505 iptr64 = &iptr64[Mevents]; // iptr64 should be pointing to first timestamp before this line
506 RUN_NUMBER = (*iptr64) >> 32;
507 //run_type = (*iptr64) & 0xFFFFFFFF;
508 //iptr64++;
509 }
510
511 //-------- Common data (16bit)
512 uint32_t common_header16 = *iptr++;
513 uint32_t common_header16_len = common_header16 & 0xFFFF;
514 uint16_t *iptr16 = (uint16_t *) iptr;
515 iptr = &iptr[common_header16_len];
516
517 vector <uint16_t> event_types;
518 for (uint32_t i = 0; i < Mevents; i++) event_types.push_back(*iptr16++);
519
520 //-------- ROC data (32bit)
521 for (uint32_t iroc = 0; iroc < Nrocs; iroc++) {
522 uint32_t common_header32 = *iptr++;
523 uint32_t common_header32_len = common_header32 & 0xFFFF;
524 uint32_t *iend_common_header = &iptr[common_header32_len];
525 uint32_t rocid = common_header32 >> 24;
526
527 if (rocid == 1) {
528 uint32_t Nwords_per_event = common_header32_len / Mevents;
529 for (uint32_t i = 0; i < Mevents; i++) {
530
531 iptr++; // uint64_t ts_low
532 iptr++; // uint64_t ts_high
533 // uint64_t timestamp = (ts_high<<32) + ts_low;
534 if (Nwords_per_event > 3) {
535 uint32_t trig_mask = *iptr++;
536 uint32_t fp_trig_mask = *iptr++;
537
538 trig_masks.push_back(trig_mask);
539 fp_trig_masks.push_back(fp_trig_mask);
540 }
541
542 if (iptr > iend_common_header) {
543 cout << "ERROR: Bad data format in Built Trigger Bank!" << endl;
544 return;
545 }
546 }
547 }
548
549 iptr = iend_common_header;
550 }
551
552 iptr = iend_physics_event;
Value stored to 'iptr' is never read
553
554 return;
555}
556
557
558