@@ -281,7 +281,7 @@ InitStatus R3BActafOnlineSpectra::Init()
281281 cMap_perRing[sideNb][ringNb - 1 ][0 ]->cd (++countsPerRing[sideNb][ringNb - 1 ]);
282282 fh2_RawTraces[index]->Draw (" colz" );
283283
284- std::string nameHistC = " fh2_Pad_" + std::to_string (index) + " corrected_trace" ;
284+ std::string nameHistC = " fh2_Pad_" + std::to_string (index + 1 ) + " corrected_trace" ;
285285
286286 fh2_CorrectedTraces[index] = R3B ::root_owned<TH2F >(
287287 nameHistC.c_str (), titleHist.c_str (), nBinsSample, 1 , nBinsSample, nBinsTrace, nTraceMin, nTraceMax);
@@ -299,7 +299,7 @@ InitStatus R3BActafOnlineSpectra::Init()
299299 fh2_CorrectedTraces[index]->Draw (" colz" );
300300
301301 // Filtered traces (CAL LEVEL!)
302- std::string nameFiltHist = " fh2_Pad_" + std::to_string (index) + " filtered_trace" ;
302+ std::string nameFiltHist = " fh2_Pad_" + std::to_string (index + 1 ) + " filtered_trace" ;
303303 fh2_FilteredTraces[index] = R3B ::root_owned<TH2F >(
304304 nameFiltHist.c_str (), titleHist.c_str (), nBinsSample, 1 , nBinsSample, nBinsTrace, nTraceMin, nTraceMax);
305305 fh2_FilteredTraces[index]->GetXaxis ()->SetTitle (" Time [Chn]" );
@@ -310,7 +310,7 @@ InitStatus R3BActafOnlineSpectra::Init()
310310 cCalFilt->cd (chn);
311311 fh2_FilteredTraces[index]->Draw (" colz" );
312312
313- std::string nameHistE = " fh1_Pad_" + std::to_string (index) + " _Eraw" ;
313+ std::string nameHistE = " fh1_Pad_" + std::to_string (index + 1 ) + " _Eraw" ;
314314 std::string titleHistE = " ERaw: Pad " + std::to_string (index + 1 ) + " (Mod " + std::to_string (FADCnum) +
315315 " Chn " + std::to_string (FADCchn) + " )" ;
316316 fh1_RawE[index] = R3B ::root_owned<TH1F >(nameHistE.c_str (), titleHistE.c_str (), 100 , 0 , 300000 );
@@ -327,7 +327,7 @@ InitStatus R3BActafOnlineSpectra::Init()
327327 cMap_perRing[sideNb][ringNb - 1 ][2 ]->cd (countsPerRing[sideNb][ringNb - 1 ]);
328328 fh1_RawE[index]->Draw (" colz" );
329329
330- std::string nameHistB = " fh1_Pad_" + std::to_string (index) + " _Baseline" ;
330+ std::string nameHistB = " fh1_Pad_" + std::to_string (index + 1 ) + " _Baseline" ;
331331 std::string titleHistB = " Baseline: Pad " + std::to_string (index + 1 ) + " (Mod " + std::to_string (FADCnum) +
332332 " Chn " + std::to_string (FADCchn) + " )" ;
333333 fh1_Baseline[index] = R3B ::root_owned<TH1F >(nameHistB.c_str (), titleHistB.c_str (), 300 , 7000 , 10000 );
@@ -553,7 +553,7 @@ InitStatus R3BActafOnlineSpectra::Init()
553553 {
554554
555555 TString tit;
556- i == 0 ? tit = " Counts per ring (upstream side )" : tit = " Counts per ring (downstream side )" ;
556+ i == 0 ? tit = " Counts per ring (upstream)" : tit = " Counts per ring (downstream)" ;
557557
558558 cCounts->cd (i + 2 );
559559 fh1_RingCounts[i] = R3B ::root_owned<TH1F >(Form (" fh1_RingCounts_side%d" , i + 1 ), tit, 8 , 0.5 , 8.5 );
@@ -575,11 +575,11 @@ InitStatus R3BActafOnlineSpectra::Init()
575575 for (auto i = 0 ; i < fh2_XYPos.size (); i++)
576576 {
577577 TString tit;
578- i == 0 ? tit = " XY (upstream)" : tit = " XY (downstream)" ;
578+ i == 0 ? tit = " Pad plane (upstream)" : tit = " Pad plane (downstream)" ;
579579
580580 cXY->cd (i + 1 );
581581
582- fh2_XYPos[i] = new TH2Poly ();
582+ fh2_XYPos[i] = R3B ::root_owned< TH2Poly> ();
583583
584584 for (int iPad = 1 + 64 * i; iPad <= 65 + 64 * i; iPad++)
585585 {
@@ -662,15 +662,15 @@ InitStatus R3BActafOnlineSpectra::Init()
662662 hitfol->Add (cXY);
663663
664664 // Canvas with XY positions (one per ring) storing the tracks of three events (updated each 3000 events)
665- auto * cXY_nevents = new TCanvas (" X_Y_events" , Form ( " XY positions (%d events) " , nbEventsFilled) , 10 , 10 , 500 , 500 );
665+ auto * cXY_nevents = new TCanvas (" X_Y_events" , " XY positions per event " , 10 , 10 , 500 , 500 );
666666 cXY_nevents->Divide (2 , 1 );
667667
668668 for (int i = 0 ; i < fh2_XYPos_Evts.size (); i++)
669669 {
670670 cXY_nevents->cd (i + 1 );
671671 fh2_XYPos_Evts[i] =
672672 static_cast <TH2Poly*>(fh2_XYPos[i]->Clone ((fh2_XYPos[i]->GetTitle () + TString (" _events" )).Data ()));
673- fh2_XYPos_Evts[i]->SetTitle (fh2_XYPos[i]->GetTitle () + TString (Form ( " %d Events " , nbEventsFilled) ));
673+ fh2_XYPos_Evts[i]->SetTitle (fh2_XYPos[i]->GetTitle () + TString (" per event " ));
674674 fh2_XYPos_Evts[i]->SetLineColor (kBlack );
675675 fh2_XYPos_Evts[i]->SetLineWidth (1 );
676676 fh2_XYPos_Evts[i]->Draw (" colz ]" );
@@ -963,7 +963,8 @@ void R3BActafOnlineSpectra::Exec(Option_t* /*option*/)
963963 if (value == 0 )
964964 continue ;
965965
966- fh2_timetag_signal->Fill (index++, value + hit->GetBaseline ());
966+ if (hit->GetBaseline () > 0 )
967+ fh2_timetag_signal->Fill (index++, value + hit->GetBaseline ());
967968 }
968969 }
969970 }
@@ -1011,8 +1012,6 @@ void R3BActafOnlineSpectra::Exec(Option_t* /*option*/)
10111012 if (value == 0 )
10121013 continue ;
10131014
1014- // if (value < -hit->GetBaseline())
1015- // continue;
10161015 if (hit->GetBaseline () > 0 )
10171016 {
10181017 fh2_CorrectedTraces[pad]->Fill (index, value /* - hit->GetBaseline()*/ );
@@ -1077,39 +1076,40 @@ void R3BActafOnlineSpectra::Exec(Option_t* /*option*/)
10771076 }
10781077
10791078 // Fill hit data
1080- // In principle each events has 128 hits
1079+ if (fNEvents % updateRate == 0 )
1080+ {
1081+ for (auto & hist : fh2_XYPos_Evts)
1082+ hist->Reset (" " );
1083+ }
1084+
10811085 if (fHitItems && fHitItems ->GetEntriesFast () > 0 )
10821086 {
10831087 auto nHits = fHitItems ->GetEntriesFast ();
1084- for (int ihit = 0 ; ihit < nHits; ihit++)
1088+ for (size_t ihit = 0 ; ihit < nHits; ihit++)
10851089 {
10861090 auto * hit = dynamic_cast <R3BActafHitData*>(fHitItems ->At (ihit));
10871091 if (!hit)
10881092 continue ;
10891093
1090- int pad = hit->GetPad ();
1094+ auto pad = hit->GetPad ();
10911095
10921096 if (pad > fPads )
10931097 continue ;
10941098
1095- int side = hit->GetSide () - 1 ;
1096- int ring = hit->GetRing ();
1097- double x = hit->GetXpos ();
1098- double y = hit->GetYpos ();
1099- // double z = hit->GetZpos ();
1099+ auto side = hit->GetSide () - 1 ;
1100+ auto ring = hit->GetRing ();
1101+ auto x = hit->GetXpos ();
1102+ auto y = hit->GetYpos ();
1103+ auto energy = hit->GetEnergy ();
11001104
1101- TVector3 track = hit->GetTrack ();
1102- double phi = track.Phi () * TMath::RadToDeg ();
1105+ auto track = hit->GetTrack ();
1106+ auto phi = track.Phi () * TMath::RadToDeg ();
11031107
11041108 fh1_RingCounts[side]->Fill (ring);
11051109 fh2_XYPos[side]->Fill (x, y);
11061110
1107- if (fNEvents % updateRate == 0 )
1108- fh2_XYPos_Evts[side]->Reset (" " );
1109-
1110- for (int iEventFilled = 1 ; iEventFilled <= nbEventsFilled; iEventFilled++)
1111- if ((fNEvents - iEventFilled) % updateRate == 0 )
1112- fh2_XYPos_Evts[side]->Fill (x, y);
1111+ auto bin = fh2_XYPos_Evts[side]->FindBin (x, y);
1112+ fh2_XYPos_Evts[side]->SetBinContent (bin, energy);
11131113
11141114 fh1_PhiCounts[side]->Fill (phi);
11151115 fh1_CountsPerSide->Fill (side + 1 );
0 commit comments