21 #include <JANA/JApplication.h>
59 japp->RootWriteLock();
66 gPARMS->SetDefaultParameter(
"CDC_ROC_HITS:TSTART",TSTART);
67 gPARMS->SetDefaultParameter(
"CDC_ROC_HITS:TSTOP",TSTOP);
71 TDirectory *
main = gDirectory;
72 gDirectory->mkdir(
"CDC_roc_hits")->cd();
75 cdc_nevents =
new TH1I(
"cdc_nevents",
"CDC number of events",1, 0.5, 1.5);
76 cdc_hits_roc25 =
new TH2D(
"cdc_hits_roc25",
"CDC hits in ROC 25, channel vs slot;slot;channel",15,2.5,17.5,72,0.5,72.5);
77 cdc_hits_roc26 =
new TH2D(
"cdc_hits_roc26",
"CDC hits in ROC 26, channel vs slot;slot;channel",14,2.5,16.5,72,0.5,72.5);
78 cdc_hits_roc27 =
new TH2D(
"cdc_hits_roc27",
"CDC hits in ROC 27, channel vs slot;slot;channel",14,2.5,16.5,72,0.5,72.5);
79 cdc_hits_roc28 =
new TH2D(
"cdc_hits_roc28",
"CDC hits in ROC 28, channel vs slot;slot;channel",15,2.5,17.5,72,0.5,72.5);
81 cdc_sumamp_roc25 =
new TH1D(
"cdc_sumamp_roc25",
"CDC pulse peak amplitude summed for ROC 25;pulse peak (ADC units)",4096,0,4096);
82 cdc_sumamp_roc26 =
new TH1D(
"cdc_sumamp_roc26",
"CDC pulse peak amplitude summed for ROC 26;pulse peak (ADC units)",4096,0,4096);
83 cdc_sumamp_roc27 =
new TH1D(
"cdc_sumamp_roc27",
"CDC pulse peak amplitude summed for ROC 27;pulse peak (ADC units)",4096,0,4096);
84 cdc_sumamp_roc28 =
new TH1D(
"cdc_sumamp_roc28",
"CDC pulse peak amplitude summed for ROC 28;pulse peak (ADC units)",4096,0,4096);
86 cdc_amp_roc25 =
new TH2D(
"cdc_amp_roc25",
"CDC pulse peak amplitude in ROC 25;slot*100+channel;pulse peak (ADC units)",1600,200,1800,4096,0,4096);
87 cdc_amp_roc26 =
new TH2D(
"cdc_amp_roc26",
"CDC pulse peak amplitude in ROC 26;slot*100+channel;pulse peak (ADC units)",1600,200,1800,4096,0,4096);
88 cdc_amp_roc27 =
new TH2D(
"cdc_amp_roc27",
"CDC pulse peak amplitude in ROC 27;slot*100+channel;pulse peak (ADC units)",1600,200,1800,4096,0,4096);
89 cdc_amp_roc28 =
new TH2D(
"cdc_amp_roc28",
"CDC pulse peak amplitude in ROC 28;slot*100+channel;pulse peak (ADC units)",1600,200,1800,4096,0,4096);
91 cdc_netamp_roc25 =
new TH2D(
"cdc_netamp_roc25",
"CDC pulse peak amplitude minus pedestal in ROC 25;slot*100+channel;pulse peak minus pedestal (ADC units)",1600,200,1800,4096,0,4096);
92 cdc_netamp_roc26 =
new TH2D(
"cdc_netamp_roc26",
"CDC pulse peak amplitude minus pedestal in ROC 26;slot*100+channel;pulse peak minus pedestal (ADC units)",1600,200,1800,4096,0,4096);
93 cdc_netamp_roc27 =
new TH2D(
"cdc_netamp_roc27",
"CDC pulse peak amplitude minus pedestal in ROC 27;slot*100+channel;pulse peak minus pedestal (ADC units)",1600,200,1800,4096,0,4096);
94 cdc_netamp_roc28 =
new TH2D(
"cdc_netamp_roc28",
"CDC pulse peak amplitude minus pedestal in ROC 28;slot*100+channel;pulse peak minus pedestal (ADC units)",1600,200,1800,4096,0,4096);
96 cdc_time_roc25 =
new TH2D(
"cdc_time_roc25",
"CDC pulse time in ROC 25;slot*100+channel;time (0.8ns)",1600,200,1800,1000,0,2000);
97 cdc_time_roc26 =
new TH2D(
"cdc_time_roc26",
"CDC pulse time in ROC 26;slot*100+channel;time (0.8ns)",1600,200,1800,1000,0,2000);
98 cdc_time_roc27 =
new TH2D(
"cdc_time_roc27",
"CDC pulse time in ROC 27;slot*100+channel;time (0.8ns)",1600,200,1800,1000,0,2000);
99 cdc_time_roc28 =
new TH2D(
"cdc_time_roc28",
"CDC pulse time in ROC 28;slot*100+channel;time (0.8ns)",1600,200,1800,1000,0,2000);
101 cdc_ped_roc25 =
new TH2D(
"cdc_ped_roc25",
"CDC pedestal in ROC 25;slot*100+channel;pedestal",1600,200,1800,255,0,255);
102 cdc_ped_roc26 =
new TH2D(
"cdc_ped_roc26",
"CDC pedestal in ROC 26;slot*100+channel;pedestal",1600,200,1800,255,0,255);
103 cdc_ped_roc27 =
new TH2D(
"cdc_ped_roc27",
"CDC pedestal in ROC 27;slot*100+channel;pedestal",1600,200,1800,255,0,255);
104 cdc_ped_roc28 =
new TH2D(
"cdc_ped_roc28",
"CDC pedestal in ROC 28;slot*100+channel;pedestal",1600,200,1800,255,0,255);
107 cdc_time_selected =
new TH1D(
"cdc_time_selected",
"CDC pulse time selected for amp_t histograms;time (0.8ns)",1000,0,2000);
109 cdc_sumamp_t_roc25 =
new TH1D(
"cdc_sumamp_t_roc25",
"CDC pulse peak amplitude summed for ROC 25 with time cut;pulse peak (ADC units)",4096,0,4096);
110 cdc_sumamp_t_roc26 =
new TH1D(
"cdc_sumamp_t_roc26",
"CDC pulse peak amplitude summed for ROC 26 with time cut; pulse peak (ADC units)",4096,0,4096);
111 cdc_sumamp_t_roc27 =
new TH1D(
"cdc_sumamp_t_roc27",
"CDC pulse peak amplitude summed for ROC 27 with time cut; pulse peak (ADC units)",4096,0,4096);
112 cdc_sumamp_t_roc28 =
new TH1D(
"cdc_sumamp_t_roc28",
"CDC pulse peak amplitude summed for ROC 28 with time cut; pulse peak (ADC units)",4096,0,4096);
114 cdc_amp_t_roc25 =
new TH2D(
"cdc_amp_t_roc25",
"CDC pulse peak amplitude in ROC 25 with time cut;slot*100+channel; pulse peak (ADC units)",1600,200,1800,4096,0,4096);
115 cdc_amp_t_roc26 =
new TH2D(
"cdc_amp_t_roc26",
"CDC pulse peak amplitude in ROC 26 with time cut;slot*100+channel; pulse peak (ADC units)",1600,200,1800,4096,0,4096);
116 cdc_amp_t_roc27 =
new TH2D(
"cdc_amp_t_roc27",
"CDC pulse peak amplitude in ROC 27 with time cut;slot*100+channel; pulse peak (ADC units)",1600,200,1800,4096,0,4096);
117 cdc_amp_t_roc28 =
new TH2D(
"cdc_amp_t_roc28",
"CDC pulse peak amplitude in ROC 28 with time cut;slot*100+channel; pulse peak (ADC units)",1600,200,1800,4096,0,4096);
165 vector<const DCDCDigiHit*> digihits;
166 eventLoop->Get(digihits);
168 japp->RootWriteLock();
173 for(uint32_t i=0; i<digihits.size(); i++) {
187 digihit->GetSingle(pi);
196 digihit->GetSingle(pp);
201 digihit->GetSingle(cp);
217 ASCALE = 1<<cf->
ABIT;
218 PSCALE = 1<<cf->
PBIT;
225 netamp = ASCALE*amp - PSCALE*ped;
229 if (!rocid)
continue;
236 if (rocid == 25) cdc_sumamp_roc25->Fill(amp);
237 if (rocid == 26) cdc_sumamp_roc26->Fill(amp);
238 if (rocid == 27) cdc_sumamp_roc27->Fill(amp);
239 if (rocid == 28) cdc_sumamp_roc28->Fill(amp);
246 if (rocid == 25) cdc_netamp_roc25->Fill(slot*100+channel,netamp);
247 if (rocid == 26) cdc_netamp_roc26->Fill(slot*100+channel,netamp);
248 if (rocid == 27) cdc_netamp_roc27->Fill(slot*100+channel,netamp);
249 if (rocid == 28) cdc_netamp_roc28->Fill(slot*100+channel,netamp);
251 if (rocid == 25) cdc_ped_roc25->Fill(slot*100+channel,ped);
252 if (rocid == 26) cdc_ped_roc26->Fill(slot*100+channel,ped);
253 if (rocid == 27) cdc_ped_roc27->Fill(slot*100+channel,ped);
254 if (rocid == 28) cdc_ped_roc28->Fill(slot*100+channel,ped);
257 if (rocid == 25) cdc_time_roc25->Fill(slot*100+channel,time);
258 if (rocid == 26) cdc_time_roc26->Fill(slot*100+channel,time);
259 if (rocid == 27) cdc_time_roc27->Fill(slot*100+channel,time);
260 if (rocid == 28) cdc_time_roc28->Fill(slot*100+channel,time);
263 if ((
int)time>=TSTART && (
int)time<=TSTOP) {
265 cdc_time_selected->Fill(time);
267 if (rocid == 25) cdc_sumamp_t_roc25->Fill(amp);
268 if (rocid == 26) cdc_sumamp_t_roc26->Fill(amp);
269 if (rocid == 27) cdc_sumamp_t_roc27->Fill(amp);
270 if (rocid == 28) cdc_sumamp_t_roc28->Fill(amp);
272 if (rocid == 25) cdc_amp_t_roc25->Fill(slot*100+channel,amp);
273 if (rocid == 26) cdc_amp_t_roc26->Fill(slot*100+channel,amp);
274 if (rocid == 27) cdc_amp_t_roc27->Fill(slot*100+channel,amp);
275 if (rocid == 28) cdc_amp_t_roc28->Fill(slot*100+channel,amp);
308 const float COLD = 0.1;
319 bool emptychan[15][72];
320 bool hotchan[15][72];
321 bool coldchan[15][72];
328 outfile = fopen(
"CDC_roc_hits.txt",
"w");
330 if (outfile == NULL)
printf(
"1 Cannot open file CDC_roc_hits.txt\n");
331 if (!outfile)
printf(
"2 Cannot open file CDC_roc_hits.txt\n");
336 for (roc=25; roc<29; roc++) {
338 for (
int islot=3; islot<18; islot++) {
339 for (
int ichan=0; ichan<72; ichan++) {
340 emptychan[islot-3][ichan] = 0;
341 hotchan[islot-3][ichan] = 0;
342 coldchan[islot-3][ichan] = 0;
353 }
else if (roc==26) {
359 }
else if (roc==27) {
365 }
else if (roc==28) {
373 usedchans = 72*(maxslot-4) - unusedchans;
374 if (totalhits) meanhits = totalhits/usedchans;
375 printf(
"\nROC %i: mean number of hits per channel is %i\n",roc,meanhits);
376 if (outfile) fprintf(outfile,
"\nROC %i: mean hits per channel is %i\n",roc,meanhits);
380 for (
int islot=3; islot<maxslot+1; islot++) {
382 if (islot==11)
continue;
383 if (islot==12)
continue;
386 for (
int ichan=0; ichan<72; ichan++) {
391 if (islot==6 && ichan==17) unused = 1;
392 if (islot==7 && ichan==11) unused = 1;
393 if (islot==8 && ichan==35) unused = 1;
394 if (islot==8 && ichan==37) unused = 1;
395 if (islot==9 && ichan==37) unused = 1;
396 if (islot==9 && ichan==59) unused = 1;
397 if (islot==10 && ichan==61) unused = 1;
398 if (islot==13 && ichan==13) unused = 1;
399 if (islot==13 && ichan==37) unused = 1;
400 if (islot==14 && ichan==35) unused = 1;
401 if (islot==14 && ichan==59) unused = 1;
402 if (islot==14 && ichan==25) unused = 1;
403 if (islot==16 && ichan==11) unused = 1;
404 if (islot==16 && ichan==37) unused = 1;
405 if (islot==17 && ichan==59) unused = 1;
409 }
else if (roc==26) {
411 if (islot==3 && ichan==59) unused = 1;
412 if (islot==4 && ichan==7) unused = 1;
413 if (islot==4 && ichan==11) unused = 1;
414 if (islot==4 && ichan>47) unused = 1;
415 if (islot==5 && ichan==13) unused = 1;
416 if (islot==6 && ichan==11) unused = 1;
417 if (islot==6 && ichan==61) unused = 1;
418 if (islot==7 && ichan==13) unused = 1;
419 if (islot==9 && ichan==33) unused = 1;
420 if (islot==9 && ichan==35) unused = 1;
421 if (islot==13 && ichan==37) unused = 1;
422 if (islot==13 && ichan==61) unused = 1;
423 if (islot==14 && ichan==61) unused = 1;
424 if (islot==15 && ichan==61) unused = 1;
425 if (islot==16 && ichan==13) unused = 1;
426 if (islot==16 && ichan==35) unused = 1;
430 }
else if (roc==27) {
432 if (islot==3 && ichan==37) unused = 1;
433 if (islot==3 && ichan==61) unused = 1;
434 if (islot==4 && ichan==11) unused = 1;
435 if (islot==4 && ichan==35) unused = 1;
436 if (islot==5 && ichan==13) unused = 1;
437 if (islot==5 && ichan==35) unused = 1;
438 if (islot==7 && ichan==17) unused = 1;
439 if (islot==7 && ichan==41) unused = 1;
440 if (islot==8 && ichan==13) unused = 1;
441 if (islot==8 && ichan==61) unused = 1;
442 if (islot==9 && ichan==11) unused = 1;
443 if (islot==9 && ichan==35) unused = 1;
444 if (islot==9 && ichan==37) unused = 1;
445 if (islot==10 && ichan==37) unused = 1;
446 if (islot==13 && ichan==35) unused = 1;
447 if (islot==15 && ichan==59) unused = 1;
448 if (islot==16 && ichan==11) unused = 1;
452 }
else if (roc==28) {
454 if (islot==5 && ichan==37) unused = 1;
455 if (islot==6 && ichan==65) unused = 1;
456 if (islot==7 && ichan==13) unused = 1;
457 if (islot==9 && ichan==35) unused = 1;
458 if (islot==10 && ichan==37) unused = 1;
459 if (islot==14 && ichan==31) unused = 1;
460 if (islot==14 && ichan==37) unused = 1;
461 if (islot==16 && ichan==59) unused = 1;
462 if (islot==17 && ichan==61) unused = 1;
468 if (unused)
continue;
470 if (chanhits == 0) emptychan[islot-3][ichan] = 1;
471 if (chanhits > HOT*meanhits) hotchan[islot-3][ichan] = 1;
472 if (chanhits < COLD*meanhits) coldchan[islot-3][ichan] = 1;
480 printf(
"Checking ROC %i for silent channels...\n",roc);
481 if (outfile) fprintf(outfile,
"Checking ROC %i for silent channels...\n",roc);
485 for (
int islot=3; islot<maxslot; islot++) {
486 for (
int ichan=0; ichan<72; ichan++) {
487 if (emptychan[islot-3][ichan]) {
489 printf(
" roc %i slot %i channel %i\n",roc,islot,ichan);
490 if (outfile) fprintf(outfile,
" roc %i slot %i channel %i\n",roc,islot,ichan);
497 if (outfile) fprintf(outfile,
" none found \n");
502 printf(
"Checking ROC %i for cold channels (below %1.2f x mean hits/channel)...\n",roc,COLD);
503 if (outfile) fprintf(outfile,
"Checking ROC %i for cold channels (below %1.2f x mean hits/channel)...\n",roc,COLD);
506 for (
int islot=3; islot<maxslot; islot++) {
507 for (
int ichan=0; ichan<72; ichan++) {
508 if (coldchan[islot-3][ichan] && !emptychan[islot-3][ichan]) {
510 printf(
" roc %i slot %i channel %i\n",roc,islot,ichan);
511 if (outfile) fprintf(outfile,
" roc %i slot %i channel %i\n",roc,islot,ichan);
517 if (outfile) fprintf(outfile,
" none found \n");
521 printf(
"Checking ROC %i for hot channels (over %1.2f x mean hits/channel)...\n",roc,HOT);
522 if (outfile) fprintf(outfile,
"Checking ROC %i for hot channels (over %1.2f x mean hits/channel)...\n",roc,HOT);
525 for (
int islot=3; islot<maxslot; islot++) {
526 for (
int ichan=0; ichan<72; ichan++) {
527 if (hotchan[islot-3][ichan]) {
529 printf(
" roc %i slot %i channel %i\n",roc,islot,ichan);
530 if (outfile) fprintf(outfile,
" roc %i slot %i channel %i\n",roc,islot,ichan);
536 if (outfile) fprintf(outfile,
" none found \n");
544 if (outfile) fclose(outfile);
static TH2D * cdc_hits_roc28
static TH2D * cdc_amp_roc26
uint32_t first_max_amp
from second word
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH2D * cdc_amp_roc27
uint32_t pulse_peak
from Pulse Pedestal Data word
uint32_t pedestal
from second word
jerror_t fini(void)
Called after last event of last event source has been processed.
uint32_t le_time
from first word
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH2D * cdc_amp_roc25
JEventProcessor_CDC_roc_hits()
uint32_t time_quality_bit
from first word
jerror_t init(void)
Called once at program start.
static TH2D * cdc_hits_roc27
static TH2D * cdc_hits_roc26
printf("string=%s", string)
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2D * cdc_hits_roc25
~JEventProcessor_CDC_roc_hits()
int main(int argc, char *argv[])
static TH2D * cdc_amp_roc28