Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_CDC_expert_2.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_CDC_expert_2.cc
4 // Created: 26 Feb 2016
5 // Creator: Naomi Jarvis
6 
7 
8 #include <stdint.h>
9 #include <vector>
10 
11 #include <TMath.h>
12 
13 
15 
16 
17 //----------------------------------------------------------------------------------
18 
19 
20 // Routine used to create our JEventProcessor
21 extern "C"{
22  void InitPlugin(JApplication *app){
23  InitJANAPlugin(app);
24  app->AddProcessor(new JEventProcessor_CDC_expert_2());
25  }
26 }
27 
28 
29 //----------------------------------------------------------------------------------
30 
31 
33 }
34 
35 
36 //----------------------------------------------------------------------------------
37 
38 
40 }
41 
42 
43 //----------------------------------------------------------------------------------
44 
46 
47 
48  // raw quantities for read out (fa125 new format) are
49  // time field max 2047 scaled x 1, units 0.8ns
50  // time qf field max 1
51  // overflow count field max 7
52  // pedestal field max 255 scaled x 1/1
53  // max amplitude 9 bits field max 511 scaled x 1/8
54  // integral field max 16383 scaled x 1/16
55 
56 
57  // max values for histogram scales
58 
59  const Int_t IMAX = 100000; //max for raw integral
60  const Int_t IPPMAX = 150000; //max for raw integral + pedestal
61  const Int_t PMAX = 256; //max for pedestal, fa125-format, 8 bits
62  const Int_t AMAX = 4096; //max for amplitude, fa125-format, 9 bits * scale factor
63  const Int_t RTMAX = 1800; //max for raw time
64  const Int_t RTMIN = 160;
65  const Int_t RTBINS = 164; //bins
66 
67  const Int_t RTVSNMAX = 1024; //raw time vs straw histogram range ends at this value
68 
69  const Int_t EMAX = 21000; //max for E histograms, fC
70  // const Int_t EMAX = 21000000; //max for E histograms, fC
71  // E histograms filled with a_scale*gains*(integration-pedestal)
72 
73  const Int_t TMAX = 1250; //max for t histograms, ns
74  // t histograms filled with t_scale*(raw-t - offset) + tmin
75  const Int_t TMIN = -250;
76  const Int_t TBINS = 250;
77 
78 
79  const Int_t NSTRAWS = 3522;
80  const Float_t HALF = 0.5;
81  const Float_t NSTRAWSPH = 3522.5;
82 
83  //dead straws: K39 (row 11) and W38 (ring 23)
84 
85  Char_t deadstraws[32] = "(#709 and #2384 disconnected)"; //dead
86  Char_t deadrow11[30] = "(#39 disconnected)"; //dead
87  Char_t deadrow23[30] = "(#38 disconnected)"; //dead
88 
89 
90  // create root folder for cdc and cd to it, store main dir
91  TDirectory *main = gDirectory;
92 
93  gDirectory->mkdir("CDC_expert_2")->cd();
94  TDirectory *xd = gDirectory;
95 
96 
97  // book histograms
98 
99  //number of straws in each ring, starts with 0 so that straws[1] is the number of straws in ring 1
100  const Int_t straws[29] = {0,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};
101 
102 
103  cdc_e = new TH1D("cdc_e","CDC charge (fC);charge (fC)",200,0,EMAX);
104  cdc_e_vs_n = new TH2D("cdc_e_vs_n",Form("CDC charge (fC) vs straw number;straw %s;charge (fC)",deadstraws),NSTRAWS,HALF,NSTRAWSPH,100,0,EMAX);
105 
106  cdc_e_vs_t = new TH2D("cdc_e_vs_t","CDC charge (fC) vs time (ns);time (ns);charge (fC)",TBINS,TMIN,TMAX,100,0,EMAX);
107 
108 
109  cdc_t = new TH1D("cdc_t","CDC time (ns);time (ns)",TBINS*2,TMIN,TMAX);
110  cdc_t_vs_n = new TH2D("cdc_t_vs_n",Form("CDC time (ns) vs straw number;straw %s;time (ns)",deadstraws),NSTRAWS,HALF,NSTRAWSPH,TBINS,TMIN,TMAX);
111 
112 
113  cdc_rt = new TH1I("cdc_rt","CDC raw time (0.8ns);raw time (0.8ns)",RTMAX-RTMIN,RTMIN,RTMAX);
114  cdc_rt_qf0 = new TH1I("cdc_rt_qf0","CDC raw time with qf=0 (0.8ns);raw time (0.8ns)",RTMAX-RTMIN,RTMIN,RTMAX);
115  cdc_rt_vs_n = new TH2I("cdc_rt_vs_n",Form("CDC raw time (0.8ns) vs straw number;straw %s;raw time (0.8ns)",deadstraws),NSTRAWS,HALF,NSTRAWSPH,RTBINS,RTMIN,RTMAX);
116 
117 
118  cdc_amp = new TH1I("cdc_amp","CDC amplitude;amplitude",256,0,AMAX);
119  cdc_amp_vs_n = new TH2I("cdc_amp_vs_n",Form("CDC amplitude vs straw number;straw %s;amplitude",deadstraws),NSTRAWS,HALF,NSTRAWSPH,256,0,AMAX);
120 
121 
122 
123 
124 
125 
126  cdc_int_vs_raw_t = new TH2I("cdc_int_vs_raw_t",Form("CDC integral (ADC units), pedestal subtracted, vs raw time (0.8ns);raw time (0.8ns);integral, pedestal subtracted (ADC units)"),(Int_t)RTBINS,RTMIN,RTMAX,100,0,IMAX);
127 
128  cdc_what_is_n = new TH2I("cdc_what_is_n","CDC slot*100 + channel vs straw number, bin content=(rocid-24);straw;slot*100 + channel",NSTRAWS,HALF,NSTRAWSPH,1600,200+HALF,1800+HALF);
129 
130 
131  gDirectory->mkdir("pedestals_by_roc","CDC Pedestals for each ROC")->cd();
132 
133  cdc_initped_roc25 = new TH2I("cdc_initped_roc25","CDC pedestal (ADC units) from raw window data vs slot*100+channel, ROC 25;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
134  cdc_initped_roc26 = new TH2I("cdc_initped_roc26","CDC pedestal (ADC units) from raw window data vs slot*100+channel, ROC 26;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
135  cdc_initped_roc27 = new TH2I("cdc_initped_roc27","CDC pedestal (ADC units) from raw window data vs slot*100+channel, ROC 27;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
136  cdc_initped_roc28 = new TH2I("cdc_initped_roc28","CDC pedestal (ADC units) from raw window data vs slot*100+channel, ROC 28;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
137 
138  cdc_ped_roc25 = new TH2I("cdc_ped_roc25","CDC pedestal (ADC units) vs slot*100+channel, ROC 25;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
139  cdc_ped_roc26 = new TH2I("cdc_ped_roc26","CDC pedestal (ADC units) vs slot*100+channel, ROC 26;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
140  cdc_ped_roc27 = new TH2I("cdc_ped_roc27","CDC pedestal (ADC units) vs slot*100+channel, ROC 27;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
141  cdc_ped_roc28 = new TH2I("cdc_ped_roc28","CDC pedestal (ADC units) vs slot*100+channel, ROC 28;slot*100 + channel;pedestal",1600,200+HALF,1800+HALF,(Int_t)PMAX/4,0,PMAX);
142 
143  xd->cd();
144 
145  gDirectory->mkdir("amp_by_roc","CDC amplitudes for each ROC")->cd();
146 
147  cdc_amp_roc25 = new TH2I("cdc_amp_roc25","CDC amplitude (ADC units) vs slot*100+channel, ROC 25;slot*100 + channel;amplitude",1600,200+HALF,1800+HALF,256,0,AMAX);
148  cdc_amp_roc26 = new TH2I("cdc_amp_roc26","CDC amplitude (ADC units) vs slot*100+channel, ROC 26;slot*100 + channel;amplitude",1600,200+HALF,1800+HALF,256,0,AMAX);
149  cdc_amp_roc27 = new TH2I("cdc_amp_roc27","CDC amplitude (ADC units) vs slot*100+channel, ROC 27;slot*100 + channel;amplitude",1600,200+HALF,1800+HALF,256,0,AMAX);
150  cdc_amp_roc28 = new TH2I("cdc_amp_roc28","CDC amplitude (ADC units) vs slot*100+channel, ROC 28;slot*100 + channel;amplitude",1600,200+HALF,1800+HALF,256,0,AMAX);
151 
152  xd->cd();
153 
154 
155  gDirectory->mkdir("bad_t","CDC Bad time flagged")->cd();
156 
157  cdc_o_badt = new TH2I("cdc_o_badt","CDC occupancy by straw,ring, events with bad time flagged;straw;ring",209,0.5,209.5,28,0.5,28.5);
158  cdc_ped_badt = new TH1I("cdc_ped_badt","CDC pedestal, events with bad time flagged;straw;pedestal",256,0,PMAX);
159  cdc_raw_t_badt = new TH1I("cdc_raw_t_badt",Form("CDC raw time (0.8ns), events with bad time flagged;straw;raw time (0.8ns)"),RTBINS,RTMIN,RTMAX);
160  cdc_amp_badt = new TH1I("cdc_amp_badt","CDC amplitude (ADC units), events with bad time flagged;ADC units",256,0,AMAX);
161  //cdc_int_badt = new TH1I("cdc_int_badt","CDC integral (ADC units), pedestal subtracted, events with bad time flagged;ADC units",100,0,IMAX);
162  //cdc_intpp_badt = new TH1I("cdc_intpp_badt","CDC integral (ADC units), including pedestal, events with bad time flagged;ADC units",128,0,IPPMAX);
163 
164  cdc_qf = new TH1I("cdc_qf","CDC time quality factor;time quality factor (0:good, 1:zero, 2:hi ped, 3: below TH, 4:late TCL, 5: neg ups, 9:hi ups)",10,0,10);
165  cdc_qf_vs_n = new TH2I("cdc_qf_vs_n","CDC time quality factor vs straw number;straw;time quality factor",NSTRAWS,HALF,NSTRAWSPH,10,0,10);
166  cdc_qf_vs_a = new TH2I("cdc_qf_vs_a","CDC time quality factor vs amplitude;amplitude;time quality factor",128,0,AMAX,10,0,10);
167  cdc_qf_vs_rt = new TH2I("cdc_qf_vs_raw_t","CDC time quality factor vs raw time;time;time quality factor",RTBINS,RTMIN,RTMAX,10,0,10);
168 
169  xd->cd();
170 
171 
172  gDirectory->mkdir("overflows","CDC overflow flagged")->cd();
173 
174  cdc_o_overflow = new TH2I("cdc_o_overflow","CDC overflow occupancy by straw,ring;straw;ring",209,0.5,209.5,28,0.5,28.5);
175  cdc_ped_overflow = new TH1I("cdc_ped_overflow","CDC pedestal, events with ADC overflow;pedestal",256,0,PMAX);
176  cdc_raw_t_overflow = new TH1I("cdc_raw_t_overflow",Form("CDC raw time (0.8ns), events with ADC overflow;raw time (0.8ns)"),RTBINS,RTMIN,RTMAX);
177 
178  xd->cd();
179 
180 
181  Int_t i;
182 
183  gDirectory->mkdir("rings_e_vs_t","CDC rings: charge vs time")->cd();
184  for (i=1; i<29; i++) {
185  cdc_e_vs_t_ring[i] = new TH2D(Form("cdc_e_vs_t_ring[%i]",i),"CDC charge (fC) vs time (ns);time (ns);charge (fC)",TBINS,TMIN,TMAX,100,0,EMAX);
186  }
187  xd->cd();
188 
189 
190  gDirectory->mkdir("rings_int_vs_raw_t","CDC rings: integral vs raw time (pedestal subtracted)")->cd();
191  for (i=1; i<29; i++) {
192  cdc_int_vs_raw_t_ring[i] = new TH2I(Form("cdc_int_vs_raw_t_ring[%i]",i),Form("CDC integral (ADC units), pedestal subtracted, vs raw time (0.8ns);raw time (0.8ns);integral, pedestal subtracted (ADC units)"),RTBINS,RTMIN,RTMAX,100,0,IMAX);
193  }
194  xd->cd();
195 
196 
197  // gDirectory->mkdir("rings_e","CDC rings: charge vs straw")->cd();
198  // for (i=1; i<29; i++) {
199  // cdc_e_ring[i] = new TH2D(Form("cdc_e_ring[%i]",i),Form("CDC charge (fC), ring %i;straw;charge (fC)",i),straws[i],HALF,straws[i]+HALF,100,0,EMAX);
200  // }
201  // xd->cd();
202 
203 
204  gDirectory->mkdir("rings_t","CDC rings: time vs straw")->cd();
205  for (i=1; i<29; i++) {
206  cdc_t_ring[i] = new TH2D(Form("cdc_t_ring[%i]",i),Form("CDC time (ns), ring %i;straw;time (ns)",i),straws[i],HALF,straws[i]+HALF,TBINS,TMIN,TMAX);
207  }
208  cdc_t_ring[11]->GetXaxis()->SetTitle(Form("pedestal %s",deadrow11));
209  cdc_t_ring[23]->GetXaxis()->SetTitle(Form("pedestal %s",deadrow23));
210  xd->cd();
211 
212 
213  gDirectory->mkdir("rings_pedestal","CDC rings: pedestal vs straw")->cd();
214  for (i=1; i<29; i++) {
215  cdc_ped_ring[i] = new TH2I(Form("cdc_ped_ring[%i]",i),Form("CDC pedestal (ADC units), ring %i;straw;pedestal",i),straws[i],HALF,straws[i]+HALF,(Int_t)PMAX/2,0,PMAX);
216  }
217  cdc_ped_ring[11]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow11));
218  cdc_ped_ring[23]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow23));
219  xd->cd();
220 
221 
222  gDirectory->mkdir("rings_initpedestal","CDC rings: initial pedestal from raw window data vs straw")->cd();
223  for (i=1; i<29; i++) {
224  cdc_initped_ring[i] = new TH2I(Form("cdc_initped_ring[%i]",i),Form("CDC initial pedestal (ADC units) from raw window data, ring %i;straw;pedestal",i),straws[i],HALF,straws[i]+HALF,(Int_t)PMAX/2,0,PMAX);
225  }
226  cdc_initped_ring[11]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow11));
227  cdc_initped_ring[23]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow23));
228  xd->cd();
229 
230 
231 
232  gDirectory->mkdir("rings_raw_t","CDC rings: raw time vs straw")->cd();
233  for (i=1; i<29; i++) {
234  cdc_raw_t_ring[i] = new TH2I(Form("cdc_raw_t_ring[%i]",i),Form("CDC raw time (0.8ns), ring %i;straw;raw time (0.8ns)",i),straws[i],HALF,straws[i]+HALF,256,0,RTVSNMAX);
235  }
236  cdc_raw_t_ring[11]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow11));
237  cdc_raw_t_ring[23]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow23));
238  xd->cd();
239 
240 
241  gDirectory->mkdir("rings_amp","CDC rings: amplitude")->cd();
242  for (i=1; i<29; i++) {
243  cdc_amp_ring[i] = new TH2I(Form("cdc_amp_ring[%i]",i),Form("CDC amplitude (ADC units), ring %i",i),straws[i],HALF,straws[i]+HALF,256,0,AMAX);
244  }
245  cdc_amp_ring[11]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow11));
246  cdc_amp_ring[23]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow23));
247  xd->cd();
248 
249 
250  // gDirectory->mkdir("rings_integral","CDC rings: integral vs straw (pedestal subtracted)")->cd();
251  // for (i=1; i<29; i++) {
252  // cdc_int_ring[i] = new TH2I(Form("cdc_int_ring[%i]",i),Form("CDC integral (ADC units), pedestal subtracted, ring %i",i),straws[i],HALF,straws[i]+HALF,128,0,IMAX);
253  // }
254  // xd->cd();
255 
256 
257  gDirectory->mkdir("rings_integral_incl_ped","CDC rings: integral vs straw (including pedestal)")->cd();
258  for (i=1; i<29; i++) {
259  cdc_intpp_ring[i] = new TH2I(Form("cdc_intpp_ring[%i]",i),Form("CDC integral (ADC units), including pedestal, ring %i",i),straws[i],HALF,straws[i]+HALF,100,0,IPPMAX);
260  }
261  cdc_intpp_ring[11]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow11));
262  cdc_intpp_ring[23]->GetXaxis()->SetTitle(Form("Straw number, %s",deadrow23));
263 
264 
265 
266 
267  main->cd(); // back to main
268 
269  return NOERROR;
270 
271 
272 }
273 
274 
275 //----------------------------------------------------------------------------------
276 
277 
278 jerror_t JEventProcessor_CDC_expert_2::brun(JEventLoop *eventLoop, int32_t runnumber) {
279  // This is called whenever the run number changes
280 
281  return NOERROR;
282 
283 }
284 
285 
286 //----------------------------------------------------------------------------------
287 
288 
289 jerror_t JEventProcessor_CDC_expert_2::evnt(JEventLoop *eventLoop, uint64_t eventnumber) {
290  // This is called for every event. Use of common resources like writing
291  // to a file or filling a histogram should be mutex protected. Using
292  // loop-Get(...) to get reconstructed objects (and thereby activating the
293  // reconstruction algorithm) should be done outside of any mutex lock
294  // since multiple threads may call this method at the same time.
295 
296  float q,t; // dcdchits quantities charge, time
297 
298  uint32_t rocid;
299  uint32_t slot;
300  uint32_t channel;
301 
302  uint16_t ring,straw; // ring and straw numbers from either dcdchits or dcdcdigihits
303  uint16_t n; // straw number, 1 to 3522
304 
305  uint32_t qf,ocount; // time quality factor and overflow count from new firmware
306  uint32_t rt,p,a; // dcdcdigihits raw quantities: time, pedestal, amplitude
307  uint32_t integral; // dcdcdigihits integral, includes pedestal
308  uint32_t integ; // dcdcdigihits integral minus pedestal
309 
310  uint16_t originalq; //last digit of le_time if qf=1
311 
312  uint32_t initped; //pedestal calculated from WRD at start of window
313 
314  // default scaling factors will be overridden by Df125Config if present
315  uint16_t ISCALE = 16; //scaling factor for integral
316  uint16_t ASCALE = 8; //amplitude
317  uint16_t PSCALE = 1; //ped
318  uint16_t NW = 200;
319  uint16_t IE = 200;
320 
321 
322  const uint16_t NPEDSAMPLES=16; //number of samples to use for initial pedestal initped calculated from window raw data if present
323 
324  //add extra 0 at front to use offset[1] for ring 1
325  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};
326 
327  const DTrigger* locTrigger = NULL;
328  eventLoop->GetSingle(locTrigger);
329  if(locTrigger->Get_L1FrontPanelTriggerBits() != 0)
330  return NOERROR;
331 
332  if (!locTrigger->Get_IsPhysicsEvent()){ // do not look at PS triggers
333  return NOERROR;
334  }
335 
336  //first set of histograms is for dcdchits, these are t and q after calibration
337  //second set is for dcdcdigihits, these are the raw quantities
338 
339  // get hit data for cdc
340  vector<const DCDCHit*> hits;
341  eventLoop->Get(hits);
342 
343  // get raw data for cdc
344  vector<const DCDCDigiHit*> digihits;
345  eventLoop->Get(digihits);
346 
347 
348  japp->RootFillLock(this); //ACQUIRE ROOT LOCK!!
349 
350 
351 
352  for (uint32_t i=0; i<hits.size(); i++) {
353 
354  const DCDCHit *hit = hits[i];
355 
356  if (hit->q>0.0) {
357 
358  q = hit->q; // in fC
359  t = hit->t; // in nanoseconds
360  ring = hit->ring;
361  straw = hit->straw;
362 
363  n = straw_offset[ring] + straw;
364 
365  if (q > 0.0) {
366  cdc_e->Fill(q);
367  cdc_e_vs_n->Fill(n,q);
368  }
369 
370  cdc_t->Fill(t);
371  cdc_t_vs_n->Fill(n,t);
372 
373  cdc_e_vs_t->Fill(t,q);
374  cdc_e_vs_t_ring[ring]->Fill(t,q);
375 
376  //cdc_e_ring[ring]->Fill(straw,q);
377  cdc_t_ring[ring]->Fill(straw,t);
378  }
379  }
380 
381 
382 
383  const DCDCDigiHit *digihit = NULL;
384  const Df125CDCPulse *cp = NULL;
385  const Df125WindowRawData *wrd = NULL;
386  const Df125Config *cf = NULL;
387 
388  for (uint32_t i=0; i<digihits.size(); i++) {
389 
390  digihit = digihits[i];
391 
392  ring = digihit->ring;
393  straw = digihit->straw;
394 
395  n = straw_offset[ring] + straw;
396 
397  originalq = 0;
398 
399  //new firmware uses Df125CDCPulseData
400 
401  cp = NULL;
402  digihit->GetSingle(cp);
403 
404  if (!cp) continue; //no CDCPulseData (happens occasionally)
405 
406  cp->GetSingle(cf);
407  if (cf) {
408  ISCALE = 1<<cf->IBIT;
409  ASCALE = 1<<cf->ABIT;
410  PSCALE = 1<<cf->PBIT;
411 
412  NW = cf->NW;
413  IE = cf->IE;
414 
415  }
416 
417  rocid = cp->rocid;
418  slot = cp->slot;
419  channel = cp->channel;
420 
421  rt = cp->le_time;
422  qf = cp->time_quality_bit;
423  ocount = cp->overflow_count;
424 
425  a = ASCALE*cp->first_max_amp;
426  p = PSCALE*cp->pedestal;
427  integral = ISCALE*cp->integral;
428 
429 
430  int lastsample = NW-20-1; //eg sample 179 is the last sample integrated for NW=200
431  int timesample = int(0.1*rt);
432  if (timesample+IE < lastsample) lastsample = timesample+IE;
433 
434  int pulselength = 1 + lastsample - timesample;
435 
436  integ = integral - p*pulselength;
437 
438  if (qf==0) {
439 
440  originalq = 0;
441 
442  cdc_rt_qf0->Fill(rt);
443 
444  } else {
445 
446  originalq = rt - 10*int(0.1*rt);
447 
448  cdc_qf_vs_n->Fill(n,originalq);
449  cdc_qf_vs_a->Fill(a,originalq);
450  cdc_qf_vs_rt->Fill(rt,originalq);
451 
452  cdc_o_badt->Fill(straw,ring);
453  cdc_ped_badt->Fill(p);
454  cdc_raw_t_badt->Fill(rt);
455  cdc_amp_badt->Fill(a);
456 
457  //cdc_int_badt->Fill(integ);
458  //cdc_intpp_badt->Fill(integral);
459 
460  }
461 
462  cdc_qf->Fill(originalq);
463 
464  cdc_rt->Fill(rt);
465  cdc_rt_vs_n->Fill(n,rt);
466 
467  cdc_amp->Fill(a);
468  cdc_amp_vs_n->Fill(n,a);
469 
470  cdc_int_vs_raw_t->Fill(rt,integ);
471  cdc_int_vs_raw_t_ring[ring]->Fill(rt,integ);
472 
473  cdc_ped_ring[ring]->Fill(straw,p);
474  cdc_raw_t_ring[ring]->Fill(straw,rt);
475  cdc_amp_ring[ring]->Fill(straw,a); //no ped subtraction
476  //cdc_int_ring[ring]->Fill(straw,integ);
477  cdc_intpp_ring[ring]->Fill(straw,integral);
478 
479 
480 
481  if (ocount>0) { // overflow samples present
482  cdc_o_overflow->Fill(straw,ring);
483  cdc_ped_overflow->Fill(p);
484  cdc_raw_t_overflow->Fill(rt);
485  }
486 
487 
488  if (rocid == 25) cdc_ped_roc25->Fill(100*slot + channel,p);
489  if (rocid == 26) cdc_ped_roc26->Fill(100*slot + channel,p);
490  if (rocid == 27) cdc_ped_roc27->Fill(100*slot + channel,p);
491  if (rocid == 28) cdc_ped_roc28->Fill(100*slot + channel,p);
492 
493 
494  if (rocid == 25) cdc_amp_roc25->Fill(100*slot + channel,a);
495  if (rocid == 26) cdc_amp_roc26->Fill(100*slot + channel,a);
496  if (rocid == 27) cdc_amp_roc27->Fill(100*slot + channel,a);
497  if (rocid == 28) cdc_amp_roc28->Fill(100*slot + channel,a);
498 
499 
500  cdc_what_is_n->SetBinContent(cdc_what_is_n->FindBin(n,100*slot + channel),rocid-24);
501 
502 
503  // initial pedestals from window raw data samples if available
504 
505  wrd = NULL;
506  cp->GetSingle(wrd);
507  if (!wrd) continue;
508 
509 
510  initped=0;
511 
512  if (wrd->samples.size()>=NPEDSAMPLES) {
513 
514  for (uint16_t j=0; j<NPEDSAMPLES; j++) initped += (uint32_t)wrd->samples[j];
515 
516  initped = (uint32_t)initped/16.0;
517 
518  if (initped > 0) {
519 
520  if (rocid == 25) cdc_initped_roc25->Fill(100*slot + channel,initped);
521  if (rocid == 26) cdc_initped_roc26->Fill(100*slot + channel,initped);
522  if (rocid == 27) cdc_initped_roc27->Fill(100*slot + channel,initped);
523  if (rocid == 28) cdc_initped_roc28->Fill(100*slot + channel,initped);
524 
525  }
526 
527  }
528 
529  if (initped) cdc_initped_ring[ring]->Fill(straw,initped);
530 
531  } //end for each digihit
532 
533 
534  japp->RootFillUnLock(this); //RELEASE ROOT LOCK!!
535 
536 
537  return NOERROR;
538 }
539 
540 
541 //----------------------------------------------------------------------------------
542 
543 
545  // This is called whenever the run number changes, before it is
546  // changed to give you a chance to clean up before processing
547  // events from the next run number.
548  return NOERROR;
549 }
550 
551 
552 //----------------------------------------------------------------------------------
553 
554 
556  // Called before program exit after event processing is finished.
557  return NOERROR;
558 }
559 
560 
561 //----------------------------------------------------------------------------------
562 //----------------------------------------------------------------------------------
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
uint32_t first_max_amp
from second word
Definition: Df125CDCPulse.h:68
jerror_t init(void)
Called once at program start.
uint16_t IBIT
Definition: Df125Config.h:44
const double PMAX
uint32_t pedestal
from second word
Definition: Df125CDCPulse.h:66
uint16_t PBIT
Definition: Df125Config.h:46
uint16_t IE
Definition: Df125Config.h:40
uint16_t ABIT
Definition: Df125Config.h:45
uint32_t Get_L1FrontPanelTriggerBits(void) const
uint32_t overflow_count
from first word
Definition: Df125CDCPulse.h:65
JApplication * japp
uint32_t le_time
from first word
Definition: Df125CDCPulse.h:63
bool Get_IsPhysicsEvent(void) const
float t
Definition: DCDCHit.h:22
InitPlugin_t InitPlugin
jerror_t fini(void)
Called after last event of last event source has been processed.
vector< uint16_t > samples
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
int ring
Definition: DCDCHit.h:18
uint32_t time_quality_bit
from first word
Definition: Df125CDCPulse.h:64
float q
Definition: DCDCHit.h:20
uint16_t NW
Definition: Df125Config.h:35
const double TMAX
uint32_t channel
Definition: DDAQAddress.h:34
const double TMIN
uint32_t rocid
Definition: DDAQAddress.h:32
const double TBINS
uint32_t integral
from second word
Definition: Df125CDCPulse.h:67
TCanvas * cp
int straw
Definition: DCDCHit.h:19
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
int main(int argc, char *argv[])
Definition: gendoc.cc:6
uint32_t slot
Definition: DDAQAddress.h:33