49 japp->RootWriteLock();
77 TDirectory *
main = gDirectory;
78 gDirectory->mkdir(
"BCAL_LED_time")->cd();
140 low_up_1 =
new TProfile(
"low_bias_up_column_1_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-4,1536);
141 low_up_2 =
new TProfile(
"low_bias_up_column_2_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-3,1537);
142 low_up_3 =
new TProfile(
"low_bias_up_column_3_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-2,1538);
143 low_up_4 =
new TProfile(
"low_bias_up_column_4_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-1,1539);
145 low_down_1 =
new TProfile(
"low_bias_down_column_1_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-4,1536);
146 low_down_2 =
new TProfile(
"low_bias_down_column_2_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-3,1537);
147 low_down_3 =
new TProfile(
"low_bias_down_column_3_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-2,1538);
148 low_down_4 =
new TProfile(
"low_bias_down_column_4_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-1,1539);
150 low_up =
new TProfile(
"low_bias_up_time_vchannel",
"Low bias up - Diff time vs channel;channel ID;time",768,0,768);
151 low_down =
new TProfile(
"low_bias_down_time_vchannel",
"Low bias down - Diff time vs channel;channel ID;time",768,0,768);
153 high_up_1 =
new TProfile(
"high_bias_up_column_1_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-4,1536);
154 high_up_2 =
new TProfile(
"high_bias_up_column_2_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-3,1537);
155 high_up_3 =
new TProfile(
"high_bias_up_column_3_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-2,1538);
156 high_up_4 =
new TProfile(
"high_bias_up_column_4_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-1,1539);
158 high_down_1 =
new TProfile(
"high_bias_down_column_1_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-4,1536);
159 high_down_2 =
new TProfile(
"high_bias_down_column_2_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-3,1537);
160 high_down_3 =
new TProfile(
"high_bias_down_column_3_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-2,1538);
161 high_down_4 =
new TProfile(
"high_bias_down_column_4_time_vchannel",
"Avg BCAL time vs channel;channel ID;time",386,-1,1539);
163 high_up =
new TProfile(
"high_bias_up_time_vchannel",
"High bias up - Diff time vs channel;channel ID;time",768,0,768);
164 high_down =
new TProfile(
"high_bias_down_time_vchannel",
"High bias down - Diff time vs channel;channel ID;time",768,0,768);
166 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
211 h2_ledboth_Tall_vs_event =
new TProfile(
"h2_ledboth_Tall_vs_event",
"LED uboth - Tup and Tdown vs event", 20000,0,200000000);
213 h1_ledall_layer =
new TH1I(
"h1_ledall_layer",
"LED ALL - layer", 5,0,5);
214 h1_led0_layer =
new TH1I(
"h1_led0_layer",
"LED No bit - layer", 5,0,5);
216 h1_ledup_layer =
new TH1I(
"h1_ledup_layer",
"LED up - layer", 5,0,5);
217 h1_ledup_sector =
new TH1I(
"h1_ledup_sector",
"LED up - sector", 50,0,5);
218 h2_ledup_z_vs_cellid =
new TH2I(
"h2_ledup_z_vs_cellid",
"LED up - z vs Chan ID", 800,0,800,500,-100,400);
220 h1_ledup_z_all =
new TH1I(
"h1_ledup_z_all",
"LED up - z all channels", 500,-100,400);
221 h1_ledup_Tdiff_all =
new TH1I(
"h1_ledup_Tdiff_all",
"LED up - Tdiff all channels", 400,-50,50);
222 h1_ledup_Tup_all =
new TH1I(
"h1_ledup_Tup_all",
"LED up - Tup all channels", 410,0,410);
223 h1_ledup_Tdown_all =
new TH1I(
"h1_ledup_Tdown_all",
"LED up - Tdown all channels", 410,0,410);
224 h2_ledup_Tup_vs_z =
new TH2I(
"h2_ledup_Tup_vs_z",
"LED up - Tup vs z", 100,-100,400,410,0,410);
225 h2_ledup_Tdown_vs_z =
new TH2I(
"h2_ledup_Tdown_vs_z",
"LED up - Tdown vs z", 100,-100,400,410,0,410);
226 h2_ledup_Tup_vs_event =
new TProfile(
"h2_ledup_Tup_vs_event",
"LED up - Tup vs event", 20000,0,200000000);
227 h2_ledup_Tdown_vs_event =
new TProfile(
"h2_ledup_Tdown_vs_event",
"LED up - Tdown vs event", 20000,0,200000000);
228 h2_ledup_Tall_vs_event =
new TProfile(
"h2_ledup_Tall_vs_event",
"LED up - Tup and Tdown vs event", 20000,0,200000000);
233 h2_leddown_z_vs_cellid =
new TH2I(
"h2_leddown_z_vs_cellid",
"LED down - z vs Chan ID", 800,0,800,500,-100,400);
235 h1_leddown_z_all =
new TH1I(
"h1_leddown_z_all",
"LED down - z all channels", 500,-100,400);
236 h1_leddown_Tdiff_all =
new TH1I(
"h1_leddown_Tdiff_all",
"LED down - Tdiff all channels", 400,-50,50);
237 h1_leddown_Tup_all =
new TH1I(
"h1_leddown_Tup_all",
"LED down - Tup all channels", 410,0,410);
238 h1_leddown_Tdown_all =
new TH1I(
"h1_leddown_Tdown_all",
"LED down - Tdown all channels", 410,0,410);
239 h2_leddown_Tup_vs_z =
new TH2I(
"h2_leddown_Tup_vs_z",
"LED down - Tup vs z", 100,-100,400,410,0,410);
240 h2_leddown_Tdown_vs_z =
new TH2I(
"h2_leddown_Tdown_vs_z",
"LED down - Tdown vs z", 100,-100,400,410,0,410);
241 h2_leddown_Tup_vs_event =
new TProfile(
"h2_leddown_Tup_vs_event",
"LED down - Tup vs event", 20000,0,200000000);
243 h2_leddown_Tall_vs_event =
new TProfile(
"h2_leddown_Tall_vs_event",
"LED down - Tup and Tdown vs event", 20000,0,200000000);
276 int chcounter[1536] = { 0 } ;
279 vector<const DBCALDigiHit*> bcaldigihits;
281 vector <const DBCALHit*> hitVector;
283 vector<const DBCALHit*> dbcalhits;
284 vector<const DBCALPoint*> dbcalpoints;
287 bool LED_US=0, LED_DS=0;
292 loop->GetSingle(trig);
328 japp->RootWriteLock();
330 float ledup_sector = 0;
331 int ledup_sector_int = 0;
332 float ledup_mean = 0;
333 int ledup_events = 0;
334 float leddown_sector = 0;
335 int leddown_sector_int = 0;
336 float leddown_mean = 0;
337 int leddown_events = 0;
339 loop->Get(dbcalhits);
340 loop->Get(bcaldigihits);
341 loop->Get(dbcalpoints);
345 double total_bcal_energy = 0.;
346 for(
unsigned int i=0; i<dbcalhits.size(); i++) {
347 total_bcal_energy += dbcalhits[i]->E;
349 if (!(LED_US || LED_DS)) {
350 LED_0 = (dbcalhits.size() >= 200) || (total_bcal_energy > 12.);
356 for(
unsigned int i=0; i<dbcalpoints.size(); i++) {
357 dbcalpoints[i]->Get(hitVector);
358 const DBCALHit *Hit1 = hitVector[0];
359 const DBCALHit *Hit2 = hitVector[1];
365 Tdiff += Tdown - Tup;
370 Tdiff += Tdown - Tup;
378 else if (Tdiff < 0) {
381 cout <<
" total_bcal_energy=" << total_bcal_energy <<
" bcalhits=" << dbcalhits.size() << endl;
382 cout <<
"LED_US=" << LED_US <<
" LED_DS=" << LED_DS <<
" LED_0=" << LED_0 <<
" Tdiff=" << Tdiff << endl;
385 if (! (LED_US || LED_DS)) {
386 cout <<
" *** No bit set " << endl;
387 cout <<
" total_bcal_energy=" << total_bcal_energy <<
" bcalhits=" << dbcalhits.size() << endl;
388 cout <<
"LED_US=" << LED_US <<
" LED_DS=" << LED_DS <<
" LED_0=" << LED_0 <<
" Tdiff=" << Tdiff << endl;
391 if (LED_US || LED_DS) {
393 float apedsubtime[1536] = { 0. };
394 int apedsubpeak[1536] = { 0 };
396 for(
unsigned int i=0; i<dbcalpoints.size(); i++) {
398 int module = dbcalpoints[i]->module();
399 int layer = dbcalpoints[i]->layer();
400 int sector = dbcalpoints[i]->sector();
401 int cell_id = (module-1)*16 + (layer-1)*4 + sector-1;
410 float z = dbcalpoints[i]->z();
411 dbcalpoints[i]->Get(hitVector);
412 const DBCALHit *Hit1 = hitVector[0];
413 const DBCALHit *Hit2 = hitVector[1];
469 if ( LED_DS && (Tdiff>-30 && Tdiff<-15)) {
470 apedsubpeak[cell_id] = Adown;
471 apedsubtime[cell_id] = Tdown;
472 chcounter[cell_id]++;
473 apedsubpeak[cell_id+768] = Aup;
474 apedsubtime[cell_id+768] = Tup;
475 chcounter[cell_id+768]++;
484 leddown_sector += sector;
485 leddown_mean += Aup + Adown;
492 if (LED_US && (Tdiff>15 && Tdiff<30)) {
493 apedsubpeak[cell_id] = Adown;
494 apedsubtime[cell_id] = Tdown;
495 chcounter[cell_id]++;
496 apedsubpeak[cell_id+768] = Aup;
497 apedsubtime[cell_id+768] = Tup;
498 chcounter[cell_id+768]++;
507 ledup_sector += sector;
508 ledup_mean += Aup + Adown;
516 ledup_sector_int = ledup_events > 0? ledup_sector/ledup_events + 0.5 : 0;
517 ledup_mean = ledup_events > 0? ledup_mean/(2*ledup_events): 0;
518 leddown_sector_int = leddown_events > 0? leddown_sector/leddown_events + 0.5: 0;
519 leddown_mean = leddown_events > 0? leddown_mean/(2*leddown_events) : 0;
528 for (
int chid = 0; chid < 1536; chid++) {
530 if (chcounter[chid] != 1)
continue;
536 if (ledup_sector_int == 1 && chid%4+1 == 1) {
column1_up_peak_vevent->Fill(eventnumber,apedsubpeak[chid]);}
537 else if (ledup_sector_int == 2 && chid%4+1 == 2) {
column2_up_peak_vevent->Fill(eventnumber,apedsubpeak[chid]);}
538 else if (ledup_sector_int == 3 && chid%4+1 == 3) {
column3_up_peak_vevent->Fill(eventnumber,apedsubpeak[chid]);}
539 else if (ledup_sector_int == 4 && chid%4+1 == 4) {
column4_up_peak_vevent->Fill(eventnumber,apedsubpeak[chid]);}
551 if (ledup_sector_int == 1 && chid%4+1 == 1) {
column1_time_vevent->Fill(eventnumber,apedsubtime[chid]);}
552 else if (ledup_sector_int == 2 && chid%4+1 == 2) {
column2_time_vevent->Fill(eventnumber,apedsubtime[chid]);}
553 else if (ledup_sector_int == 3 && chid%4+1 == 3) {
column3_time_vevent->Fill(eventnumber,apedsubtime[chid]);}
554 else if (ledup_sector_int == 4 && chid%4+1 == 4) {
column4_time_vevent->Fill(eventnumber,apedsubtime[chid]);}
558 double column1up = 0;
559 double column2up = 0;
560 double column3up = 0;
561 double column4up = 0;
563 double column1down = 0;
564 double column2down = 0;
565 double column3down = 0;
566 double column4down = 0;
583 for (
int chid = 0; chid < 1536; chid++) {
585 if (chcounter[chid] != 1)
continue;
587 if (ledup_sector_int == 1 && chid%4+1 == 1) {
589 if (chid < 768)
low_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
591 low_up_1->Fill(chid,apedsubtime[chid]);
595 else if (chid > 767) {
600 if (chid < 768)
high_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
605 else if (chid > 767) {
610 else if (ledup_sector_int == 2 && chid%4+1 == 2) {
612 if (chid < 768)
low_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
613 low_up_2->Fill(chid,apedsubtime[chid]);
617 else if (chid > 767) {
622 if (chid < 768)
high_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
627 else if (chid > 767) {
632 else if (ledup_sector_int == 3 && chid%4+1 == 3) {
634 if (chid < 768)
low_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
635 low_up_3->Fill(chid,apedsubtime[chid]);
639 else if (chid > 767) {
644 if (chid < 768)
high_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
649 else if (chid > 767) {
654 else if (ledup_sector_int == 4 && chid%4+1 == 4) {
656 if (chid < 768)
low_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
657 low_up_4->Fill(chid,apedsubtime[chid]);
661 else if (chid > 767) {
666 if (chid < 768)
high_up->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
671 else if (chid > 767) {
678 if (leddown_sector_int == 1 && chid%4+1 == 1) {
681 low_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
689 else if (chid > 767) {
695 high_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
702 else if (chid > 767) {
707 else if (leddown_sector_int == 2 && chid%4+1 == 2) {
709 if (chid < 768)
low_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
714 else if (chid > 767) {
719 if (chid < 768)
high_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
724 else if (chid > 767) {
729 else if (leddown_sector_int == 3 && chid%4+1 == 3) {
731 if (chid < 768)
low_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
736 else if (chid > 767) {
741 if (chid < 768)
high_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
746 else if (chid > 767) {
751 else if (leddown_sector_int == 4 && chid%4+1 == 4) {
753 if (chid < 768)
low_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
758 else if (chid > 767) {
763 if (chid < 768)
high_down->Fill(chid,apedsubtime[chid]-apedsubtime[chid+768]);
768 else if (chid > 767) {
838 ofstream foutlowdown ; foutlowdown.open(
"LED_lowbias_downstream.txt");
839 ofstream foutlowup; foutlowup.open(
"LED_lowbias_upstream.txt");
840 ofstream fouthighdown; fouthighdown.open(
"LED_highbias_downstream.txt");
841 ofstream fouthighup; fouthighup.open(
"LED_highbias_upstream.txt");
843 for(
int k=0 ;k < 768;k += 4)
882 foutlowdown << lowdownmean1down << endl << lowdownmean1up << endl << lowdownmean2down << endl << lowdownmean2up << endl << lowdownmean3down << endl << lowdownmean3up << endl << lowdownmean4down << endl << lowdownmean4up << endl;
883 foutlowup << lowupmean1down << endl << lowupmean1up << endl << lowupmean2down << endl << lowupmean2up << endl << lowupmean3down << endl << lowupmean3up << endl << lowupmean4down << endl << lowupmean4up << endl;
884 fouthighdown << highdownmean1down << endl << highdownmean1up << endl << highdownmean2down << endl << highdownmean2up << endl << highdownmean3down << endl << highdownmean3up << endl << highdownmean4down << endl << highdownmean4up << endl;
885 fouthighup << highupmean1down << endl << highupmean1up << endl << highupmean2down << endl << highupmean2up << endl << highupmean3down << endl << highupmean3up << endl << highupmean4down << endl << highupmean4up << endl;
891 fouthighdown.close();
TProfile * column4_down_time_vevent2
TProfile * column3_down_time_vevent1
TProfile * column1_down_time_vevent2
TProfile * column4_down_peak_vevent
TProfile * bcal_time_vevent
TProfile * column1_down_time_vevent1
TProfile * column2_down_time_vevent1
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
TProfile * column2_down_time_vevent3
jerror_t fini(void)
Called after last event of last event source has been processed.
TProfile * h2_ledboth_sector_vs_event
TH1I * h1_leddown_sector_config
TH1I * h1_ledup_Tdiff_all
TProfile * h2_ledup_sector_vs_event
TProfile * column4_up_peak_vevent
TProfile * column4_down_time_vevent1
TProfile * column3_up_time_vevent1
TProfile * column3_down_time_vevent2
TH1I * h1_ledup_sector_config
TProfile * column1_up_time_vevent4
TH2I * h2_ledup_z_vs_cellid
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
TProfile * column3_up_peak_vevent
TH2I * h2_leddown_Tdown_vs_z
TProfile * h2_leddown_sector_vs_event
TProfile * h2_ledup_Tup_vs_event
TProfile * column3_down_time_vevent4
TProfile * column1_down_time_vevent3
TProfile * column3_up_time_vevent2
TProfile * column1_up_peak_vevent
jerror_t init(void)
Called once at program start.
TH2I * h2_leddown_z_vs_cellid
TProfile * column2_up_time_vevent4
TH1I * h1_leddown_Tup_all
JEventProcessor_BCAL_LED_time()
TProfile * column2_down_time_vevent4
TProfile * column1_up_time_vevent2
TH2I * h2_ledup_Tdown_vs_z
~JEventProcessor_BCAL_LED_time()
TProfile * column2_up_peak_vevent
TH1I * h1_leddown_Tdiff_all
TH2I * h2_leddown_Tup_vs_z
TH1I * h1_ledup_Tdown_all
TProfile * column4_up_time_vevent2
TProfile * column4_down_time_vevent3
TProfile * column1_down_time_vevent4
TProfile * h2_leddown_Tdown_vs_event
TProfile * column1_up_time_vevent3
TProfile * column4_down_time_vevent4
TProfile * column1_time_vevent
TH1I * h1_leddown_Tdown_all
TProfile * column2_down_time_vevent2
TProfile * column3_time_vevent
TProfile * column1_down_peak_vevent
TProfile * column3_up_time_vevent4
TProfile * h2_leddown_Tall_vs_event
TProfile * column3_up_time_vevent3
TProfile * h2_ledup_Tall_vs_event
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
TProfile * down_time_vevent
TProfile * column3_down_time_vevent3
TProfile * h2_ledup_Tdown_vs_event
TProfile * column2_time_vevent
TProfile * column4_up_time_vevent3
TProfile * column3_down_peak_vevent
TProfile * column2_up_time_vevent1
TProfile * column2_down_peak_vevent
TProfile * column4_up_time_vevent1
TProfile * column4_time_vevent
TProfile * column4_up_time_vevent4
TProfile * column2_up_time_vevent2
TProfile * up_time_vevent
int main(int argc, char *argv[])
TProfile * h2_leddown_Tup_vs_event
TProfile * column1_up_time_vevent1
float t_raw
Uncalibrated time in ns.
TProfile * h2_ledboth_Tall_vs_event
TProfile * column2_up_time_vevent3