Bug Summary

File:plugins/monitoring/DAQ_online/JEventProcessor_DAQ_online.cc
Location:line 504, column 3
Description:Value stored to 'evio_buffsize' is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_DAQ_online.cc
4// Created: Thu Aug 7 09:37:03 EDT 2014
5// Creator: dalton (on Linux gluon05.jlab.org 2.6.32-358.18.1.el6.x86_64 x86_64)
6//
7
8#include <stdint.h>
9#include <vector>
10
11#include "JEventProcessor_DAQ_online.h"
12#include <JANA/JApplication.h>
13#include <JANA/JFactory.h>
14
15using namespace std;
16using namespace jana;
17
18#include <DAQ/DF1TDCHit.h>
19#include <DAQ/Df250PulseIntegral.h>
20#include <DAQ/JEventSource_EVIO.h>
21#include <TTAB/DTranslationTable.h>
22
23#include <TDirectory.h>
24#include <TH2.h>
25#include <TH1.h>
26#include <TProfile.h>
27#include <TProfile2D.h>
28#include <TROOT.h>
29
30
31static const int highcratenum=100;
32// root hist pointers
33static TH2I *daq_occ_crates[highcratenum];
34static TProfile2D *daq_ped_crates[highcratenum];
35static TProfile2D *daq_TDClocked_crates[highcratenum];
36static TProfile2D *daq_TDCovr_crates[highcratenum];
37static TProfile *daq_hits_per_event;
38static TProfile *daq_words_per_event;
39static TH1D *daq_event_size;
40static TH1D *daq_event_tdiff;
41static TH1D *daq_words_by_type;
42static bool ttab_labels_set = false;
43
44// Routine used to create our JEventProcessor
45extern "C"{
46 void InitPlugin(JApplication *app){
47 InitJANAPlugin(app);
48 app->AddProcessor(new JEventProcessor_DAQ_online());
49 }
50} // "C"
51
52
53//------------------
54// JEventProcessor_DAQ_online (Constructor)
55//------------------
56JEventProcessor_DAQ_online::JEventProcessor_DAQ_online()
57{
58
59}
60
61//------------------
62// ~JEventProcessor_DAQ_online (Destructor)
63//------------------
64JEventProcessor_DAQ_online::~JEventProcessor_DAQ_online()
65{
66
67}
68
69//------------------
70// init
71//------------------
72jerror_t JEventProcessor_DAQ_online::init(void)
73{
74 printf("JEventProcessor_DAQ_online::init()\n");
75
76 // lock all root operations
77 japp->RootWriteLock();
78
79 // create root folder for DAQ and cd to it, store main dir
80 maindir = gDirectory(TDirectory::CurrentDirectory());
81 daqdir = maindir->mkdir("DAQ");
82 daqdir->cd();
83
84 // Initialise histograms and variables
85 for (int i=0; i<highcratenum; i++) {
86 daq_occ_crates[i] = NULL__null;
87 daq_ped_crates[i] = NULL__null;
88 daq_TDClocked_crates[i] = NULL__null;
89 daq_TDCovr_crates[i] = NULL__null;
90 }
91
92 daq_hits_per_event = new TProfile("daq_hits_per_event", "Hits/event vs. rocid", 100, 0.5, 100.5);
93 daq_words_per_event = new TProfile("daq_words_per_event", "words/event vs. rocid", 100, 0.5, 100.5);
94 daq_event_size = new TH1D("daq_event_size", "Event size in kB", 1000, 0.0, 1.0E3);
95 daq_event_tdiff = new TH1D("daq_event_tdiff", "Time between events", 10000, 0.0, 1.0E2);
96 daq_words_by_type = new TH1D("daq_words_by_type", "Number of words in EVIO file by type", kNEVIOWordTypes, 0, (double)kNEVIOWordTypes);
97
98 daq_words_per_event->GetXaxis()->SetBinLabel(1 ,"Trigger Bank");
99 daq_words_per_event->GetXaxis()->SetBinLabel(99 ,"Residual");
100
101 daq_event_size->SetXTitle("Total event size (kB)");
102 daq_event_tdiff->SetXTitle("#deltat between events (ms)");
103
104 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kUnknown, "unknown");
105 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOHeader, "EVIO len. & header");
106 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOEventNumber, "Event Number Word");
107 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEVIOTimestamp, "Timestamp");
108
109 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kBORData, "BOR record");
110
111 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockHeader, "f250 Block Header");
112 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250BlockTrailer, "f250 Block Trailer");
113 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventHeader, "f250 Event Header");
114 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250TriggerTime, "f250 Trigger Time");
115 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowRawData, "f250 Window Raw Data");
116 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250WindowSum, "f250 Window Sum");
117 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseRawData, "f250 Pulse Raw Data");
118 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseIntegral, "f250 Pulse Integral");
119 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulseTime, "f250 Pulse Time");
120 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250PulsePedestal, "f250 Pulse Pedestal");
121 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250EventTrailer, "f250 Event Trailer");
122 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250DataNotValid, "f250 Data Not Valid");
123 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf250Filler, "f250 Filler Word");
124
125 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockHeader, "f125 Block Header");
126 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125BlockTrailer, "f125 Block Trailer");
127 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventHeader, "f125 Event Header");
128 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125TriggerTime, "f125 Trigger Time");
129 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125WindowRawData, "f125 Window Raw Data");
130 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125CDCPulse, "f125 CDC Pulse");
131 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse6, "f125 FDC Pulse (integral)");
132 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125FDCPulse9, "f125 FDC Pulse (peak)");
133 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseIntegral, "f125 Pulse Integral");
134 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulseTime, "f125 Pulse Time");
135 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125PulsePedestal, "f125 Pulse Pedestal");
136 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125EventTrailer, "f125 Event Trailer");
137 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125DataNotValid, "f125 Data Not Valid");
138 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kf125Filler, "f125 Filler Word");
139
140 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BlockHeader, "F1v2 Block Header");
141 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BLockTrailer, "F1v2 Block Trailer");
142 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2EventHeader, "F1v2 Event Header");
143 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2TriggerTime, "F1v2 Trigger Time");
144 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2ChipHeader, "F1v2 Chip Header");
145 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Data, "F1v2 Data");
146 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2Filler, "F1v2 Filler");
147 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v2BreakWord, "F1v2 Break Word");
148
149 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BlockHeader, "F1v3 Block Header");
150 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BLockTrailer, "F1v3 Block Trailer");
151 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3EventHeader, "F1v3 Event Header");
152 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3TriggerTime, "F1v3 Trigger Time");
153 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3ChipHeader, "F1v3 Chip Header");
154 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Data, "F1v3 Data");
155 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3Filler, "F1v3 Filler");
156 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF1v3BreakWord, "F1v3 Break Word");
157
158 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalHeader, "CAEN1190 GLobal Header");
159 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTrailer, "CAEN1190 Global Trailer");
160 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190GlobalTriggerTime, "CAEN1190 Trigger Time");
161 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCHeader, "CAEN1190 TDC Header");
162 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCData, "CAEN1190 TDC Data");
163 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCError, "CAEN1190 TDC Error");
164 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190TDCTrailer, "CAEN1190 TDC Trailer");
165 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kCAEN1190Filler, "CAEN1190 Filler");
166
167 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfig, "DAQ Config");
168 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf250, "DAQ Config f250");
169 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigf125, "DAQ Config f125");
170 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigF1, "DAQ Config F1");
171 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kConfigCAEN1190, "DAQ Config CAEN1190");
172
173 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSheader, "EPICS header");
174 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kEPICSdata, "EPICS data");
175
176 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kF800FAFA, "0xf800fafa");
177 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kD00DD00D, "0xd00dd00d");
178
179 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kTotWords, "Total words in all events");
180 daq_words_by_type->GetXaxis()->SetBinLabel(1 + kNevents, "Number of events");
181
182 // back to main dir
183 maindir->cd();
184
185 // unlock
186 japp->RootUnLock();
187
188 return NOERROR;
189}
190
191//------------------
192// AddROCIDLabels
193//------------------
194void JEventProcessor_DAQ_online::AddROCIDLabels(JEventLoop *loop)
195{
196 /// This is called just once to set the x-axis labels
197 /// of histograms whose x-axis is the rocid so that we
198 /// can label them by detector.
199
200 const DTranslationTable *ttab = NULL__null;
201 loop->GetSingle(ttab);
202
203 japp->RootWriteLock();
204
205 // Loop over all rocid values
206 for(uint32_t rocid=2; rocid<99; rocid++){
207 // We don't actually know what slot/channel combos are defined
208 // for this so we loop until we find one.
209 bool found_chan = false;
210 daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, "");
211 daq_words_per_event->GetXaxis()->SetBinLabel(rocid, "");
212 for(uint32_t slot=2; slot<24; slot++){
213 for(uint32_t channel=0; channel<3; channel++){
214 try{
215 DTranslationTable::csc_t csc = {rocid, slot, channel};
216 const DTranslationTable::DChannelInfo &chinfo = ttab->GetDetectorIndex(csc);
217 daq_hits_per_event->GetXaxis()->SetBinLabel(rocid, ttab->DetectorName(chinfo.det_sys).c_str());
218 daq_words_per_event->GetXaxis()->SetBinLabel(rocid, ttab->DetectorName(chinfo.det_sys).c_str());
219 found_chan = true;
220 break;
221 }catch(JException &e){
222 // Do nothing
223 }
224 }
225 if(found_chan) break;
226 }
227 }
228
229 japp->RootUnLock();
230}
231
232//------------------
233// brun
234//------------------
235jerror_t JEventProcessor_DAQ_online::brun(JEventLoop *eventLoop, int32_t runnumber)
236{
237 // This is called whenever the run number changes
238 return NOERROR;
239}
240
241//------------------
242// evnt
243//------------------
244jerror_t JEventProcessor_DAQ_online::evnt(JEventLoop *loop, uint64_t eventnumber)
245{
246 // This is called for every event. Use of common resources like writing
247 // to a file or filling a histogram should be mutex protected. Using
248 // loop->Get(...) to get reconstructed objects (and thereby activating the
249 // reconstruction algorithm) should be done outside of any mutex lock
250 // since multiple threads may call this method at the same time.
251 // Here's an example:
252 vector<const DF1TDCHit*> f1tdchits;
253 vector<const Df250PulseIntegral*> f250PIs;
254 vector<const Df125PulseIntegral*> f125PIs;
255 vector<const Df125CDCPulse*> f125CDCs;
256 vector<const Df125FDCPulse*> f125FDCs;
257 vector<const DCAEN1290TDCHit*> caen1290hits;
258
259 loop->Get(f1tdchits);
260 loop->Get(f250PIs);
261 loop->Get(f125PIs);
262 loop->Get(f125CDCs);
263 loop->Get(f125FDCs);
264 loop->Get(caen1290hits);
265
266 ParseEventSize(loop->GetJEvent());
267
268 // Set rocid histogram labels based on detector if needed
269 if(!ttab_labels_set){
270 ttab_labels_set = true;
271 AddROCIDLabels(loop);
272 }
273
274 // Initialize counters looking at num. hits per crate
275 uint32_t Nhits_rocid[101];
276 for(uint32_t rocid=0; rocid<101; rocid++) Nhits_rocid[rocid] = 0;
277
278 // Lock ROOT
279 japp->RootWriteLock();
280
281 if (daqdir!=NULL__null) daqdir->cd();
282
283
284 // Access TDC from DF1TDCHit object
285 for(unsigned int i=0; i<f1tdchits.size(); i++) {
286 const DF1TDCHit *hit = f1tdchits[i];
287 int rocid = hit->rocid;
288 int slot = hit->slot;
289 int channel = hit->channel;
290 int data_word = hit->data_word;
291
292 if(rocid>=0 && rocid<=100) Nhits_rocid[rocid]++;
293
294 if (daq_occ_crates[rocid]==NULL__null) {
295 printf("JEventProcessor_DAQ_online::evnt creating occupancy histogram for crate %i\n",rocid);
296 char cratename[255],title[255];
297 sprintf(cratename,"daq_occ_crate%i",rocid);
298 sprintf(title,"Crate %i occupancy (TDC);Slot;Channel",rocid);
299 daq_occ_crates[rocid] = new TH2I(cratename,title,21,0.5,21.5,32,-0.5,31.5);
300 daq_occ_crates[rocid]->SetStats(0);
301 sprintf(cratename,"daq_TDClocked_crate%i",rocid);
302 sprintf(title,"Crate %i TDC lock status (TDC);Slot;Channel",rocid);
303 daq_TDClocked_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,32,-0.5,31.5);
304 daq_TDClocked_crates[rocid]->SetStats(0);
305 sprintf(cratename,"daq_TDCovr_crate%i",rocid);
306 sprintf(title,"Crate %i TDC overflow status (TDC);Slot;Channel",rocid);
307 daq_TDCovr_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,32,-0.5,31.5);
308 daq_TDCovr_crates[rocid]->SetStats(0);
309
310 }
311 daq_occ_crates[rocid]->Fill(slot,channel);
312 daq_TDClocked_crates[rocid]->Fill(slot,channel,(data_word>>26)&(1));
313 daq_TDCovr_crates[rocid]->Fill(slot,channel,(data_word>>25)&(1));
314 daq_TDCovr_crates[rocid]->Fill(slot,channel,(data_word>>24)&(1));
315 }
316
317 // Access F250 from Df250PulseIntegral object
318 for(unsigned int i=0; i<f250PIs.size(); i++) {
319 const Df250PulseIntegral *hit = f250PIs[i];
320 int rocid = hit->rocid;
321 int slot = hit->slot;
322 int channel = hit->channel;
323
324 if(rocid>=0 && rocid<=100) {
325 Nhits_rocid[rocid]++;
326
327 if (daq_occ_crates[rocid]==NULL__null) {
328 printf("JEventProcessor_DAQ_online::evnt creating occupancy histogram for crate %i\n",rocid);
329 char cratename[255],title[255];
330 sprintf(cratename,"daq_occ_crate%i",rocid);
331 sprintf(title,"Crate %i occupancy (F250);Slot;Channel",rocid);
332 daq_occ_crates[rocid] = new TH2I(cratename,title,21,0.5,21.5,16,-0.5,15.5);
333 daq_occ_crates[rocid]->SetStats(0);
334 }
335 daq_occ_crates[rocid]->Fill(slot,channel);
336
337 if (daq_ped_crates[rocid]==NULL__null) {
338 printf("JEventProcessor_DAQ_online::evnt creating pedestal histogram for crate %i\n",rocid);
339 char cratename[255],title[255];
340 sprintf(cratename,"daq_ped_crate%i",rocid);
341 sprintf(title,"Crate %i Average Pedestal (F250);Slot;Channel",rocid);
342 daq_ped_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,16,-0.5,15.5);
343 daq_ped_crates[rocid]->SetStats(0);
344 }
345 if (hit->pedestal > 0) {
346 daq_ped_crates[rocid]->Fill(slot,channel,hit->pedestal);
347 }
348 }
349 }
350
351 // Access F125 from Df125PulseIntegral object
352 for(unsigned int i=0; i<f125PIs.size(); i++) {
353 const Df125PulseIntegral *hit = f125PIs[i];
354 int rocid = hit->rocid;
355 int slot = hit->slot;
356 int channel = hit->channel;
357
358 if(hit->emulated) continue; // ignore emulated hits
359
360 if(rocid>=0 && rocid<=100) {
361 Nhits_rocid[rocid]++;
362
363 if (daq_occ_crates[rocid]==NULL__null) {
364 printf("JEventProcessor_DAQ_online::evnt creating occupancy histogram for crate %i\n",rocid);
365 char cratename[255],title[255];
366 sprintf(cratename,"daq_occ_crate%i",rocid);
367 sprintf(title,"Crate %i occupancy (F125);Slot;Channel",rocid);
368 daq_occ_crates[rocid] = new TH2I(cratename,title,21,0.5,21.5,16,-0.5,15.5);
369 daq_occ_crates[rocid]->SetStats(0);
370 }
371 daq_occ_crates[rocid]->Fill(slot,channel);
372
373 if (daq_ped_crates[rocid]==NULL__null) {
374 printf("JEventProcessor_DAQ_online::evnt creating pedestal histogram for crate %i\n",rocid);
375 char cratename[255],title[255];
376 sprintf(cratename,"daq_ped_crate%i",rocid);
377 sprintf(title,"Crate %i Average Pedestal (F125);Slot;Channel",rocid);
378 daq_ped_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,16,-0.5,15.5);
379 daq_ped_crates[rocid]->SetStats(0);
380 }
381 if (hit->pedestal > 0) {
382 daq_ped_crates[rocid]->Fill(slot,channel,hit->pedestal);
383 }
384 }
385 }
386
387 // Access F125 from Df125CDCPulse object
388 for(unsigned int i=0; i<f125CDCs.size(); i++) {
389 const Df125CDCPulse *hit = f125CDCs[i];
390 int rocid = hit->rocid;
391 int slot = hit->slot;
392 int channel = hit->channel;
393
394 if(rocid>=0 && rocid<=100) {
395 Nhits_rocid[rocid]++;
396
397 if (daq_occ_crates[rocid]==NULL__null) {
398 printf("JEventProcessor_DAQ_online::evnt creating occupancy histogram for crate %i\n",rocid);
399 char cratename[255],title[255];
400 sprintf(cratename,"daq_occ_crate%i",rocid);
401 sprintf(title,"Crate %i occupancy (F125);Slot;Channel",rocid);
402 daq_occ_crates[rocid] = new TH2I(cratename,title,21,0.5,21.5,16,-0.5,15.5);
403 daq_occ_crates[rocid]->SetStats(0);
404 }
405 daq_occ_crates[rocid]->Fill(slot,channel);
406
407 if (daq_ped_crates[rocid]==NULL__null) {
408 printf("JEventProcessor_DAQ_online::evnt creating pedestal histogram for crate %i\n",rocid);
409 char cratename[255],title[255];
410 sprintf(cratename,"daq_ped_crate%i",rocid);
411 sprintf(title,"Crate %i Average Pedestal (F125);Slot;Channel",rocid);
412 daq_ped_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,16,-0.5,15.5);
413 daq_ped_crates[rocid]->SetStats(0);
414 }
415 if (hit->pedestal > 0) {
416 daq_ped_crates[rocid]->Fill(slot,channel,hit->pedestal);
417 }
418 }
419 }
420
421 // Access F125 from Df125FDCPulse object
422 for(unsigned int i=0; i<f125FDCs.size(); i++) {
423 const Df125FDCPulse *hit = f125FDCs[i];
424 int rocid = hit->rocid;
425 int slot = hit->slot;
426 int channel = hit->channel;
427
428 if(rocid>=0 && rocid<=100) {
429 Nhits_rocid[rocid]++;
430
431 if (daq_occ_crates[rocid]==NULL__null) {
432 printf("JEventProcessor_DAQ_online::evnt creating occupancy histogram for crate %i\n",rocid);
433 char cratename[255],title[255];
434 sprintf(cratename,"daq_occ_crate%i",rocid);
435 sprintf(title,"Crate %i occupancy (F125);Slot;Channel",rocid);
436 daq_occ_crates[rocid] = new TH2I(cratename,title,21,0.5,21.5,16,-0.5,15.5);
437 daq_occ_crates[rocid]->SetStats(0);
438 }
439 daq_occ_crates[rocid]->Fill(slot,channel);
440
441 if (daq_ped_crates[rocid]==NULL__null) {
442 printf("JEventProcessor_DAQ_online::evnt creating pedestal histogram for crate %i\n",rocid);
443 char cratename[255],title[255];
444 sprintf(cratename,"daq_ped_crate%i",rocid);
445 sprintf(title,"Crate %i Average Pedestal (F125);Slot;Channel",rocid);
446 daq_ped_crates[rocid] = new TProfile2D(cratename,title,21,0.5,21.5,16,-0.5,15.5);
447 daq_ped_crates[rocid]->SetStats(0);
448 }
449 if (hit->pedestal > 0) {
450 daq_ped_crates[rocid]->Fill(slot,channel,hit->pedestal);
451 }
452 }
453 }
454
455 // Access CAEN1290 TDC hits
456 for(unsigned int i=0; i<caen1290hits.size(); i++) {
457 const DCAEN1290TDCHit *hit = caen1290hits[i];
458 int rocid = hit->rocid;
459 //int slot = hit->slot;
460 //int channel = hit->channel;
461
462 if(rocid>=0 && rocid<=100) Nhits_rocid[rocid]++;
463 }
464
465 // Fill in hits by crate
466 for(uint32_t rocid=0; rocid<101; rocid++) daq_hits_per_event->Fill(rocid, Nhits_rocid[rocid]);
467
468 maindir->cd();
469 // Unlock ROOT
470 japp->RootUnLock();
471
472 return NOERROR;
473}
474
475//------------------
476// ParseEventSize
477//------------------
478void JEventProcessor_DAQ_online::ParseEventSize(JEvent &event)
479{
480 /// This ugliness is needed to get at the true banks for each event by rocid.
481
482 // Bombproof
483 if(event.GetJEventSource()->className() != string("JEventSource_EVIO")){
484 static bool warned = false;
485 if(!warned){
486 cout << "WARNING: This is not an event source of type JEventSource_EVIO!" << endl;
487 cout << " Event size statistics filling unavailable!" << endl;
488 warned = true;
489 }
490 return;
491 }
492
493 void *ref = event.GetRef();
494 if(!ref) return;
495 uint32_t *istart = JEventSource_EVIO::GetEVIOBufferFromRef(ref);
496 uint32_t evio_buffsize = JEventSource_EVIO::GetEVIOBufferSizeFromRef(ref);
497 uint32_t evio_buffwords = evio_buffsize/sizeof(uint32_t);
498 uint32_t *iend = &istart[evio_buffwords];
499
500 if( istart==NULL__null ) return;
501 if( (evio_buffwords>=10) && (istart[7]==0xc0da0100) ){
502 // NTH is first 8 words so skip them
503 istart= &istart[8];
504 evio_buffsize -= 8*sizeof(uint32_t);
Value stored to 'evio_buffsize' is never read
505 evio_buffwords -= 8;
506 }
507
508 // Check if this is BOR data
509 if( evio_buffwords >= 4 ){
510 uint32_t mask = (0x70<<16) | (0x01);
511 if( (istart[1]&mask) == mask ){
512
513 japp->RootWriteLock();
514 daq_words_by_type->Fill(kBORData, istart[0]/sizeof(uint32_t));
515 japp->RootUnLock();
516 return; // no further parsing needed
517 }
518 }
519
520 // Check if this is EPICS data
521 if( evio_buffwords >= 4 ){
522 if( istart[1] == (0x60<<16) + (0xD<<8) + (0x1<<0) ){
523 if( istart[2] == (0x61<<24) + (0x1<<16) + (0x1<<0) ){
524
525 japp->RootWriteLock();
526 daq_words_by_type->Fill(kEPICSheader, 3.0); // EVIO outer and segment headers + timestamp
527 daq_words_by_type->Fill(kEPICSdata, istart[0]/sizeof(uint32_t) - 3);
528 japp->RootUnLock();
529 return; // no further parsing needed
530 }
531 }
532 }
533
534 if( evio_buffwords < 4 ){
535 cout << "Too few words in event (" << evio_buffwords << ") skipping..." << endl;
536 return;
537 }
538
539 // Physics event length
540 uint32_t physics_event_len = istart[0];
541 if( (istart[1] & 0xFF001000) != 0xFF001000 ) return; // not a physics event
542 if( physics_event_len+1 > evio_buffwords ){
543 cout << "Too many words in physics event: " << physics_event_len+1 << " > " << evio_buffwords << endl;
544 return;
545 }
546
547 // Trigger bank event length
548 uint32_t trigger_bank_len = istart[2];
549 if( (istart[3] & 0xFF202000) != 0xFF202000 ) return; // not a trigger bank
550 uint64_t tlo = istart[2+5];
551 uint64_t thi = istart[2+6];
552 uint64_t timestamp = (thi<<32) + (tlo<<0);
553 if( trigger_bank_len+2 > evio_buffwords ){
554 cout << "Too many words in trigger bank " << trigger_bank_len << " > " << evio_buffwords-2 << endl;
555 return;
556 }
557
558 // Allocate memory to hold stats data
559 uint32_t Nwords[100]; // total data words for each ROC (includes event length words)
560 uint32_t word_stats[kNEVIOWordTypes]; // obtained from parsing event
561 for(uint32_t rocid=0; rocid<100; rocid++) Nwords[rocid] = 0;
562 for(uint32_t i=0; i<kNEVIOWordTypes; i++) word_stats[i] = 0;
563
564 word_stats[kNevents]++;
565 word_stats[kTotWords] += evio_buffwords;
566
567 word_stats[kEVIOHeader] += 4; // physics event and built trigger bank length and header words
568
569 // Loop over data banks
570 uint32_t *iptr = &istart[3+trigger_bank_len];
571 while(iptr < iend){
572
573 uint32_t len = *iptr;
574 uint32_t rocid = (iptr[1]>>16) & 0XFF;
575
576 if(rocid<100) Nwords[rocid] += len+1;
577
578 word_stats[kEVIOHeader] += 2; // ROC data bank length and header words
579
580 uint32_t *imyend = &iptr[len+1];
581 if(imyend > iend) imyend = iend;
582
583 uint64_t Nwords = ((uint64_t)imyend - (uint64_t)iptr)/sizeof(uint32_t);
584 if(Nwords<2){
585 cout << "Nwords<2 (?)" << endl;
586 break;
587 }
588
589 DataWordStats(iptr, imyend, word_stats);
590
591 iptr = &iptr[len +1];
592 }
593
594 // Fill histograms
595 japp->RootWriteLock();
596
597 // Calculating time between events is tricky when using multiple-threads.
598 // We need the timestamp of two sequential events, but the order in which
599 // they are processed here will likely not be in event order. Thus, we keep
600 // a running list of the last 128 timestamps and event numbers seen by this
601 // routine. We can then search this for the event prior to this one and if
602 // found, use it.
603 uint32_t event_num = event.GetEventNumber();
604 static uint32_t recent_event_nums[128];
605 static uint64_t recent_timestamps[128];
606 static uint32_t ievent = 0;
607 for(uint32_t i=0; i<ievent; i++){
608 if(i>=128) break;
609 if(recent_event_nums[i] == (event_num-1)){
610 double tdiff = (double)(timestamp - recent_timestamps[i])/250.0E6; // convert to seconds
611 daq_event_tdiff->Fill(tdiff*1000.0); // ms
612 break;
613 }
614 }
615
616 // Record this timestamp/event number in the ring buffer
617 uint32_t idx = ievent%128;
618 recent_event_nums[idx] = event_num;
619 recent_timestamps[idx] = timestamp;
620 ievent++;
621
622 // Fill event size histos
623 double physics_event_len_kB = (double)((physics_event_len+1)*sizeof(uint32_t))/1024.0;
624 daq_event_size->Fill(physics_event_len_kB);
625 uint32_t TotalWords = 0;
626 for(uint32_t rocid=0; rocid<100; rocid++){
627 daq_words_per_event->Fill(rocid, Nwords[rocid]);
628 TotalWords += Nwords[rocid];
629 }
630
631 daq_words_per_event->Fill(1, trigger_bank_len+1);
632 daq_words_per_event->Fill(99, physics_event_len - trigger_bank_len - TotalWords);
633
634 for(uint32_t i=0; i<kNEVIOWordTypes; i++){
635 daq_words_by_type->Fill(i, (double)word_stats[i]);
636 }
637
638 japp->RootUnLock();
639
640}
641
642//------------------
643// DataWordStats
644//------------------
645void JEventProcessor_DAQ_online::DataWordStats(uint32_t *iptr, uint32_t *iend, uint32_t *word_stats)
646{
647 // Upon entry, the iptr will point to the start of the "Physics Event's Data Bank".
648 // It will loop over all sub-banks, tallying the word count as it goes up to
649 // but not including iend.
650
651 iptr++; // advance past length word
652 uint32_t rocid = (*iptr++)>>16 & 0x0FFF;
653 while(iptr < iend){
654 uint32_t data_block_bank_len = *iptr++;
655 uint32_t *iendbank = &iptr[data_block_bank_len];
656 uint32_t det_id = ((*iptr) >> 16) & 0x0FFF;
657
658 word_stats[kEVIOHeader] += 2; // data block bank length and header words
659
660 iptr++; // advance to first raw data word
661
662 uint32_t Ntoprocess = data_block_bank_len - 1; // 1 for bank header
663
664#if 0 // I don't know if these words are actually implmented ??
665 word_stats[kEVIOEventNumber]++; // starting event number
666 word_stats[kEVIOTimestamp] += 2; // 48-bit timestamp
667 iptr++; // starting event number
668 iptr++; // 48-bit timestamp
669 iptr++; // 48-bit timestamp
670 Ntoprocess -= 3;
671#endif
672 uint32_t *irawdata = iptr;
673
674 switch(det_id){
675 case 0:
676 case 1:
677 case 3:
678 case 6: // flash 250 module, MMD 2014/2/4
679 case 16: // flash 125 module (CDC), DL 2014/6/19
680 case 26: // F1 TDC module (BCAL), MMD 2014-07-31
681 ParseJLabModuleData(rocid, iptr, iendbank, word_stats);
682 break;
683
684 case 20:
685 ParseCAEN1190(rocid, iptr, iendbank, word_stats);
686 break;
687
688 case 0x55:
689 ParseModuleConfiguration(rocid, iptr, iendbank, word_stats);
690 break;
691
692 default:
693 break;
694 }
695
696 uint32_t Nprocessed = (uint32_t)((uint64_t)iptr - (uint64_t)irawdata)/sizeof(uint32_t);
697 if(Nprocessed < Ntoprocess) word_stats[kUnknown] += Ntoprocess - Nprocessed;
698 iptr = iendbank;
699 }
700
701
702}
703
704//------------------
705// ParseJLabModuleData
706//------------------
707void JEventProcessor_DAQ_online::ParseJLabModuleData(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
708{
709 while(iptr < iend){
710 if(*iptr != 0xf800fafa) break;
711 word_stats[kF800FAFA]++;
712 iptr++;
713 }
714
715 uint32_t mod_id = ((*iptr) >> 18) & 0x000F;
716 switch(mod_id){
717 case DModuleType::FADC250: Parsef250Bank(rocid, iptr, iend, word_stats); break;
718 case DModuleType::FADC125: Parsef125Bank(rocid, iptr, iend, word_stats); break;
719 case DModuleType::F1TDC32: ParseF1v2TDCBank(rocid, iptr, iend, word_stats); break;
720 case DModuleType::F1TDC48: ParseF1v3TDCBank(rocid, iptr, iend, word_stats); break;
721 //case DModuleType::JLAB_TS: ParseTSBank(rocid, iptr, iend, word_stats); break;
722 //case DModuleType::TID: ParseTIBank(rocid, iptr, iend, word_stats); break;
723 }
724}
725
726//------------------
727// Parsef250Bank
728//------------------
729void JEventProcessor_DAQ_online::Parsef250Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
730{
731 while(iptr<iend){
732
733 if(((*iptr>>31) & 0x1) == 0) { word_stats[kUnknown]++ ; iptr++; continue;}
734
735 uint32_t window_width;
736 uint32_t window_words;
737 uint32_t data_type = (*iptr>>27) & 0x0F;
738 switch(data_type){
739 case 0: word_stats[kf250BlockHeader]++; iptr++; break;
740 case 1: word_stats[kf250BlockTrailer]++; iptr++; break;
741 case 2: word_stats[kf250EventHeader]++; iptr++; break;
742 case 3: // Trigger time
743 word_stats[kf250TriggerTime]++;
744 iptr++;
745 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf250TriggerTime]++; iptr++; }
746 break;
747 case 4: // Window Raw Data
748 window_width = (*iptr>>0) & 0x0FFF;
749 window_words = 1 + ((window_width+1)/2); // 1 is for header word + 2 sample per word
750 word_stats[kf250WindowRawData] += window_words;
751 iptr = &iptr[window_words];
752 break;
753 case 7: word_stats[kf250PulseIntegral]++; iptr++; break;
754 case 8: word_stats[kf250PulseTime]++; iptr++; break;
755 case 10: word_stats[kf250PulsePedestal]++; iptr++; break;
756 case 13: word_stats[kf250EventTrailer]++; iptr++; break;
757 case 14: word_stats[kf250DataNotValid]++; iptr++; break;
758 case 15: word_stats[kf250Filler]++; iptr++; break;
759
760 default: word_stats[kUnknown]++; iptr++; break;
761 }
762 }
763}
764
765//------------------
766// Parsef125Bank
767//------------------
768void JEventProcessor_DAQ_online::Parsef125Bank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
769{
770 while(iptr<iend){
771
772 if(((*iptr>>31) & 0x1) == 0) { word_stats[kUnknown]++ ; iptr++; continue;}
773
774 uint32_t window_width;
775 uint32_t window_words;
776 uint32_t data_type = (*iptr>>27) & 0x0F;
777 switch(data_type){
778 case 0: word_stats[kf125BlockHeader]++; iptr++; break;
779 case 1: word_stats[kf125BlockTrailer]++; iptr++; break;
780 case 2: word_stats[kf125EventHeader]++; iptr++; break;
781 case 3: // Trigger time
782 word_stats[kf125TriggerTime]++;
783 iptr++;
784 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125TriggerTime]++; iptr++; }
785 break;
786 case 4: // Window Raw Data
787 window_width = (*iptr>>0) & 0x0FFF;
788 window_words = 1 + ((window_width+1)/2); // 1 is for header word + 2 sample per word
789 word_stats[kf125WindowRawData] += window_words;
790 iptr = &iptr[window_words];
791 break;
792 case 5: word_stats[kf125CDCPulse]++;
793 iptr++;
794 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125CDCPulse]++; iptr++; }
795 break;
796 case 6: word_stats[kf125FDCPulse6]++;
797 iptr++;
798 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse6]++; iptr++; }
799 break;
800 case 7: word_stats[kf125PulseIntegral]++; iptr++; break;
801 case 8: word_stats[kf125PulseTime]++; iptr++; break;
802 case 9: word_stats[kf125FDCPulse9]++;
803 iptr++;
804 if(((*iptr>>31) & 0x1) == 0){ word_stats[kf125FDCPulse9]++; iptr++; }
805 break;
806 case 10: word_stats[kf125PulsePedestal]++; iptr++; break;
807 case 13: word_stats[kf125EventTrailer]++; iptr++; break;
808 case 14: word_stats[kf125DataNotValid]++; iptr++; break;
809 case 15: word_stats[kf125Filler]++; iptr++; break;
810
811 default: word_stats[kUnknown]++; iptr++; break;
812 }
813 }
814}
815
816//------------------
817// ParseF1v2TDCBank
818//------------------
819void JEventProcessor_DAQ_online::ParseF1v2TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
820{
821 while(iptr<iend){
822 switch( (*iptr++) & 0xF8000000 ){
823 case 0xC0000000: word_stats[kF1v2ChipHeader]++; break;
824 case 0xB8000000: word_stats[kF1v2Data]++; break;
825 case 0xF8000000: word_stats[kF1v2Filler]++; break;
826 case 0x80000000: word_stats[kF1v2BlockHeader]++; break;
827 case 0x88000000: word_stats[kF1v2BLockTrailer]++; break;
828 case 0x90000000: word_stats[kF1v2EventHeader]++; break;
829 case 0x98000000: word_stats[kF1v2TriggerTime]++; break;
830 case 0xF0000000: word_stats[kF1v2BreakWord]++; break;
831 default: word_stats[kUnknown]++; break;
832 }
833 }
834}
835
836//------------------
837// ParseF1v3TDCBank
838//------------------
839void JEventProcessor_DAQ_online::ParseF1v3TDCBank(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
840{
841 while(iptr<iend){
842 switch( (*iptr++) & 0xF8000000 ){
843 case 0xC0000000: word_stats[kF1v3ChipHeader]++; break;
844 case 0xB8000000: word_stats[kF1v3Data]++; break;
845 case 0xF8000000: word_stats[kF1v3Filler]++; break;
846 case 0x80000000: word_stats[kF1v3BlockHeader]++; break;
847 case 0x88000000: word_stats[kF1v3BLockTrailer]++; break;
848 case 0x90000000: word_stats[kF1v3EventHeader]++; break;
849 case 0x98000000: word_stats[kF1v3TriggerTime]++; break;
850 case 0xF0000000: word_stats[kF1v3BreakWord]++; break;
851 default: word_stats[kUnknown]++; break;
852 }
853 }
854}
855
856//------------------
857// ParseCAEN1190
858//------------------
859void JEventProcessor_DAQ_online::ParseCAEN1190(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
860{
861 while(iptr<iend){
862
863 // This word appears to be appended to the data.
864 // Probably in the ROL. Ignore it if found.
865 if(*iptr == 0xd00dd00d) {
866 word_stats[kD00DD00D]++;
867 iptr++;
868 continue;
869 }
870
871 uint32_t type = (*iptr++) >> 27;
872 switch(type){
873 case 0b01000: word_stats[kCAEN1190GlobalHeader]++; break;
874 case 0b10000: word_stats[kCAEN1190GlobalTrailer]++; break;
875 case 0b10001: word_stats[kCAEN1190GlobalTriggerTime]++; break;
876 case 0b00001: word_stats[kCAEN1190TDCHeader]++; break;
877 case 0b00000: word_stats[kCAEN1190TDCData]++; break;
878 case 0b00100: word_stats[kCAEN1190TDCError]++; break;
879 case 0b00011: word_stats[kCAEN1190TDCTrailer]++; break;
880 case 0b11000: word_stats[kCAEN1190Filler]++; break;
881 default: word_stats[kUnknown]++; break;
882 }
883 }
884}
885
886//------------------
887// ParseModuleConfiguration
888//------------------
889void JEventProcessor_DAQ_online::ParseModuleConfiguration(uint32_t rocid, uint32_t *&iptr, uint32_t *iend, uint32_t *word_stats)
890{
891 while(iptr < iend){
892
893 word_stats[kConfig]++; // Count headers as generic
894 uint32_t Nvals = ((*iptr++) >> 24) & 0xFF;
895
896 // Loop over all parameters in this section
897 for(uint32_t i=0; i< Nvals; i++){
898
899 switch((*iptr++)>>24){
900 case 0x05: word_stats[kConfigf250]++; break;
901 case 0x0F: word_stats[kConfigf125]++; break;
902 case 0x06: word_stats[kConfigF1]++; break;
903 case 0x10: word_stats[kConfigCAEN1190]++; break;
904 default: word_stats[kConfig]++; break;
905 }
906 }
907 }
908}
909
910//------------------
911// erun
912//------------------
913jerror_t JEventProcessor_DAQ_online::erun(void)
914{
915 // This is called whenever the run number changes, before it is
916 // changed to give you a chance to clean up before processing
917 // events from the next run number.
918 return NOERROR;
919}
920
921//------------------
922// fini
923//------------------
924jerror_t JEventProcessor_DAQ_online::fini(void)
925{
926 // Called before program exit after event processing is finished.
927 return NOERROR;
928}
929