Bug Summary

File:plugins/monitoring/CDC_online/JEventProcessor_CDC_online.cc
Location:line 300, 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 initialized_histograms = false;
80}
81
82
83//----------------------------------------------------------------------------------
84
85
86JEventProcessor_CDC_online::~JEventProcessor_CDC_online() {
87}
88
89
90//----------------------------------------------------------------------------------
91
92jerror_t JEventProcessor_CDC_online::init(void) {
93
94 // I moved all the histogram setup into the brun so that I can use different
95 // scales for the later runs using the new firmware
96
97
98 // create root folder for cdc and cd to it, store main dir
99 TDirectory *main = gDirectory(TDirectory::CurrentDirectory());
100 gDirectory(TDirectory::CurrentDirectory())->mkdir("CDC")->cd();
101
102
103 cdc_num_events = new TH1I("cdc_num_events","CDC number of events",1, 0.5, 1.5);
104
105 cdc_o = new TH2I("cdc_o","CDC occupancy by straw, ring;straw;ring",209,0.5,209.5,28,0.5,28.5);
106
107
108 gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_occupancy","CDC rings: occupancy")->cd();
109
110
111 // Hit occupancy
112 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};
113 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};
114 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};
115
116 // Define a different 2D histogram for each ring. X-axis is phi, Y-axis is radius (to plot correctly with "pol" option)
117 for(int iring=0; iring<28; iring++){
118 double r_start = radius[iring] - 0.8;
119 double r_end = radius[iring] + 0.8;
120 double phi_start = phi[iring]; // this is for center of straw. Need additional calculation for phi at end plate
121 double phi_end = phi_start + TMath::TwoPi();
122
123 char hname[256];
124 sprintf(hname, "cdc_occ_ring[%d]", iring+1);
125 cdc_occ_ring[iring+1] = new TH2D(hname, "", Nstraws[iring], phi_start, phi_end, 1, r_start, r_end);
126 }
127
128
129 // back to main dir
130 main->cd();
131
132
133 return NOERROR;
134}
135
136
137//----------------------------------------------------------------------------------
138
139
140jerror_t JEventProcessor_CDC_online::brun(JEventLoop *eventLoop, int32_t runnumber) {
141 // This is called whenever the run number changes
142
143 // max values for histogram scales, modified fa250-format readout
144
145
146 Int_t AMAX = 4096; //max for amplitude, fa250-format, 12 bits
147
148 // Int_t IMAX = 524288; //max for raw integral, fa250-format, 19 bits
149 Int_t IMAX = 400000; //max for raw integral, fa250-format, 19 bits
150
151 Int_t PMAX = 512; //max for pedestal, fa250-format max is 512
152 // Int_t RTMAX = 32768; //max for raw time, fa250-format, 15 bits
153 Int_t RTMAX = 12000; //max for raw time, less than full field width
154
155 Char_t rtunits[8] = "0.125ns"; //raw time is in units of sample/64 = ns/8
156
157
158
159 if (runnumber > 3675) { //new fa125 format firmware, from 11 Sept 2015
160
161
162 // raw quantities for read out (125 format) are
163 // time field max 2047 scaled x 1, units 0.8ns
164 // time qf field max 1
165 // overflow count field max 7
166 // pedestal field max 255 scaled x 1/1 initially
167 // max amplitude 9 bits, field max 511 scaled x 1/8
168 // integral field max 16383 scaled x 1/16
169
170 // max values for histogram scales, fa125-format readout
171
172 IMAX = 16384; //max for raw integral, fa125-format, 14 bits
173 PMAX = 256; //max for pedestal, fa125-format, 8 bits
174 RTMAX = 2048; //max for raw time, fa125-format, 11 bits
175 AMAX = 512; //max for amplitude, fa125-format, 9 bits
176
177 sprintf(rtunits,"0.8ns"); //raw time is in units of sample/10 = 0.8ns
178
179 }
180
181
182 const Int_t NSTRAWS = 3522;
183 const Float_t HALF = 0.5;
184 const Float_t NSTRAWSPH = 3522.5;
185
186 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
187
188 if(initialized_histograms) //don't init twice!
189 {
190 japp->RootUnLock(); //RELEASE ROOT LOCK
191 return NOERROR;
192 }
193
194 gDirectory(TDirectory::CurrentDirectory())->cd("CDC");
195
196 // book histograms
197
198 cdc_raw_amp = new TH1I("cdc_raw_amp","CDC amplitude (ADC units, scaled); ADC units",AMAX,0,AMAX);
199
200 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);
201
202 cdc_raw_t = new TH1I("cdc_raw_t",Form("CDC raw time (units of %s); raw time (%s)",rtunits,rtunits),200,0,RTMAX);
203
204 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);
205
206 cdc_raw_int = new TH1I("cdc_raw_int","CDC integral (ADC units, scaled), pedestal subtracted; ADC units",200,0,IMAX);
207
208 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);
209
210 cdc_raw_intpp = new TH1I("cdc_raw_intpp","CDC integral (ADC units, scaled), includes pedestal; ADC units",200,0,IMAX);
211
212 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);
213
214 cdc_ped = new TH1I("cdc_ped","CDC pedestal (ADC units);pedestal (ADC units)",(Int_t)(PMAX/2),0,PMAX);
215
216 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);
217
218 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);
219
220 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);
221
222 gDirectory(TDirectory::CurrentDirectory())->cd(".."); //RETURN TO MAIN FOLDER
223
224 initialized_histograms = true;
225
226 japp->RootUnLock(); //RELEASE ROOT LOCK
227
228
229 return NOERROR;
230}
231
232
233//----------------------------------------------------------------------------------
234
235
236jerror_t JEventProcessor_CDC_online::evnt(JEventLoop *eventLoop, uint64_t eventnumber) {
237 // This is called for every event. Use of common resources like writing
238 // to a file or filling a histogram should be mutex protected. Using
239 // loop-Get(...) to get reconstructed objects (and thereby activating the
240 // reconstruction algorithm) should be done outside of any mutex lock
241 // since multiple threads may call this method at the same time.
242
243
244 uint32_t tr,p,a; // dcdcdigihits raw quantities: time, pedestal, amplitude, quality factor, overflow count
245 uint32_t integral; // dcdcdigihits integral, includes pedestal
246 uint32_t integ; // dcdcdigihits integral minus pedestal
247
248 uint16_t ring,straw; // ring and straw numbers from either dcdchits or dcdcdigihits
249 uint16_t n; // straw number, 1 to 3522
250
251 uint32_t total_ped; //total pedestal during integration period
252
253 Bool_t PED_SUB; // if this is false, integration window info is missing, so don't plot integrals
254
255
256 uint32_t nsamples_integral=0; ///< number of samples used in integral
257 uint32_t nsamples_pedestal=0; ///< number of samples used in pedestal
258
259 const uint16_t NPEDSAMPLES=16;
260
261// Bool_t FoundRawData=kFALSE; //set true if found window raw data, present in mode 8 and raw mode
262
263 //add extra 0 at front to use offset[1] for ring 1
264 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};
265
266 // get raw data for cdc
267 vector<const DCDCDigiHit*> digihits;
268 eventLoop->Get(digihits);
269
270 //get WRD data for new format (until it is linked to CDCPulse)
271 vector<const Df125WindowRawData*> wrdvector;
272 eventLoop->Get(wrdvector);
273
274
275
276 // FILL HISTOGRAMS
277 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
278 japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
279
280 if(digihits.size() > 0)
281 cdc_num_events->Fill(1);
282
283 for(uint32_t i=0; i<digihits.size(); i++) {
284
285 const DCDCDigiHit *digihit = digihits[i];
286
287 // Get pointers to the underlying objects of interest
288 const Df125PulseIntegral *pi = NULL__null;
289 const Df125PulsePedestal *pp = NULL__null;
290 const Df125WindowRawData *windat = NULL__null;
291 const Df125CDCPulse *cp = NULL__null;
292 const Df125Config *cf = NULL__null;
293
294 vector<uint16_t> samples;
295 uint32_t winped=0;
296
297
298
299 PED_SUB = kFALSE; //set this to true when we find the config params
300 total_ped = 0;
Value stored to 'total_ped' is never read
301 a = 0;
302
303 //get raw window data via pulse integral
304 digihit->GetSingle(pi);
305 if (pi) {
306 pi->GetSingle(windat);
307
308 nsamples_integral = pi ? pi->nsamples_integral : 0;
309 nsamples_pedestal = pi ? pi->nsamples_pedestal : 0;
310
311 if ((nsamples_integral > 0) && (nsamples_pedestal > 0)) PED_SUB = kTRUE;
312
313 } else if (i < (uint32_t)wrdvector.size()) {
314 windat = wrdvector[i];
315 }
316
317 //get amplitude from pulse peak in pulse pedestal
318 digihit->GetSingle(pp);
319 if (pp) a = pp->pulse_peak;
320
321 //get amplitude from CDCPulseData for new firmware
322 digihit->GetSingle(cp);
323 if (cp) a = cp->first_max_amp;
324
325 //get IE from Df125Config when available
326 digihit->GetSingle(cf);
327 if (cf) nsamples_integral = cf->IE - (int)(0.1*digihit->pulse_time);
328
329
330 ring = digihit->ring;
331 straw = digihit->straw;
332 n = straw_offset[ring] + straw;
333
334 if ((digihit->pulse_integral > 0)||(digihit->pulse_time > 0)) {
335
336 p = digihit->pedestal;
337 tr = digihit->pulse_time; // raw time in 0.8 ns units
338 integral = digihit->pulse_integral; // pulse integral in fadc units, pedestal not subtracted
339
340
341 cdc_o->Fill(straw,ring);
342
343 Double_t w = cdc_occ_ring[ring]->GetBinContent(straw, 1) + 1.0;
344 cdc_occ_ring[ring]->SetBinContent(straw, 1, w);
345
346
347 integ = 0;
348
349 //ok to use p for pedestal subtraction here because if fa250 algo fails with p=0, integral=0 and amplitude=0 also
350
351 if (PED_SUB) {
352 total_ped = p*nsamples_integral/nsamples_pedestal;
353 integ = integral - total_ped;
354 }
355
356 if (tr>0) {
357 cdc_raw_t->Fill(tr);
358 cdc_raw_t_vs_n->Fill(n,tr);
359 }
360
361
362 if (PED_SUB && (integ>0)) {
363 cdc_raw_int->Fill(integ);
364 cdc_raw_int_vs_n->Fill(n,integ);
365 }
366
367 if (integral>0) {
368 cdc_raw_intpp->Fill(integral);
369 cdc_raw_intpp_vs_n->Fill(n,integral);
370 }
371
372 if (p > 0) {
373 cdc_ped->Fill(p);
374 cdc_ped_vs_n->Fill(n,p);
375 }
376
377 if (a > 0) {
378 //a = a - p; //not subtracting pedestal as scaling factors may differ
379 cdc_raw_amp->Fill(a);
380 cdc_raw_amp_vs_n->Fill(n,a);
381 }
382
383
384 }
385
386 // get raw window data for cdc
387
388 if (windat) {
389
390 if (windat->samples.size()>=NPEDSAMPLES) {
391
392// FoundRawData = kTRUE;
393
394 winped = 0;
395
396 for (uint16_t i=0; i<NPEDSAMPLES; i++) winped += (uint32_t)windat->samples[i];
397
398 winped = (uint32_t)winped/16.0;
399
400 if (winped > 0) {
401 cdc_windata_ped->Fill(winped);
402 cdc_windata_ped_vs_n->Fill(n,winped);
403 }
404
405 }//sample size
406 } //windat
407
408 } //end of loop through digihits
409
410 japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
411
412 return NOERROR;
413}
414
415
416//----------------------------------------------------------------------------------
417
418
419jerror_t JEventProcessor_CDC_online::erun(void) {
420 // This is called whenever the run number changes, before it is
421 // changed to give you a chance to clean up before processing
422 // events from the next run number.
423 return NOERROR;
424}
425
426
427//----------------------------------------------------------------------------------
428
429
430jerror_t JEventProcessor_CDC_online::fini(void) {
431 // Called before program exit after event processing is finished.
432
433
434
435 return NOERROR;
436}
437
438
439//----------------------------------------------------------------------------------
440//----------------------------------------------------------------------------------