Bug Summary

File:programs/Utilities/hdevio_scan/DMapEVIOWords.cc
Location:line 199, column 3
Description:Value stored to 'evio_buffsize' is never read

Annotated Source Code

1// $Id:$
2//
3// File: DMapEVIOWords.cc
4// Created: Sat May 28 19:22:47 EDT 2016
5// Creator: davidl (on Linux gluon104.jlab.org 2.6.32-358.23.2.el6.x86_64)
6//
7
8#include <stdint.h>
9#include <vector>
10
11#include "DMapEVIOWords.h"
12#include <JANA/JApplication.h>
13#include <JANA/JFactory.h>
14#include <JANA/JEventLoop.h>
15
16using namespace std;
17using namespace jana;
18
19#include <DANA/DApplication.h>
20#include <TTAB/DTranslationTable.h>
21
22#include <TDirectory.h>
23#include <TH2.h>
24#include <TH1.h>
25#include <TProfile.h>
26#include <TProfile2D.h>
27#include <TROOT.h>
28
29
30// root hist pointers
31static TProfile *daq_hits_per_event;
32static TProfile *daq_words_per_event;
33static TH1D *daq_event_size;
34static TH1D *daq_event_tdiff;
35static TH1D *daq_words_by_type;
36//static bool ttab_labels_set = false;
37
38
39
40//------------------
41// DMapEVIOWords (Constructor)
42//------------------
43DMapEVIOWords::DMapEVIOWords()
44{
45 daq_hits_per_event = new TProfile("daq_hits_per_event", "Hits/event vs. rocid", 100, 0.5, 100.5);
46 daq_words_per_event = new TProfile("daq_words_per_event", "words/event vs. rocid", 100, 0.5, 100.5);
47 daq_event_size = new TH1D("daq_event_size", "Event size in kB", 1000, 0.0, 1.0E3);
48 daq_event_tdiff = new TH1D("daq_event_tdiff", "Time between events", 10000, 0.0, 1.0E1);
49 daq_words_by_type = new TH1D("daq_words_by_type", "Number of words in EVIO file by type", kNEVIOWordTypes, 0, (double)kNEVIOWordTypes);
50
51 daq_words_per_event->GetXaxis()->SetBinLabel(1 ,"Trigger Bank");
52 daq_words_per_event->GetXaxis()->SetBinLabel(99 ,"Residual");
53 AddROCIDLabels();
54
55 daq_event_size->SetXTitle("Total event size (kB)");
56 daq_event_tdiff->SetXTitle("#deltat between events (ms)");
57
58 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kUnknown, "unknown");
59 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOHeader, "EVIO len. & header");
60 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOEventNumber, "Event Number Word");
61 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOTimestamp, "Timestamp");
62
63 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kBORData, "BOR record");
64
65 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockHeader, "f250 Block Header");
66 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockTrailer, "f250 Block Trailer");
67 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventHeader, "f250 Event Header");
68 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250TriggerTime, "f250 Trigger Time");
69 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowRawData, "f250 Window Raw Data");
70 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowSum, "f250 Window Sum");
71 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseRawData, "f250 Pulse Raw Data");
72 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseIntegral, "f250 Pulse Integral");
73 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseTime, "f250 Pulse Time");
74 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulsePedestal, "f250 Pulse Pedestal");
75 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventTrailer, "f250 Event Trailer");
76 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250DataNotValid, "f250 Data Not Valid");
77 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250Filler, "f250 Filler Word");
78
79 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockHeader, "f125 Block Header");
80 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockTrailer, "f125 Block Trailer");
81 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventHeader, "f125 Event Header");
82 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125TriggerTime, "f125 Trigger Time");
83 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125WindowRawData, "f125 Window Raw Data");
84 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125CDCPulse, "f125 CDC Pulse");
85 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse6, "f125 FDC Pulse (integral)");
86 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse9, "f125 FDC Pulse (peak)");
87 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseIntegral, "f125 Pulse Integral");
88 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseTime, "f125 Pulse Time");
89 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulsePedestal, "f125 Pulse Pedestal");
90 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventTrailer, "f125 Event Trailer");
91 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125DataNotValid, "f125 Data Not Valid");
92 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125Filler, "f125 Filler Word");
93
94 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BlockHeader, "F1v2 Block Header");
95 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BLockTrailer, "F1v2 Block Trailer");
96 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2EventHeader, "F1v2 Event Header");
97 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2TriggerTime, "F1v2 Trigger Time");
98 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2ChipHeader, "F1v2 Chip Header");
99 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Data, "F1v2 Data");
100 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Filler, "F1v2 Filler");
101 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BreakWord, "F1v2 Break Word");
102
103 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BlockHeader, "F1v3 Block Header");
104 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BLockTrailer, "F1v3 Block Trailer");
105 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3EventHeader, "F1v3 Event Header");
106 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3TriggerTime, "F1v3 Trigger Time");
107 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3ChipHeader, "F1v3 Chip Header");
108 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Data, "F1v3 Data");
109 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Filler, "F1v3 Filler");
110 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BreakWord, "F1v3 Break Word");
111
112 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalHeader, "CAEN1190 GLobal Header");
113 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTrailer, "CAEN1190 Global Trailer");
114 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTriggerTime, "CAEN1190 Trigger Time");
115 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCHeader, "CAEN1190 TDC Header");
116 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCData, "CAEN1190 TDC Data");
117 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCError, "CAEN1190 TDC Error");
118 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCTrailer, "CAEN1190 TDC Trailer");
119 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190Filler, "CAEN1190 Filler");
120
121 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfig, "DAQ Config");
122 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf250, "DAQ Config f250");
123 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf125, "DAQ Config f125");
124 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigF1, "DAQ Config F1");
125 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigCAEN1190, "DAQ Config CAEN1190");
126
127 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSheader, "EPICS header");
128 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSdata, "EPICS data");
129
130 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF800FAFA, "0xf800fafa");
131 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kD00DD00D, "0xd00dd00d");
132
133 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kTotWords, "Total words in all events");
134 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kNevents, "Number of events");
135
136}
137
138//------------------
139// ~DMapEVIOWords (Destructor)
140//------------------
141DMapEVIOWords::~DMapEVIOWords()
142{
143
144}
145
146//------------------
147// AddROCIDLabels
148//------------------
149void DMapEVIOWords::AddROCIDLabels(void)
150{
151 /// This is called just once to set the x-axis labels
152 /// of histograms whose x-axis is the rocid so that we
153 /// can label them by detector.
154
155 DApplication dapp(0, NULL__null);
156 JEventLoop loop(&dapp);
157 DTranslationTable ttab(&loop);
158
159 // Loop over all rocid values
160 for(uint32_t rocid=2; rocid<99; rocid++){
161 // We don't actually know what slot/channel combos are defined
162 // for this so we loop until we find one.
163 bool found_chan = false;
164 daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, "");
165 daq_words_per_event->GetXaxis()->SetBinLabel(rocid, "");
166 for(uint32_t slot=2; slot<24; slot++){
167 for(uint32_t channel=0; channel<3; channel++){
168 try{
169 DTranslationTable::csc_t csc = {rocid, slot, channel};
170 const DTranslationTable::DChannelInfo &chinfo = ttab.GetDetectorIndex(csc);
171 daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, ttab.DetectorName(chinfo.det_sys).c_str());
172 daq_words_per_event->GetXaxis()->SetBinLabel(rocid, ttab.DetectorName(chinfo.det_sys).c_str());
173 found_chan = true;
174 break;
175 }catch(JException &e){
176 // Do nothing
177 }
178 }
179 if(found_chan) break;
180 }
181 }
182}
183
184
185//------------------
186// ParseEvent
187//------------------
188void DMapEVIOWords::ParseEvent(uint32_t *buff)
189{
190 uint32_t *istart = buff;
191 uint32_t evio_buffwords = buff[0]+1;
192 uint32_t evio_buffsize = evio_buffwords*sizeof(uint32_t);
193 uint32_t *iend = &istart[evio_buffwords];
194
195 if( istart==NULL__null ) return;
196 if( (evio_buffwords>=10) && (istart[7]==0xc0da0100) ){
197 // NTH is first 8 words so skip them
198 istart= &istart[8];
199 evio_buffsize -= 8*sizeof(uint32_t);
Value stored to 'evio_buffsize' is never read
200 evio_buffwords -= 8;
201 }
202
203 // Check if this is BOR data
204 if( evio_buffwords >= 4 ){
205 if( istart[1] == 0x00700001 ){
206
207 // FILL HISTOGRAMS
208 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
209 daq_words_by_type->Fill(kBORData, istart[0]/sizeof(uint32_t));
210 return; // no further parsing needed
211 }
212 }
213
214 // Check if this is EPICS data
215 if( evio_buffwords >= 4 ){
216 if( istart[1] == (0x60<<16) + (0xD<<8) + (0x1<<0) ){
217 if( istart[2] == (0x61<<24) + (0x1<<16) + (0x1<<0) ){
218
219 // FILL HISTOGRAMS
220 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
221 daq_words_by_type->Fill(kEPICSheader, 3.0); // EVIO outer and segment headers + timestamp
222 daq_words_by_type->Fill(kEPICSdata, istart[0]/sizeof(uint32_t) - 3);
223 return; // no further parsing needed
224 }
225 }
226 }
227
228 if( evio_buffwords < 4 ){
229 cout << "Too few words in event (" << evio_buffwords << ") skipping..." << endl;
230 return;
231 }
232
233 // Physics event length
234 uint32_t physics_event_len = istart[0];
235 if( (istart[1] & 0xFF001000) != 0xFF001000 ) return; // not a physics event
236 if( physics_event_len+1 > evio_buffwords ){
237 cout << "Too many words in physics event: " << physics_event_len+1 << " > " << evio_buffwords << endl;
238 return;
239 }
240
241 // Trigger bank event length
242 uint32_t trigger_bank_len = istart[2];
243 if( (istart[3] & 0xFF202000) != 0xFF202000 ) return; // not a trigger bank
244 if( trigger_bank_len+2 > evio_buffwords ){
245 cout << "Too many words in trigger bank " << trigger_bank_len << " > " << evio_buffwords-2 << endl;
246 return;
247 }
248
249 // Time difference between events
250 // since events may be out of order due to L3, we
251 // keep track of up to 400 timestamps and only make
252 // entries once we have accumulated that many.
253 // (probably better to look for adjacent event numbers
254 // but that will take a littel refactoring.)
255 uint64_t tlo = istart[2+5];
256 uint64_t thi = istart[2+6];
257 uint64_t timestamp = (thi<<32) + (tlo<<0);
258 ts_history.insert(timestamp);
259 if(ts_history.size()>400){
260 auto it1 = ts_history.begin();
261 auto it2 = it1;
262 uint64_t t1 = *(it1);
263 uint64_t t2 = *(++it2);
264 ts_history.erase(it1, ++it2);
265 double tdiff_ns = (double)(t2 - t1)*4.0;
266 double tdiff_ms = tdiff_ns/1.0E6;
267 daq_event_tdiff->Fill(tdiff_ms);
268 }
269
270 // Allocate memory to hold stats data
271 uint32_t Nwords[100]; // total data words for each ROC (includes event length words)
272 uint32_t word_stats[kNEVIOWordTypes]; // obtained from parsing event
273 for(uint32_t rocid=0; rocid<100; rocid++) Nwords[rocid] = 0;
274 for(uint32_t i=0; i<kNEVIOWordTypes; i++) word_stats[i] = 0;
275
276 word_stats[kNevents]++;
277 word_stats[kTotWords] += evio_buffwords;
278
279 word_stats[kEVIOHeader] += 4; // physics event and built trigger bank length and header words
280
281 // Loop over data banks
282 uint32_t *iptr = &istart[3+trigger_bank_len];
283 while(iptr < iend){
284
285 uint32_t len = *iptr;
286 uint32_t rocid = (iptr[1]>>16) & 0XFF;
287
288 if(rocid<100) Nwords[rocid] += len+1;
289
290 word_stats[kEVIOHeader] += 2; // ROC data bank length and header words
291
292 uint32_t *imyend = &iptr[len+1];
293 if(imyend > iend) imyend = iend;
294
295 uint64_t Nwords = ((uint64_t)imyend - (uint64_t)iptr)/sizeof(uint32_t);
296 if(Nwords<2){
297 static int Nwarnings = 0;
298 if(Nwarnings<10){
299 cout << "Nwords<2 (?)" << endl;
300 cout << " evio_buffwords = " << evio_buffwords << endl;
301 cout << " physics_event_len = " << physics_event_len << endl;
302 cout << " trigger_bank_len = " << trigger_bank_len << endl;
303 if(++Nwarnings == 10) cout << "Last warning!" << endl;
304 }
305 break;
306 }
307
308 DataWordStats(iptr, imyend, word_stats);
309
310 iptr = &iptr[len +1];
311 }
312
313 // FILL HISTOGRAMS
314 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
315
316
317 // Fill event size histos
318 double physics_event_len_kB = (double)((physics_event_len+1)*sizeof(uint32_t))/1024.0;
319 daq_event_size->Fill(physics_event_len_kB);
320 uint32_t TotalWords = 0;
321 for(uint32_t rocid=0; rocid<100; rocid++){
322 daq_words_per_event->Fill(rocid, Nwords[rocid]);
323 TotalWords += Nwords[rocid];
324 }
325
326 daq_words_per_event->Fill(1, trigger_bank_len+1);
327 daq_words_per_event->Fill(99, physics_event_len - trigger_bank_len - TotalWords);
328
329 for(uint32_t i=0; i<kNEVIOWordTypes; i++){
330 daq_words_by_type->Fill(i, (double)word_stats[i]);
331 }
332
333}
334
335//------------------
336// DataWordStats
337//------------------
338void DMapEVIOWords::DataWordStats(uint32_t *iptr, uint32_t *iend, uint32_t *word_stats)
339{
340 // Upon entry, the iptr will point to the start of the "Physics Event's Data Bank".
341 // It will loop over all sub-banks, tallying the word count as it goes up to
342 // but not including iend.
343
344 iptr++; // advance past length word
345 uint32_t rocid = (*iptr++)>>16 & 0x0FFF;
346 while(iptr < iend){
347 uint32_t data_block_bank_len = *iptr++;
348 uint32_t *iendbank = &iptr[data_block_bank_len];
349 uint32_t det_id = ((*iptr) >> 16) & 0x0FFF;
350
351 if(iendbank > iend) iendbank = iend;
352
353 word_stats[kEVIOHeader] += 2; // data block bank length and header words
354
355 iptr++; // advance to first raw data word
356
357 uint32_t Ntoprocess = data_block_bank_len - 1; // 1 for bank header
358
359#if 0 // I don't know if these words are actually implmented ??
360 word_stats[kEVIOEventNumber]++; // starting event number
361 word_stats[kEVIOTimestamp] += 2; // 48-bit timestamp
362 iptr++; // starting event number
363 iptr++; // 48-bit timestamp
364 iptr++; // 48-bit timestamp
365 Ntoprocess -= 3;
366#endif
367 uint32_t *irawdata = iptr;
368
369 switch(det_id){
370 case 0:
371 case 1:
372 case 3:
373 case 6: // flash 250 module, MMD 2014/2/4
374 case 16: // flash 125 module (CDC), DL 2014/6/19
375 case 26: // F1 TDC module (BCAL), MMD 2014-07-31
376 ParseJLabModuleData(rocid, iptr, iendbank, word_stats);
377 break;
378
379 case 20:
380 ParseCAEN1190(rocid, iptr, iendbank, word_stats);
381 break;
382
383 case 0x55:
384 ParseModuleConfiguration(rocid, iptr, iendbank, word_stats);
385 break;
386
387 default:
388 break;
389 }
390
391 uint32_t Nprocessed = (uint32_t)((uint64_t)iptr - (uint64_t)irawdata)/sizeof(uint32_t);
392 if(Nprocessed < Ntoprocess) word_stats[kUnknown] += Ntoprocess - Nprocessed;
393 iptr = iendbank;
394 }
395
396
397}
398
399//------------------
400// ParseJLabModuleData
401//------------------
402void DMapEVIOWords::ParseJLabModuleData(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
403{
404 while(iptr < iend){
405 if(*iptr != 0xf800fafa) break;
406 word_stats[kF800FAFA]++;
407 iptr++;
408 }
409
410 uint32_t mod_id = ((*iptr) >> 18) & 0x000F;
411 switch(mod_id){
412 case DModuleType::FADC250: Parsef250Bank(rocid, iptr, iend, word_stats); break;
413 case DModuleType::FADC125: Parsef125Bank(rocid, iptr, iend, word_stats); break;
414 case DModuleType::F1TDC32: ParseF1v2TDCBank(rocid, iptr, iend, word_stats); break;
415 case DModuleType::F1TDC48: ParseF1v3TDCBank(rocid, iptr, iend, word_stats); break;
416 //case DModuleType::JLAB_TS: ParseTSBank(rocid, iptr, iend, word_stats); break;
417 //case DModuleType::TID: ParseTIBank(rocid, iptr, iend, word_stats); break;
418 }
419}
420
421//------------------
422// Parsef250Bank
423//------------------
424void DMapEVIOWords::Parsef250Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
425{
426 while(iptr<iend){
427
428 if(((*iptr>>31) & 0x1) == 0) { word_stats[kUnknown]++ ; iptr++; continue;}
429
430 uint32_t window_width;
431 uint32_t window_words;
432 uint32_t data_type = (*iptr>>27) & 0x0F;
433 switch(data_type){
434 case 0: word_stats[kf250BlockHeader]++; iptr++; break;
435 case 1: word_stats[kf250BlockTrailer]++; iptr++; break;
436 case 2: word_stats[kf250EventHeader]++; iptr++; break;
437 case 3: // Trigger time
438 word_stats[kf250TriggerTime]++;
439 iptr++;
440 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf250TriggerTime]++; iptr++; }
441 break;
442 case 4: // Window Raw Data
443 window_width = (*iptr>>0) & 0x0FFF;
444 window_words = 1 + ((window_width+1)/2); // 1 is for header word + 2 sample per word
445 word_stats[kf250WindowRawData] += window_words;
446 iptr = &iptr[window_words];
447 break;
448 case 7: word_stats[kf250PulseIntegral]++; iptr++; break;
449 case 8: word_stats[kf250PulseTime]++; iptr++; break;
450 case 10: word_stats[kf250PulsePedestal]++; iptr++; break;
451 case 13: word_stats[kf250EventTrailer]++; iptr++; break;
452 case 14: word_stats[kf250DataNotValid]++; iptr++; break;
453 case 15: word_stats[kf250Filler]++; iptr++; break;
454
455 default: word_stats[kUnknown]++; iptr++; break;
456 }
457 }
458}
459
460//------------------
461// Parsef125Bank
462//------------------
463void DMapEVIOWords::Parsef125Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
464{
465 while(iptr<iend){
466
467 if(((*iptr>>31) & 0x1) == 0) { word_stats[kUnknown]++ ; iptr++; continue;}
468
469 uint32_t window_width;
470 uint32_t window_words;
471 uint32_t data_type = (*iptr>>27) & 0x0F;
472 switch(data_type){
473 case 0: word_stats[kf125BlockHeader]++; iptr++; break;
474 case 1: word_stats[kf125BlockTrailer]++; iptr++; break;
475 case 2: word_stats[kf125EventHeader]++; iptr++; break;
476 case 3: // Trigger time
477 word_stats[kf125TriggerTime]++;
478 iptr++;
479 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125TriggerTime]++; iptr++; }
480 break;
481 case 4: // Window Raw Data
482 window_width = (*iptr>>0) & 0x0FFF;
483 window_words = 1 + ((window_width+1)/2); // 1 is for header word + 2 sample per word
484 word_stats[kf125WindowRawData] += window_words;
485 iptr = &iptr[window_words];
486 break;
487 case 5: word_stats[kf125CDCPulse]++;
488 iptr++;
489 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125CDCPulse]++; iptr++; }
490 break;
491 case 6: word_stats[kf125FDCPulse6]++;
492 iptr++;
493 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse6]++; iptr++; }
494 break;
495 case 7: word_stats[kf125PulseIntegral]++; iptr++; break;
496 case 8: word_stats[kf125PulseTime]++; iptr++; break;
497 case 9: word_stats[kf125FDCPulse9]++;
498 iptr++;
499 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse9]++; iptr++; }
500 break;
501 case 10: word_stats[kf125PulsePedestal]++; iptr++; break;
502 case 13: word_stats[kf125EventTrailer]++; iptr++; break;
503 case 14: word_stats[kf125DataNotValid]++; iptr++; break;
504 case 15: word_stats[kf125Filler]++; iptr++; break;
505
506 default: word_stats[kUnknown]++; iptr++; break;
507 }
508 }
509}
510
511//------------------
512// ParseF1v2TDCBank
513//------------------
514void DMapEVIOWords::ParseF1v2TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
515{
516 while(iptr<iend){
517 switch( (*iptr++) & 0xF8000000 ){
518 case 0xC0000000: word_stats[kF1v2ChipHeader]++; break;
519 case 0xB8000000: word_stats[kF1v2Data]++; break;
520 case 0xF8000000: word_stats[kF1v2Filler]++; break;
521 case 0x80000000: word_stats[kF1v2BlockHeader]++; break;
522 case 0x88000000: word_stats[kF1v2BLockTrailer]++; break;
523 case 0x90000000: word_stats[kF1v2EventHeader]++; break;
524 case 0x98000000: word_stats[kF1v2TriggerTime]++; break;
525 case 0xF0000000: word_stats[kF1v2BreakWord]++; break;
526 default: word_stats[kUnknown]++; break;
527 }
528 }
529}
530
531//------------------
532// ParseF1v3TDCBank
533//------------------
534void DMapEVIOWords::ParseF1v3TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
535{
536 while(iptr<iend){
537 switch( (*iptr++) & 0xF8000000 ){
538 case 0xC0000000: word_stats[kF1v3ChipHeader]++; break;
539 case 0xB8000000: word_stats[kF1v3Data]++; break;
540 case 0xF8000000: word_stats[kF1v3Filler]++; break;
541 case 0x80000000: word_stats[kF1v3BlockHeader]++; break;
542 case 0x88000000: word_stats[kF1v3BLockTrailer]++; break;
543 case 0x90000000: word_stats[kF1v3EventHeader]++; break;
544 case 0x98000000: word_stats[kF1v3TriggerTime]++; break;
545 case 0xF0000000: word_stats[kF1v3BreakWord]++; break;
546 default: word_stats[kUnknown]++; break;
547 }
548 }
549}
550
551//------------------
552// ParseCAEN1190
553//------------------
554void DMapEVIOWords::ParseCAEN1190(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
555{
556 while(iptr<iend){
557
558 // This word appears to be appended to the data.
559 // Probably in the ROL. Ignore it if found.
560 if(*iptr == 0xd00dd00d) {
561 word_stats[kD00DD00D]++;
562 iptr++;
563 continue;
564 }
565
566 uint32_t type = (*iptr++) >> 27;
567 switch(type){
568 case 0b01000: word_stats[kCAEN1190GlobalHeader]++; break;
569 case 0b10000: word_stats[kCAEN1190GlobalTrailer]++; break;
570 case 0b10001: word_stats[kCAEN1190GlobalTriggerTime]++; break;
571 case 0b00001: word_stats[kCAEN1190TDCHeader]++; break;
572 case 0b00000: word_stats[kCAEN1190TDCData]++; break;
573 case 0b00100: word_stats[kCAEN1190TDCError]++; break;
574 case 0b00011: word_stats[kCAEN1190TDCTrailer]++; break;
575 case 0b11000: word_stats[kCAEN1190Filler]++; break;
576 default: word_stats[kUnknown]++; break;
577 }
578 }
579}
580
581//------------------
582// ParseModuleConfiguration
583//------------------
584void DMapEVIOWords::ParseModuleConfiguration(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
585{
586 while(iptr < iend){
587
588 word_stats[kConfig]++; // Count headers as generic
589 uint32_t Nvals = ((*iptr++) >> 24) & 0xFF;
590
591 // Loop over all parameters in this section
592 for(uint32_t i=0; i< Nvals; i++){
593
594 switch((*iptr++)>>24){
595 case 0x05: word_stats[kConfigf250]++; break;
596 case 0x0F: word_stats[kConfigf125]++; break;
597 case 0x06: word_stats[kConfigF1]++; break;
598 case 0x10: word_stats[kConfigCAEN1190]++; break;
599 default: word_stats[kConfig]++; break;
600 }
601 }
602 }
603}
604