Bug Summary

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