Bug Summary

File:plugins/monitoring/CDC_online/JEventProcessor_CDC_online.cc
Location:line 299, column 5
Description:Value stored to 'total_ped' is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_CDC_online.cc
4// Created: Wed Oct 22 2014
5// Creator: Naomi Jarvis
6
7
8#include <stdint.h>
9#include <vector>
10
11#include <TMath.h>
12
13
14#include "JEventProcessor_CDC_online.h"
15#include <JANA/JApplication.h>
16
17
18using namespace std;
19using namespace jana;
20
21
22#include "CDC/DCDCHit.h"
23#include "CDC/DCDCDigiHit.h"
24#include "DAQ/Df125PulseIntegral.h"
25#include "DAQ/Df125PulsePedestal.h"
26#include "DAQ/Df125WindowRawData.h"
27#include "DAQ/Df125CDCPulse.h"
28#include "DAQ/Df125Config.h"
29
30#include <TDirectory.h>
31#include <TH2.h>
32#include <TH1.h>
33
34
35// root hist pointers
36
37static TH1I *cdc_num_events = NULL__null;
38
39static TH2I *cdc_o = NULL__null;
40static TH2D *cdc_occ_ring[29];
41
42static TH1I *cdc_raw_amp = NULL__null;
43static TH2I *cdc_raw_amp_vs_n = NULL__null;
44
45static TH1I *cdc_raw_t;
46static TH2I *cdc_raw_t_vs_n;
47
48static TH1I *cdc_raw_intpp; //raw integral including pedestal
49static TH2I *cdc_raw_intpp_vs_n;
50
51static TH1I *cdc_raw_int; //raw integral minus pedestal
52static TH2I *cdc_raw_int_vs_n;
53
54static TH1I *cdc_ped = NULL__null;
55static TH2I *cdc_ped_vs_n = NULL__null;
56
57static TH1I *cdc_windata_ped = NULL__null;
58static TH2I *cdc_windata_ped_vs_n = NULL__null;
59
60
61
62
63//----------------------------------------------------------------------------------
64
65
66// Routine used to create our JEventProcessor
67extern "C"{
68 void InitPlugin(JApplication *app){
69 InitJANAPlugin(app);
70 app->AddProcessor(new JEventProcessor_CDC_online());
71 }
72}
73
74
75//----------------------------------------------------------------------------------
76
77
78JEventProcessor_CDC_online::JEventProcessor_CDC_online() {
79}
80
81
82//----------------------------------------------------------------------------------
83
84
85JEventProcessor_CDC_online::~JEventProcessor_CDC_online() {
86}
87
88
89//----------------------------------------------------------------------------------
90
91jerror_t JEventProcessor_CDC_online::init(void) {
92
93 // I moved all the histogram setup into the brun so that I can use different
94 // scales for the later runs using the new firmware
95
96
97 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
98
99
100 // create root folder for cdc and cd to it, store main dir
101 TDirectory *main = gDirectory(TDirectory::CurrentDirectory());
102 gDirectory(TDirectory::CurrentDirectory())->mkdir("CDC")->cd();
103
104
105 cdc_num_events = new TH1I("cdc_num_events","CDC number of events",1, 0.5, 1.5);
106
107 cdc_o = new TH2I("cdc_o","CDC occupancy by straw, ring;straw;ring",209,0.5,209.5,28,0.5,28.5);
108
109
110 gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_occupancy","CDC rings: occupancy")->cd();
111
112
113 // Hit occupancy
114 int Nstraws[28] = {42, 42, 54, 54, 66, 66, 80, 80, 93, 93, 106, 106, 123, 123, 135, 135, 146, 146, 158, 158, 170, 170, 182, 182, 197, 197, 209, 209};
115 double radius[28] = {10.72134, 12.08024, 13.7795, 15.14602, 18.71726, 20.2438, 22.01672, 23.50008, 25.15616, 26.61158, 28.33624, 29.77388, 31.3817, 32.75838, 34.43478, 35.81146, 38.28542, 39.7002, 41.31564, 42.73042, 44.34078, 45.75302, 47.36084, 48.77054, 50.37582, 51.76012, 53.36286, 54.74716};
116 double phi[28] = {0, 0.074707844, 0.038166294, 0.096247609, 0.05966371, 0.012001551, 0.040721951, 0.001334527, 0.014963808, 0.048683644, 0.002092645, 0.031681749, 0.040719354, 0.015197341, 0.006786058, 0.030005892, 0.019704045, -0.001782064, -0.001306618, 0.018592421, 0.003686784, 0.022132975, 0.019600866, 0.002343723, 0.021301449, 0.005348855, 0.005997358, 0.021018761};
117
118 // Define a different 2D histogram for each ring. X-axis is phi, Y-axis is radius (to plot correctly with "pol" option)
119 for(int iring=0; iring<28; iring++){
120 double r_start = radius[iring] - 0.8;
121 double r_end = radius[iring] + 0.8;
122 double phi_start = phi[iring]; // this is for center of straw. Need additional calculation for phi at end plate
123 double phi_end = phi_start + TMath::TwoPi();
124
125 char hname[256];
126 sprintf(hname, "cdc_occ_ring[%d]", iring+1);
127 cdc_occ_ring[iring+1] = new TH2D(hname, "", Nstraws[iring], phi_start, phi_end, 1, r_start, r_end);
128 }
129
130
131 // back to main dir
132 main->cd();
133
134 japp->RootUnLock(); //RELEASE ROOT LOCK!!
135
136 return NOERROR;
137}
138
139
140//----------------------------------------------------------------------------------
141
142
143jerror_t JEventProcessor_CDC_online::brun(JEventLoop *eventLoop, int32_t runnumber) {
144 // This is called whenever the run number changes
145
146 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
147
148 // max values for histogram scales, modified fa250-format readout
149
150
151 Int_t AMAX = 4096; //max for amplitude, fa250-format, 12 bits
152
153 // Int_t IMAX = 524288; //max for raw integral, fa250-format, 19 bits
154 Int_t IMAX = 400000; //max for raw integral, fa250-format, 19 bits
155
156 Int_t PMAX = 512; //max for pedestal, fa250-format max is 512
157 // Int_t RTMAX = 32768; //max for raw time, fa250-format, 15 bits
158 Int_t RTMAX = 12000; //max for raw time, less than full field width
159
160 Char_t rtunits[8] = "0.125ns"; //raw time is in units of sample/64 = ns/8
161
162
163
164 if (runnumber > 3675) { //new fa125 format firmware, from 11 Sept 2015
165
166
167 // raw quantities for read out (125 format) are
168 // time field max 2047 scaled x 1, units 0.8ns
169 // time qf field max 1
170 // overflow count field max 7
171 // pedestal field max 255 scaled x 1/1 initially
172 // max amplitude 9 bits, field max 511 scaled x 1/8
173 // integral field max 16383 scaled x 1/16
174
175 // max values for histogram scales, fa125-format readout
176
177 IMAX = 16384; //max for raw integral, fa125-format, 14 bits
178 PMAX = 256; //max for pedestal, fa125-format, 8 bits
179 RTMAX = 2048; //max for raw time, fa125-format, 11 bits
180 AMAX = 512; //max for amplitude, fa125-format, 9 bits
181
182 sprintf(rtunits,"0.8ns"); //raw time is in units of sample/10 = 0.8ns
183
184 }
185
186
187 const Int_t NSTRAWS = 3522;
188 const Float_t HALF = 0.5;
189 const Float_t NSTRAWSPH = 3522.5;
190
191 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
192
193
194
195 // created root folder for cdc in init; cd to it, store main dir
196
197 gDirectory(TDirectory::CurrentDirectory())->cd("CDC");
198
199
200 // book histograms
201
202
203 cdc_raw_amp = new TH1I("cdc_raw_amp","CDC amplitude (ADC units, scaled); ADC units",AMAX,0,AMAX);
204 cdc_raw_amp_vs_n = new TH2I("cdc_raw_amp_vs_n","CDC amplitude (ADC units, scaled) vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,128,0,AMAX);
205
206 cdc_raw_t = new TH1I("cdc_raw_t",Form("CDC raw time (units of %s); raw time (%s)",rtunits,rtunits),200,0,RTMAX);
207 cdc_raw_t_vs_n = new TH2I("cdc_raw_t_vs_n",Form("CDC raw time (units of %s) vs straw number;straw;time (%s)",rtunits,rtunits),NSTRAWS,HALF,NSTRAWSPH,100,0,RTMAX);
208
209
210
211 cdc_raw_int = new TH1I("cdc_raw_int","CDC integral (ADC units, scaled), pedestal subtracted; ADC units",200,0,IMAX);
212 cdc_raw_int_vs_n = new TH2I("cdc_raw_int_vs_n","CDC integral (ADC units,scaled), pedestal subtracted, vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,100,0,IMAX);
213
214
215 cdc_raw_intpp = new TH1I("cdc_raw_intpp","CDC integral (ADC units, scaled), includes pedestal; ADC units",200,0,IMAX);
216 cdc_raw_intpp_vs_n = new TH2I("cdc_raw_intpp_vs_n","CDC integral (ADC units, scaled), including pedestal, vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,100,0,IMAX);
217
218
219 cdc_ped = new TH1I("cdc_ped","CDC pedestal (ADC units);pedestal (ADC units)",(Int_t)(PMAX/2),0,PMAX);
220 cdc_ped_vs_n = new TH2I("cdc_ped_vs_n","CDC pedestal (ADC units) vs straw number;straw;pedestal (ADC units)",NSTRAWS,HALF,NSTRAWSPH,(Int_t)(PMAX/4),0,PMAX);
221
222
223
224 cdc_windata_ped = new TH1I("cdc_windata_ped","CDC pedestal (ADC units) from raw window data;pedestal (ADC units)",(Int_t)(PMAX/2),0,PMAX);
225 cdc_windata_ped_vs_n = new TH2I("cdc_windata_ped_vs_n","CDC pedestal (ADC units) from raw window data vs straw number;straw;pedestal (ADC units)",NSTRAWS,HALF,NSTRAWSPH,(Int_t)(PMAX/4),0,PMAX);
226
227
228
229
230 return NOERROR;
231}
232
233
234//----------------------------------------------------------------------------------
235
236
237jerror_t JEventProcessor_CDC_online::evnt(JEventLoop *eventLoop, uint64_t eventnumber) {
238 // This is called for every event. Use of common resources like writing
239 // to a file or filling a histogram should be mutex protected. Using
240 // loop-Get(...) to get reconstructed objects (and thereby activating the
241 // reconstruction algorithm) should be done outside of any mutex lock
242 // since multiple threads may call this method at the same time.
243
244
245 uint32_t tr,p,a; // dcdcdigihits raw quantities: time, pedestal, amplitude, quality factor, overflow count
246 uint32_t integral; // dcdcdigihits integral, includes pedestal
247 uint32_t integ; // dcdcdigihits integral minus pedestal
248
249 uint16_t ring,straw; // ring and straw numbers from either dcdchits or dcdcdigihits
250 uint16_t n; // straw number, 1 to 3522
251
252 uint32_t total_ped; //total pedestal during integration period
253
254 Bool_t PED_SUB; // if this is false, integration window info is missing, so don't plot integrals
255
256
257 uint32_t nsamples_integral=0; ///< number of samples used in integral
258 uint32_t nsamples_pedestal=0; ///< number of samples used in pedestal
259
260 const uint16_t NPEDSAMPLES=16;
261
262// Bool_t FoundRawData=kFALSE; //set true if found window raw data, present in mode 8 and raw mode
263
264 //add extra 0 at front to use offset[1] for ring 1
265 int straw_offset[29] = {0,0,42,84,138,192,258,324,404,484,577,670,776,882,1005,1128,1263,1398,1544,1690,1848,2006,2176,2346,2528,2710,2907,3104,3313};
266
267 // get raw data for cdc
268 vector<const DCDCDigiHit*> digihits;
269 eventLoop->Get(digihits);
270
271 //get WRD data for new format (until it is linked to CDCPulse)
272 vector<const Df125WindowRawData*> wrdvector;
273 eventLoop->Get(wrdvector);
274
275
276
277 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
278
279 if(digihits.size() > 0)
280 cdc_num_events->Fill(1);
281
282 for(uint32_t i=0; i<digihits.size(); i++) {
283
284 const DCDCDigiHit *digihit = digihits[i];
285
286 // Get pointers to the underlying objects of interest
287 const Df125PulseIntegral *pi = NULL__null;
288 const Df125PulsePedestal *pp = NULL__null;
289 const Df125WindowRawData *windat = NULL__null;
290 const Df125CDCPulse *cp = NULL__null;
291 const Df125Config *cf = NULL__null;
292
293 vector<uint16_t> samples;
294 uint32_t winped=0;
295
296
297
298 PED_SUB = kFALSE; //set this to true when we find the config params
299 total_ped = 0;
Value stored to 'total_ped' is never read
300 a = 0;
301
302 //get raw window data via pulse integral
303 digihit->GetSingle(pi);
304 if (pi) {
305 pi->GetSingle(windat);
306
307 nsamples_integral = pi ? pi->nsamples_integral : 0;
308 nsamples_pedestal = pi ? pi->nsamples_pedestal : 0;
309
310 if ((nsamples_integral > 0) && (nsamples_pedestal > 0)) PED_SUB = kTRUE;
311
312 } else if (i < (uint32_t)wrdvector.size()) {
313 windat = wrdvector[i];
314 }
315
316 //get amplitude from pulse peak in pulse pedestal
317 digihit->GetSingle(pp);
318 if (pp) a = pp->pulse_peak;
319
320 //get amplitude from CDCPulseData for new firmware
321 digihit->GetSingle(cp);
322 if (cp) a = cp->first_max_amp;
323
324 //get IE from Df125Config when available
325 digihit->GetSingle(cf);
326 if (cf) nsamples_integral = cf->IE - (int)(0.1*digihit->pulse_time);
327
328
329 ring = digihit->ring;
330 straw = digihit->straw;
331 n = straw_offset[ring] + straw;
332
333 if ((digihit->pulse_integral > 0)||(digihit->pulse_time > 0)) {
334
335 p = digihit->pedestal;
336 tr = digihit->pulse_time; // raw time in 0.8 ns units
337 integral = digihit->pulse_integral; // pulse integral in fadc units, pedestal not subtracted
338
339
340 cdc_o->Fill(straw,ring);
341
342 Double_t w = cdc_occ_ring[ring]->GetBinContent(straw, 1) + 1.0;
343 cdc_occ_ring[ring]->SetBinContent(straw, 1, w);
344
345
346 integ = 0;
347
348 //ok to use p for pedestal subtraction here because if fa250 algo fails with p=0, integral=0 and amplitude=0 also
349
350 if (PED_SUB) {
351 total_ped = p*nsamples_integral/nsamples_pedestal;
352 integ = integral - total_ped;
353 }
354
355 if (tr>0) {
356 cdc_raw_t->Fill(tr);
357 cdc_raw_t_vs_n->Fill(n,tr);
358 }
359
360
361 if (PED_SUB && (integ>0)) {
362 cdc_raw_int->Fill(integ);
363 cdc_raw_int_vs_n->Fill(n,integ);
364 }
365
366 if (integral>0) {
367 cdc_raw_intpp->Fill(integral);
368 cdc_raw_intpp_vs_n->Fill(n,integral);
369 }
370
371 if (p > 0) {
372 cdc_ped->Fill(p);
373 cdc_ped_vs_n->Fill(n,p);
374 }
375
376 if (a > 0) {
377 //a = a - p; //not subtracting pedestal as scaling factors may differ
378 cdc_raw_amp->Fill(a);
379 cdc_raw_amp_vs_n->Fill(n,a);
380 }
381
382
383 }
384
385 // get raw window data for cdc
386
387 if (windat) {
388
389 if (windat->samples.size()>=NPEDSAMPLES) {
390
391// FoundRawData = kTRUE;
392
393 winped = 0;
394
395 for (uint16_t i=0; i<NPEDSAMPLES; i++) winped += (uint32_t)windat->samples[i];
396
397 winped = (uint32_t)winped/16.0;
398
399 if (winped > 0) {
400 cdc_windata_ped->Fill(winped);
401 cdc_windata_ped_vs_n->Fill(n,winped);
402 }
403
404 }//sample size
405 } //windat
406
407 } //end of loop through digihits
408
409 japp->RootUnLock(); //RELEASE ROOT LOCK!!
410
411 //app->RootUnLock();
412
413 return NOERROR;
414}
415
416
417//----------------------------------------------------------------------------------
418
419
420jerror_t JEventProcessor_CDC_online::erun(void) {
421 // This is called whenever the run number changes, before it is
422 // changed to give you a chance to clean up before processing
423 // events from the next run number.
424 return NOERROR;
425}
426
427
428//----------------------------------------------------------------------------------
429
430
431jerror_t JEventProcessor_CDC_online::fini(void) {
432 // Called before program exit after event processing is finished.
433
434
435
436 return NOERROR;
437}
438
439
440//----------------------------------------------------------------------------------
441//----------------------------------------------------------------------------------