1 | |
2 | |
3 | |
4 | |
5 | |
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 | |
16 | using namespace std; |
17 | using 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 | extern uint32_t BLOCK_SIZE; |
30 | |
31 | |
32 | static TProfile *daq_hits_per_event; |
33 | static TProfile *daq_words_per_event; |
34 | static TH1D *daq_event_size; |
35 | static TH1D *daq_block_size; |
36 | static TH1D *daq_event_tdiff; |
37 | static TH1D *daq_words_by_type; |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | DMapEVIOWords::DMapEVIOWords() |
46 | { |
47 | char daq_block_size_title[256]; |
48 | sprintf(daq_block_size_title, "Block size (%d EVIO events) in kB", BLOCK_SIZE); |
49 | |
50 | daq_hits_per_event = new TProfile("daq_hits_per_event", "Hits/event vs. rocid", 100, 0.5, 100.5); |
51 | daq_words_per_event = new TProfile("daq_words_per_event", "words/event vs. rocid", 100, 0.5, 100.5); |
52 | daq_event_size = new TH1D("daq_event_size", "Event size in kB", 10000, 0.0, 1.0E3); |
53 | daq_block_size = new TH1D("daq_block_size", daq_block_size_title, 1000, 0.0, 1.0E3); |
54 | daq_event_tdiff = new TH1D("daq_event_tdiff", "Time between events", 10000, 0.0, 1.0E1); |
55 | daq_words_by_type = new TH1D("daq_words_by_type", "Number of words in EVIO file by type", kNEVIOWordTypes, 0, (double)kNEVIOWordTypes); |
56 | |
57 | daq_words_per_event->GetXaxis()->SetBinLabel(1 ,"Trigger Bank"); |
58 | daq_words_per_event->GetXaxis()->SetBinLabel(99 ,"Residual"); |
59 | AddROCIDLabels(); |
60 | |
61 | daq_event_size->SetXTitle("Total event size (kB)"); |
62 | daq_event_tdiff->SetXTitle("#deltat between events (ms)"); |
63 | |
64 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kUnknown, "unknown"); |
65 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOHeader, "EVIO len. & header"); |
66 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOEventNumber, "Event Number Word"); |
67 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOTimestamp, "Timestamp"); |
68 | |
69 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kBORData, "BOR record"); |
70 | |
71 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockHeader, "f250 Block Header"); |
72 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockTrailer, "f250 Block Trailer"); |
73 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventHeader, "f250 Event Header"); |
74 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250TriggerTime, "f250 Trigger Time"); |
75 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowRawData, "f250 Window Raw Data"); |
76 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowSum, "f250 Window Sum"); |
77 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseRawData, "f250 Pulse Raw Data"); |
78 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseData, "f250 Pulse Data"); |
79 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseIntegral, "f250 Pulse Integral"); |
80 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseTime, "f250 Pulse Time"); |
81 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulsePedestal, "f250 Pulse Pedestal"); |
82 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventTrailer, "f250 Event Trailer"); |
83 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250DataNotValid, "f250 Data Not Valid"); |
84 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250Filler, "f250 Filler Word"); |
85 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250Unknown, "f250 Unknown"); |
86 | |
87 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockHeader, "f125 Block Header"); |
88 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockTrailer, "f125 Block Trailer"); |
89 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventHeader, "f125 Event Header"); |
90 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125TriggerTime, "f125 Trigger Time"); |
91 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125WindowRawData, "f125 Window Raw Data"); |
92 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125CDCPulse, "f125 CDC Pulse"); |
93 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse6, "f125 FDC Pulse (integral)"); |
94 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse9, "f125 FDC Pulse (peak)"); |
95 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseIntegral, "f125 Pulse Integral"); |
96 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseTime, "f125 Pulse Time"); |
97 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulsePedestal, "f125 Pulse Pedestal"); |
98 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventTrailer, "f125 Event Trailer"); |
99 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125DataNotValid, "f125 Data Not Valid"); |
100 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125Filler, "f125 Filler Word"); |
101 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125Unknown, "f125 Unknown"); |
102 | |
103 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BlockHeader, "F1v2 Block Header"); |
104 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BLockTrailer, "F1v2 Block Trailer"); |
105 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2EventHeader, "F1v2 Event Header"); |
106 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2TriggerTime, "F1v2 Trigger Time"); |
107 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2ChipHeader, "F1v2 Chip Header"); |
108 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Data, "F1v2 Data"); |
109 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Filler, "F1v2 Filler"); |
110 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BreakWord, "F1v2 Break Word"); |
111 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Unknown, "F1v2 Unknown"); |
112 | |
113 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BlockHeader, "F1v3 Block Header"); |
114 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BLockTrailer, "F1v3 Block Trailer"); |
115 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3EventHeader, "F1v3 Event Header"); |
116 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3TriggerTime, "F1v3 Trigger Time"); |
117 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3ChipHeader, "F1v3 Chip Header"); |
118 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Data, "F1v3 Data"); |
119 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Filler, "F1v3 Filler"); |
120 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BreakWord, "F1v3 Break Word"); |
121 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Unknown, "F1v3 Unknown"); |
122 | |
123 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalHeader, "CAEN1190 GLobal Header"); |
124 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTrailer, "CAEN1190 Global Trailer"); |
125 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTriggerTime, "CAEN1190 Trigger Time"); |
126 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCHeader, "CAEN1190 TDC Header"); |
127 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCData, "CAEN1190 TDC Data"); |
128 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCError, "CAEN1190 TDC Error"); |
129 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCTrailer, "CAEN1190 TDC Trailer"); |
130 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190Filler, "CAEN1190 Filler"); |
131 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190Unknown, "CAEN1190 Unknown"); |
132 | |
133 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfig, "DAQ Config"); |
134 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf250, "DAQ Config f250"); |
135 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf125, "DAQ Config f125"); |
136 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigF1, "DAQ Config F1"); |
137 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigCAEN1190, "DAQ Config CAEN1190"); |
138 | |
139 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSheader, "EPICS header"); |
140 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSdata, "EPICS data"); |
141 | |
142 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF800FAFA, "0xf800fafa"); |
143 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kD00DD00D, "0xd00dd00d"); |
144 | |
145 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kTotWords, "Total words in all events"); |
146 | daq_words_by_type->GetXaxis()->SetBinLabel(1 + kNevents, "Number of events"); |
147 | |
148 | } |
149 | |
150 | |
151 | |
152 | |
153 | DMapEVIOWords::~DMapEVIOWords() |
154 | { |
155 | |
156 | } |
157 | |
158 | |
159 | |
160 | |
161 | void DMapEVIOWords::AddROCIDLabels(void) |
162 | { |
163 | |
164 | |
165 | |
166 | |
167 | DApplication dapp(0, NULL__null); |
168 | JEventLoop loop(&dapp); |
169 | DTranslationTable ttab(&loop); |
170 | |
171 | |
172 | for(uint32_t rocid=2; rocid<99; rocid++){ |
173 | |
174 | |
175 | bool found_chan = false; |
176 | daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, ""); |
177 | daq_words_per_event->GetXaxis()->SetBinLabel(rocid, ""); |
178 | for(uint32_t slot=2; slot<24; slot++){ |
179 | for(uint32_t channel=0; channel<3; channel++){ |
180 | try{ |
181 | DTranslationTable::csc_t csc = {rocid, slot, channel}; |
182 | const DTranslationTable::DChannelInfo &chinfo = ttab.GetDetectorIndex(csc); |
183 | daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, ttab.DetectorName(chinfo.det_sys).c_str()); |
184 | daq_words_per_event->GetXaxis()->SetBinLabel(rocid, ttab.DetectorName(chinfo.det_sys).c_str()); |
185 | found_chan = true; |
186 | break; |
187 | }catch(JException &e){ |
188 | |
189 | } |
190 | } |
191 | if(found_chan) break; |
192 | } |
193 | } |
194 | } |
195 | |
196 | |
197 | |
198 | |
199 | |
200 | void DMapEVIOWords::ParseEvent(uint32_t *buff) |
201 | { |
202 | uint32_t *istart = buff; |
203 | uint32_t evio_buffwords = buff[0]+1; |
204 | uint32_t evio_buffsize = evio_buffwords*sizeof(uint32_t); |
205 | uint32_t *iend = &istart[evio_buffwords]; |
206 | |
207 | if( istart==NULL__null ) return; |
208 | if( (evio_buffwords>=10) && (istart[7]==0xc0da0100) ){ |
209 | |
210 | istart= &istart[8]; |
211 | evio_buffsize -= 8*sizeof(uint32_t); |
| Value stored to 'evio_buffsize' is never read |
212 | evio_buffwords -= 8; |
213 | } |
214 | |
215 | |
216 | if( evio_buffwords >= 4 ){ |
217 | if( (istart[1]&0xFFFF00FF) == 0x00700001 ){ |
218 | |
219 | |
220 | |
221 | daq_words_by_type->Fill(kBORData, istart[0]/sizeof(uint32_t)); |
222 | daq_words_by_type->Fill(kTotWords, istart[0]/sizeof(uint32_t)); |
223 | return; |
224 | } |
225 | } |
226 | |
227 | |
228 | if( evio_buffwords >= 4 ){ |
229 | if( istart[1] == (0x60<<16) + (0xD<<8) + (0x1<<0) ){ |
230 | if( istart[2] == (0x61<<24) + (0x1<<16) + (0x1<<0) ){ |
231 | |
232 | |
233 | |
234 | daq_words_by_type->Fill(kEPICSheader, 3.0); |
235 | daq_words_by_type->Fill(kEPICSdata, istart[0]/sizeof(uint32_t) - 3); |
236 | daq_words_by_type->Fill(kTotWords, istart[0]/sizeof(uint32_t)); |
237 | return; |
238 | } |
239 | } |
240 | } |
241 | |
242 | if( evio_buffwords < 4 ){ |
243 | cout << "Too few words in event (" << evio_buffwords << ") skipping..." << endl; |
244 | return; |
245 | } |
246 | |
247 | |
248 | uint32_t physics_event_len = istart[0]; |
249 | if( (istart[1] & 0xFF001000) != 0xFF001000 ) return; |
250 | if( physics_event_len+1 > evio_buffwords ){ |
251 | cout << "Too many words in physics event: " << physics_event_len+1 << " > " << evio_buffwords << endl; |
252 | return; |
253 | } |
254 | |
255 | |
256 | uint32_t trigger_bank_len = istart[2]; |
257 | if( (istart[3] & 0xFF202000) != 0xFF202000 ) return; |
258 | if( trigger_bank_len+2 > evio_buffwords ){ |
259 | cout << "Too many words in trigger bank " << trigger_bank_len << " > " << evio_buffwords-2 << endl; |
260 | return; |
261 | } |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | uint64_t tlo = istart[2+5]; |
270 | uint64_t thi = istart[2+6]; |
271 | uint64_t timestamp = (thi<<32) + (tlo<<0); |
272 | ts_history.insert(timestamp); |
273 | if(ts_history.size()>400){ |
274 | auto it1 = ts_history.begin(); |
275 | auto it2 = it1; |
276 | uint64_t t1 = *(it1); |
277 | uint64_t t2 = *(++it2); |
278 | ts_history.erase(it1, ++it2); |
279 | double tdiff_ns = (double)(t2 - t1)*4.0; |
280 | double tdiff_ms = tdiff_ns/1.0E6; |
281 | daq_event_tdiff->Fill(tdiff_ms); |
282 | } |
283 | |
284 | |
285 | uint32_t Nwords[100]; |
286 | uint32_t word_stats[kNEVIOWordTypes]; |
287 | for(uint32_t rocid=0; rocid<100; rocid++) Nwords[rocid] = 0; |
288 | for(uint32_t i=0; i<kNEVIOWordTypes; i++) word_stats[i] = 0; |
289 | |
290 | word_stats[kNevents]++; |
291 | word_stats[kTotWords] += evio_buffwords; |
292 | |
293 | word_stats[kEVIOHeader] += 4; |
294 | |
295 | |
296 | uint32_t *iptr = &istart[3+trigger_bank_len]; |
297 | while(iptr < iend){ |
298 | |
299 | uint32_t len = *iptr; |
300 | uint32_t rocid = (iptr[1]>>16) & 0XFF; |
301 | |
302 | if(rocid<100) Nwords[rocid] += len+1; |
303 | |
304 | word_stats[kEVIOHeader] += 2; |
305 | |
306 | uint32_t *imyend = &iptr[len+1]; |
307 | if(imyend > iend) imyend = iend; |
308 | |
309 | uint64_t Nwords = ((uint64_t)imyend - (uint64_t)iptr)/sizeof(uint32_t); |
310 | if(Nwords<2){ |
311 | static int Nwarnings = 0; |
312 | if(Nwarnings<10){ |
313 | cout << "Nwords<2 (?)" << endl; |
314 | cout << " evio_buffwords = " << evio_buffwords << endl; |
315 | cout << " physics_event_len = " << physics_event_len << endl; |
316 | cout << " trigger_bank_len = " << trigger_bank_len << endl; |
317 | if(++Nwarnings == 10) cout << "Last warning!" << endl; |
318 | } |
319 | break; |
320 | } |
321 | |
322 | DataWordStats(iptr, imyend, word_stats); |
323 | |
324 | iptr = &iptr[len +1]; |
325 | } |
326 | |
327 | |
328 | uint32_t Nwords_added = TotWordCount(word_stats); |
329 | word_stats[kUnknown] += evio_buffwords - Nwords_added; |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | double physics_event_len_kB = (double)((physics_event_len+1)*sizeof(uint32_t))/1024.0; |
337 | daq_event_size->Fill(physics_event_len_kB); |
338 | static int Nin_block = 1; |
339 | static double block_size = 0; |
340 | block_size += physics_event_len_kB; |
341 | Nin_block++; |
342 | if( (Nin_block%BLOCK_SIZE) == 0 ){ |
343 | daq_block_size->Fill(block_size); |
344 | block_size = 0.0; |
345 | Nin_block = 0; |
346 | } |
347 | |
348 | uint32_t TotalWords = 0; |
349 | for(uint32_t rocid=0; rocid<100; rocid++){ |
350 | daq_words_per_event->Fill(rocid, Nwords[rocid]); |
351 | TotalWords += Nwords[rocid]; |
352 | } |
353 | |
354 | daq_words_per_event->Fill(1, trigger_bank_len+1); |
355 | daq_words_per_event->Fill(99, physics_event_len - trigger_bank_len - TotalWords); |
356 | |
357 | for(uint32_t i=0; i<kNEVIOWordTypes; i++){ |
358 | daq_words_by_type->Fill(i, (double)word_stats[i]); |
359 | } |
360 | |
361 | } |
362 | |
363 | |
364 | |
365 | |
366 | uint32_t DMapEVIOWords::TotWordCount(uint32_t *word_stats) |
367 | { |
368 | uint32_t N=0; |
369 | for(uint32_t i=kUnknown; i<kTotWords; i++) N += word_stats[i]; |
370 | return N; |
371 | } |
372 | |
373 | |
374 | |
375 | |
376 | void DMapEVIOWords::DataWordStats(uint32_t *iptr, uint32_t *iend, uint32_t *word_stats) |
377 | { |
378 | |
379 | |
380 | |
381 | |
382 | iptr++; |
383 | uint32_t rocid = (*iptr++)>>16 & 0x0FFF; |
384 | while(iptr < iend){ |
385 | uint32_t data_block_bank_len = *iptr++; |
386 | uint32_t *iendbank = &iptr[data_block_bank_len]; |
387 | uint32_t det_id = ((*iptr) >> 16) & 0x0FFF; |
388 | |
389 | if(iendbank > iend) iendbank = iend; |
390 | |
391 | word_stats[kEVIOHeader] += 2; |
392 | |
393 | iptr++; |
394 | |
395 | |
396 | while( (*iptr==0xF800FAFA) && (iptr<iend) ){ |
397 | word_stats[kF800FAFA]++; |
398 | iptr++; |
399 | } |
400 | |
401 | switch(det_id){ |
402 | case 0: |
403 | case 1: |
404 | case 3: |
405 | case 6: |
406 | case 16: |
407 | case 26: |
408 | ParseJLabModuleData(rocid, iptr, iendbank, word_stats); |
409 | break; |
410 | |
411 | case 20: |
412 | ParseCAEN1190(rocid, iptr, iendbank, word_stats); |
413 | break; |
414 | |
415 | case 0x55: |
416 | ParseModuleConfiguration(rocid, iptr, iendbank, word_stats); |
417 | break; |
418 | |
419 | default: |
420 | break; |
421 | } |
422 | |
423 | iptr = iendbank; |
424 | } |
425 | |
426 | |
427 | } |
428 | |
429 | |
430 | |
431 | |
432 | void DMapEVIOWords::ParseJLabModuleData(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
433 | { |
434 | while(iptr < iend){ |
435 | if(*iptr != 0xf800fafa) break; |
436 | word_stats[kF800FAFA]++; |
437 | iptr++; |
438 | } |
439 | |
440 | uint32_t mod_id = ((*iptr) >> 18) & 0x000F; |
441 | switch(mod_id){ |
442 | case DModuleType::FADC250: Parsef250Bank(rocid, iptr, iend, word_stats); break; |
443 | case DModuleType::FADC125: Parsef125Bank(rocid, iptr, iend, word_stats); break; |
444 | case DModuleType::F1TDC32: ParseF1v2TDCBank(rocid, iptr, iend, word_stats); break; |
445 | case DModuleType::F1TDC48: ParseF1v3TDCBank(rocid, iptr, iend, word_stats); break; |
446 | |
447 | |
448 | } |
449 | } |
450 | |
451 | |
452 | |
453 | |
454 | void DMapEVIOWords::Parsef250Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
455 | { |
456 | while(iptr<iend){ |
457 | |
458 | if(((*iptr>>31) & 0x1) == 0) { word_stats[kf250Unknown]++ ; iptr++; continue;} |
459 | |
460 | uint32_t window_width; |
461 | uint32_t window_words; |
462 | uint32_t data_type = (*iptr>>27) & 0x0F; |
463 | switch(data_type){ |
464 | case 0: word_stats[kf250BlockHeader]++; iptr++; break; |
465 | case 1: word_stats[kf250BlockTrailer]++; iptr++; break; |
466 | case 2: word_stats[kf250EventHeader]++; iptr++; break; |
467 | case 3: |
468 | word_stats[kf250TriggerTime]++; |
469 | iptr++; |
470 | if(((*iptr>>31) & 0x1) == 0){ word_stats[kf250TriggerTime]++; iptr++; } |
471 | break; |
472 | case 4: |
473 | window_width = (*iptr>>0) & 0x0FFF; |
474 | window_words = 1 + ((window_width+1)/2); |
475 | word_stats[kf250WindowRawData] += window_words; |
476 | iptr = &iptr[window_words]; |
477 | break; |
478 | case 7: word_stats[kf250PulseIntegral]++; iptr++; break; |
479 | case 8: word_stats[kf250PulseTime]++; iptr++; break; |
480 | case 9: word_stats[kf250PulseData]++; iptr++; |
481 | while( ((*iptr>>31) & 0x1) == 0 ){ |
482 | word_stats[kf250PulseData]++; iptr++; |
483 | if(iptr == iend) break; |
484 | } |
485 | break; |
486 | case 10: word_stats[kf250PulsePedestal]++; iptr++; break; |
487 | case 13: word_stats[kf250EventTrailer]++; iptr++; break; |
488 | case 14: word_stats[kf250DataNotValid]++; iptr++; break; |
489 | case 15: word_stats[kf250Filler]++; iptr++; break; |
490 | |
491 | default: word_stats[kf250Unknown]++; iptr++; break; |
492 | } |
493 | } |
494 | } |
495 | |
496 | |
497 | |
498 | |
499 | void DMapEVIOWords::Parsef125Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
500 | { |
501 | while(iptr<iend){ |
502 | |
503 | if(((*iptr>>31) & 0x1) == 0) { word_stats[kf125Unknown]++ ; iptr++; continue;} |
504 | |
505 | uint32_t window_width; |
506 | uint32_t window_words; |
507 | uint32_t data_type = (*iptr>>27) & 0x0F; |
508 | switch(data_type){ |
509 | case 0: word_stats[kf125BlockHeader]++; iptr++; break; |
510 | case 1: word_stats[kf125BlockTrailer]++; iptr++; break; |
511 | case 2: word_stats[kf125EventHeader]++; iptr++; break; |
512 | case 3: |
513 | word_stats[kf125TriggerTime]++; |
514 | iptr++; |
515 | if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125TriggerTime]++; iptr++; } |
516 | break; |
517 | case 4: |
518 | window_width = (*iptr>>0) & 0x0FFF; |
519 | window_words = 1 + ((window_width+1)/2); |
520 | word_stats[kf125WindowRawData] += window_words; |
521 | iptr = &iptr[window_words]; |
522 | break; |
523 | case 5: word_stats[kf125CDCPulse]++; |
524 | iptr++; |
525 | if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125CDCPulse]++; iptr++; } |
526 | break; |
527 | case 6: word_stats[kf125FDCPulse6]++; |
528 | iptr++; |
529 | if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse6]++; iptr++; } |
530 | break; |
531 | case 7: word_stats[kf125PulseIntegral]++; iptr++; break; |
532 | case 8: word_stats[kf125PulseTime]++; iptr++; break; |
533 | case 9: word_stats[kf125FDCPulse9]++; |
534 | iptr++; |
535 | if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse9]++; iptr++; } |
536 | break; |
537 | case 10: word_stats[kf125PulsePedestal]++; iptr++; break; |
538 | case 13: word_stats[kf125EventTrailer]++; iptr++; break; |
539 | case 14: word_stats[kf125DataNotValid]++; iptr++; break; |
540 | case 15: word_stats[kf125Filler]++; iptr++; break; |
541 | |
542 | default: word_stats[kf125Unknown]++; iptr++; break; |
543 | } |
544 | } |
545 | } |
546 | |
547 | |
548 | |
549 | |
550 | void DMapEVIOWords::ParseF1v2TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
551 | { |
552 | while(iptr<iend){ |
553 | switch( (*iptr++) & 0xF8000000 ){ |
554 | case 0xC0000000: word_stats[kF1v2ChipHeader]++; break; |
555 | case 0xB8000000: word_stats[kF1v2Data]++; break; |
556 | case 0xF8000000: word_stats[kF1v2Filler]++; break; |
557 | case 0x80000000: word_stats[kF1v2BlockHeader]++; break; |
558 | case 0x88000000: word_stats[kF1v2BLockTrailer]++; break; |
559 | case 0x90000000: word_stats[kF1v2EventHeader]++; break; |
560 | case 0x98000000: word_stats[kF1v2TriggerTime]++; break; |
561 | case 0xF0000000: word_stats[kF1v2BreakWord]++; break; |
562 | default: word_stats[kF1v2Unknown]++; break; |
563 | } |
564 | } |
565 | } |
566 | |
567 | |
568 | |
569 | |
570 | void DMapEVIOWords::ParseF1v3TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
571 | { |
572 | while(iptr<iend){ |
573 | switch( (*iptr++) & 0xF8000000 ){ |
574 | case 0xC0000000: word_stats[kF1v3ChipHeader]++; break; |
575 | case 0xB8000000: word_stats[kF1v3Data]++; break; |
576 | case 0xF8000000: word_stats[kF1v3Filler]++; break; |
577 | case 0x80000000: word_stats[kF1v3BlockHeader]++; break; |
578 | case 0x88000000: word_stats[kF1v3BLockTrailer]++; break; |
579 | case 0x90000000: word_stats[kF1v3EventHeader]++; break; |
580 | case 0x98000000: word_stats[kF1v3TriggerTime]++; break; |
581 | case 0xF0000000: word_stats[kF1v3BreakWord]++; break; |
582 | default: word_stats[kF1v3Unknown]++; break; |
583 | } |
584 | } |
585 | } |
586 | |
587 | |
588 | |
589 | |
590 | void DMapEVIOWords::ParseCAEN1190(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
591 | { |
592 | while(iptr<iend){ |
593 | |
594 | |
595 | |
596 | if(*iptr == 0xd00dd00d) { |
597 | word_stats[kD00DD00D]++; |
598 | iptr++; |
599 | continue; |
600 | } |
601 | |
602 | uint32_t type = (*iptr++) >> 27; |
603 | switch(type){ |
604 | case 0b01000: word_stats[kCAEN1190GlobalHeader]++; break; |
605 | case 0b10000: word_stats[kCAEN1190GlobalTrailer]++; break; |
606 | case 0b10001: word_stats[kCAEN1190GlobalTriggerTime]++; break; |
607 | case 0b00001: word_stats[kCAEN1190TDCHeader]++; break; |
608 | case 0b00000: word_stats[kCAEN1190TDCData]++; break; |
609 | case 0b00100: word_stats[kCAEN1190TDCError]++; break; |
610 | case 0b00011: word_stats[kCAEN1190TDCTrailer]++; break; |
611 | case 0b11000: word_stats[kCAEN1190Filler]++; break; |
612 | default: word_stats[kCAEN1190Unknown]++; break; |
613 | } |
614 | } |
615 | } |
616 | |
617 | |
618 | |
619 | |
620 | void DMapEVIOWords::ParseModuleConfiguration(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats) |
621 | { |
622 | while(iptr < iend){ |
623 | |
624 | word_stats[kConfig]++; |
625 | uint32_t Nvals = ((*iptr++) >> 24) & 0xFF; |
626 | |
627 | |
628 | for(uint32_t i=0; i< Nvals; i++){ |
629 | |
630 | switch((*iptr++)>>24){ |
631 | case 0x05: word_stats[kConfigf250]++; break; |
632 | case 0x0F: word_stats[kConfigf125]++; break; |
633 | case 0x06: word_stats[kConfigF1]++; break; |
634 | case 0x10: word_stats[kConfigCAEN1190]++; break; |
635 | default: word_stats[kConfig]++; break; |
636 | } |
637 | } |
638 | } |
639 | } |
640 | |