1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | #include <stdint.h> |
9 | #include <vector> |
10 | |
11 | #include <TMath.h> |
12 | |
13 | |
14 | #include "JEventProcessor_CDC_expert.h" |
15 | #include <JANA/JApplication.h> |
16 | |
17 | |
18 | using namespace std; |
19 | using 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 | |
29 | #include <TDirectory.h> |
30 | #include <TH2.h> |
31 | #include <TH1.h> |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | static TH1D *cdc_e = NULL__null; |
39 | static TH2D *cdc_e_vs_n = NULL__null; |
40 | |
41 | static TH1D *cdc_t = NULL__null; |
42 | static TH2D *cdc_t_vs_n = NULL__null; |
43 | |
44 | |
45 | static TH2D *cdc_e_ring[29]; |
46 | static TH2D *cdc_t_ring[29]; |
47 | |
48 | |
49 | static TH2D *cdc_e_vs_t; |
50 | static TH2D *cdc_e_vs_t_ring[29]; |
51 | |
52 | static TH2I *cdc_raw_int_vs_t; |
53 | static TH2I *cdc_raw_int_vs_t_ring[29]; |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | static TH2I *cdc_ped_ring[29]; |
60 | |
61 | |
62 | |
63 | static TH2I *cdc_windata_ped_ring[29]; |
64 | |
65 | static TH2I *cdc_windata_ped_roc25; |
66 | static TH2I *cdc_windata_ped_roc26; |
67 | static TH2I *cdc_windata_ped_roc27; |
68 | static TH2I *cdc_windata_ped_roc28; |
69 | |
70 | static TH2I *cdc_raw_t_ring[29]; |
71 | |
72 | |
73 | |
74 | static TH2I *cdc_raw_amp_ring[29]; |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | static TH2I *cdc_raw_intpp_ring[29]; |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | static TH2I *cdc_raw_int_ring[29]; |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | extern "C"{ |
98 | void InitPlugin(JApplication *app){ |
99 | InitJANAPlugin(app); |
100 | app->AddProcessor(new JEventProcessor_CDC_expert()); |
101 | } |
102 | } |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | JEventProcessor_CDC_expert::JEventProcessor_CDC_expert() { |
109 | } |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | JEventProcessor_CDC_expert::~JEventProcessor_CDC_expert() { |
116 | } |
117 | |
118 | |
119 | |
120 | |
121 | jerror_t JEventProcessor_CDC_expert::init(void) { |
122 | |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | const Int_t IMAX = 400000; |
132 | const Int_t PMAX = 512; |
133 | |
134 | const Char_t rtunits[8] = "0.125ns"; |
135 | |
136 | const Int_t RTVSNMAX = 8192; |
137 | |
138 | const Int_t AMAX = 4096; |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | const Int_t EMAX = 21000000; |
165 | |
166 | |
167 | const Int_t TMAX = 1500; |
168 | |
169 | |
170 | |
171 | const Int_t NSTRAWS = 3522; |
172 | const Float_t HALF = 0.5; |
173 | const Float_t NSTRAWSPH = 3522.5; |
174 | |
175 | japp->RootWriteLock(); |
176 | |
177 | |
178 | TDirectory *main = gDirectory(TDirectory::CurrentDirectory()); |
179 | gDirectory(TDirectory::CurrentDirectory())->mkdir("CDC_expert")->cd(); |
180 | |
181 | |
182 | |
183 | |
184 | |
185 | 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}; |
186 | |
187 | |
188 | cdc_e = new TH1D("cdc_e","CDC charge (fC);charge (fC)",200,0,EMAX); |
189 | cdc_e_vs_n = new TH2D("cdc_e_vs_n","CDC charge (fC) vs straw number;straw;charge (fC)",NSTRAWS,HALF,NSTRAWSPH,100,0,EMAX); |
190 | |
191 | cdc_e_vs_t = new TH2D("cdc_e_vs_t","CDC charge (fC) vs time (ns);time (ns);charge (fC)",150,-250,TMAX,100,0,EMAX); |
192 | |
193 | |
194 | cdc_t = new TH1D("cdc_t","CDC time (ns);time (ns)",300,-250,TMAX); |
195 | cdc_t_vs_n = new TH2D("cdc_t_vs_n","CDC time (ns) vs straw number;straw;time (ns)",NSTRAWS,HALF,NSTRAWSPH,150,-250,TMAX); |
196 | |
197 | |
198 | |
199 | |
200 | cdc_raw_int_vs_t = new TH2I("cdc_raw_int_vs_t",Form("CDC integral (ADC units), pedestal subtracted, vs raw time (units of %s);time (%s);integral, pedestal subtracted (ADC units)",rtunits,rtunits),(Int_t)256,0,RTVSNMAX,100,0,IMAX); |
201 | |
202 | |
203 | |
204 | cdc_windata_ped_roc25 = new TH2I("cdc_windata_ped_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); |
205 | cdc_windata_ped_roc26 = new TH2I("cdc_windata_ped_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); |
206 | cdc_windata_ped_roc27 = new TH2I("cdc_windata_ped_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); |
207 | cdc_windata_ped_roc28 = new TH2I("cdc_windata_ped_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); |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | Int_t i; |
237 | |
238 | |
239 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_e_vs_t","CDC rings: charge vs time")->cd(); |
240 | |
241 | for (i=1; i<29; i++) { |
242 | 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)",150,0,TMAX,100,0,EMAX); |
243 | } |
244 | |
245 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
246 | |
247 | |
248 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_int_vs_raw_t","CDC rings: integral vs raw time (pedestal subtracted)")->cd(); |
249 | |
250 | for (i=1; i<29; i++) { |
251 | cdc_raw_int_vs_t_ring[i] = new TH2I(Form("cdc_raw_int_vs_t_ring[%i]",i),Form("CDC integral (ADC units), pedestal subtracted, vs raw time (%s);raw time (%s);integral, pedestal subtracted (ADC units)",rtunits,rtunits),256,0,RTVSNMAX,100,0,IMAX); |
252 | |
253 | } |
254 | |
255 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
256 | |
257 | |
258 | |
259 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_e","CDC rings: charge vs straw")->cd(); |
260 | |
261 | for (i=1; i<29; i++) { |
262 | 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); |
263 | } |
264 | |
265 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
266 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings__t","CDC rings: time vs straw")->cd(); |
267 | |
268 | for (i=1; i<29; i++) { |
269 | 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,150,0,TMAX); |
270 | } |
271 | |
272 | |
273 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
274 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_pedestal","CDC rings: pedestal vs straw")->cd(); |
275 | |
276 | for (i=1; i<29; i++) { |
277 | 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); |
278 | } |
279 | |
280 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
281 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_windata_pedestal","CDC rings: pedestal from raw window data vs straw")->cd(); |
282 | |
283 | for (i=1; i<29; i++) { |
284 | cdc_windata_ped_ring[i] = new TH2I(Form("cdc_windata_ped_ring[%i]",i),Form("CDC pedestal (ADC units) from raw window data, ring %i;straw;pedestal",i),straws[i],HALF,straws[i]+HALF,(Int_t)PMAX/2,0,PMAX); |
285 | } |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
292 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_raw_t","CDC rings: raw time vs straw")->cd(); |
293 | |
294 | for (i=1; i<29; i++) { |
295 | cdc_raw_t_ring[i] = new TH2I(Form("cdc_raw_t_ring[%i]",i),Form("CDC raw time (units of %s), ring %i;straw;raw time (%s)",rtunits,i,rtunits),straws[i],HALF,straws[i]+HALF,256,0,RTVSNMAX); |
296 | } |
297 | |
298 | |
299 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
300 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_raw_amp","CDC rings: amplitude")->cd(); |
301 | |
302 | for (i=1; i<29; i++) { |
303 | cdc_raw_amp_ring[i] = new TH2I(Form("cdc_raw_amp_ring[%i]",i),Form("CDC amplitude (ADC units), ring %i",i),straws[i],HALF,straws[i]+HALF,256,0,AMAX); |
304 | } |
305 | |
306 | |
307 | |
308 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
309 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_raw_integral","CDC rings: integral vs straw (pedestal subtracted)")->cd(); |
310 | |
311 | for (i=1; i<29; i++) { |
312 | cdc_raw_int_ring[i] = new TH2I(Form("cdc_raw_int_ring[%i]",i),Form("CDC integral (ADC units), pedestal subtracted, ring %i",i),straws[i],HALF,straws[i]+HALF,100,0,IMAX); |
313 | } |
314 | |
315 | |
316 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
317 | gDirectory(TDirectory::CurrentDirectory())->mkdir("rings_raw_integral_incl_ped","CDC rings: integral vs straw (including pedestal)")->cd(); |
318 | |
319 | for (i=1; i<29; i++) { |
320 | cdc_raw_intpp_ring[i] = new TH2I(Form("cdc_raw_intpp_ring[%i]",i),Form("CDC integral (ADC units), including pedestal, ring %i",i),straws[i],HALF,straws[i]+HALF,100,0,IMAX); |
321 | } |
322 | |
323 | |
324 | |
325 | |
326 | main->cd(); |
327 | |
328 | japp->RootUnLock(); |
329 | |
330 | |
331 | return NOERROR; |
332 | } |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | jerror_t JEventProcessor_CDC_expert::brun(JEventLoop *eventLoop, int runnumber) { |
339 | |
340 | return NOERROR; |
341 | } |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | jerror_t JEventProcessor_CDC_expert::evnt(JEventLoop *eventLoop, int eventnumber) { |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | float q,t; |
355 | |
356 | |
357 | uint32_t tr,p,a; |
358 | uint32_t integral; |
359 | uint32_t integ; |
360 | |
361 | uint16_t ring,straw; |
362 | uint16_t n; |
363 | |
364 | Bool_t PED_SUB; |
365 | |
366 | uint32_t total_ped; |
367 | uint32_t nsamples_integral; |
368 | uint32_t nsamples_pedestal; |
369 | |
370 | |
371 | |
372 | const uint16_t NPEDSAMPLES=16; |
373 | |
374 | |
375 | 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}; |
376 | |
377 | |
378 | |
379 | |
380 | |
381 | |
382 | vector<const DCDCHit*> hits; |
383 | eventLoop->Get(hits); |
384 | |
385 | |
386 | vector<const DCDCDigiHit*> digihits; |
387 | eventLoop->Get(digihits); |
388 | |
389 | japp->RootWriteLock(); |
390 | |
391 | for(uint32_t i=0; i<hits.size(); i++) { |
392 | |
393 | const DCDCHit *hit = hits[i]; |
394 | |
395 | if(hit->q>0.0) { |
396 | |
397 | q = hit->q; |
398 | t = hit->t; |
399 | ring = hit->ring; |
400 | straw = hit->straw; |
401 | |
402 | n = straw_offset[ring] + straw; |
403 | |
404 | if (q > 0.0) { |
405 | cdc_e->Fill(q); |
406 | cdc_e_vs_n->Fill(n,q); |
407 | } |
408 | |
409 | |
410 | cdc_t->Fill(t); |
411 | cdc_t_vs_n->Fill(n,t); |
412 | |
413 | |
414 | cdc_e_vs_t->Fill(t,q); |
415 | cdc_e_vs_t_ring[ring]->Fill(t,q); |
416 | |
417 | cdc_e_ring[ring]->Fill(straw,q); |
418 | cdc_t_ring[ring]->Fill(straw,t); |
419 | } |
420 | } |
421 | |
422 | |
423 | a = 0; |
424 | |
425 | |
426 | for(uint32_t i=0; i<digihits.size(); i++) { |
427 | |
428 | const DCDCDigiHit *digihit = digihits[i]; |
429 | |
430 | |
431 | const Df125PulseIntegral *pi = NULL__null; |
432 | const Df125PulsePedestal *pp = NULL__null; |
433 | const Df125WindowRawData *windat = NULL__null; |
434 | |
435 | vector<uint16_t> samples; |
436 | uint32_t winped=0; |
437 | |
438 | PED_SUB = kFALSE; |
439 | total_ped = 0; |
440 | |
441 | digihit->GetSingle(pi); |
442 | if(pi) pi->GetSingle(windat); |
443 | nsamples_integral = pi ? pi->nsamples_integral : 0; |
444 | nsamples_pedestal = pi ? pi->nsamples_pedestal : 0; |
445 | |
446 | if ((nsamples_integral > 0) && (nsamples_pedestal > 0)) PED_SUB = kTRUE; |
447 | |
448 | digihit->GetSingle(pp); |
449 | if(pp) a = pp->pulse_peak; |
450 | |
451 | |
452 | if (windat) { |
453 | |
454 | if (windat->samples.size()>=NPEDSAMPLES) { |
455 | |
456 | |
457 | |
458 | winped = 0; |
459 | |
460 | for (uint16_t j=0; j<NPEDSAMPLES; j++) winped += (uint32_t)windat->samples[j]; |
461 | |
462 | winped = (uint32_t)winped/16.0; |
463 | |
464 | if (winped > 0) { |
465 | |
466 | if (pi->rocid == 25) cdc_windata_ped_roc25->Fill(100*pi->slot + pi->channel,winped); |
467 | if (pi->rocid == 26) cdc_windata_ped_roc26->Fill(100*pi->slot + pi->channel,winped); |
468 | if (pi->rocid == 27) cdc_windata_ped_roc27->Fill(100*pi->slot + pi->channel,winped); |
469 | if (pi->rocid == 28) cdc_windata_ped_roc28->Fill(100*pi->slot + pi->channel,winped); |
470 | |
471 | } |
472 | |
473 | } |
474 | } |
475 | |
476 | |
477 | |
478 | |
479 | if((digihit->pulse_integral>0)||(digihit->pulse_time>0)) { |
480 | |
481 | ring = digihit->ring; |
482 | straw = digihit->straw; |
483 | |
484 | p = digihit->pedestal; |
485 | tr = digihit->pulse_time; |
486 | integral = digihit->pulse_integral; |
487 | |
488 | |
489 | |
490 | |
491 | |
492 | integ = 0; |
493 | |
494 | |
495 | |
496 | if (PED_SUB) { |
497 | total_ped = p*nsamples_integral/nsamples_pedestal; |
498 | integ = integral - total_ped; |
499 | } |
500 | |
501 | n = straw_offset[ring] + straw; |
| Value stored to 'n' is never read |
502 | |
503 | if (PED_SUB) cdc_raw_int_vs_t->Fill(tr,integ); |
504 | if (PED_SUB) cdc_raw_int_vs_t_ring[ring]->Fill(tr,integ); |
505 | |
506 | cdc_ped_ring[ring]->Fill(straw,p); |
507 | cdc_raw_t_ring[ring]->Fill(straw,tr); |
508 | if (a>p) cdc_raw_amp_ring[ring]->Fill(straw,a-p); |
509 | if (PED_SUB) cdc_raw_int_ring[ring]->Fill(straw,integ); |
510 | cdc_raw_intpp_ring[ring]->Fill(straw,integral); |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | |
518 | |
519 | |
520 | |
521 | |
522 | |
523 | |
524 | |
525 | |
526 | |
527 | |
528 | |
529 | |
530 | |
531 | |
532 | |
533 | |
534 | |
535 | } |
536 | |
537 | } |
538 | |
539 | |
540 | japp->RootUnLock(); |
541 | |
542 | |
543 | return NOERROR; |
544 | } |
545 | |
546 | |
547 | |
548 | |
549 | |
550 | jerror_t JEventProcessor_CDC_expert::erun(void) { |
551 | |
552 | |
553 | |
554 | return NOERROR; |
555 | } |
556 | |
557 | |
558 | |
559 | |
560 | |
561 | jerror_t JEventProcessor_CDC_expert::fini(void) { |
562 | |
563 | return NOERROR; |
564 | } |
565 | |
566 | |
567 | |
568 | |