Bug Summary

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