11 "MUSIC strip energies (complete events);Strip;#DeltaE [" +
14 new TH2F(PlottingUtils::GetRandomName().Data(), musicTitle, 18, -0.5,
15 17.5, cfg.music_energy_bins, cfg.strip_e_min, cfg.strip_e_max);
17 new TH1F(PlottingUtils::GetRandomName().Data(),
18 "Event multiplicity (complete events);Multiplicity;Counts", 36,
21 for (Int_t s = 1; s <= 16; s++) {
22 Double_t lMax = cfg.strip_e_max;
23 Double_t rMax = cfg.strip_e_max;
24 if (cfg.odd_even_split) {
25 lMax = (s % 2 == 0) ? cfg.left_even_max : cfg.left_odd_max;
26 rMax = (s % 2 == 0) ? cfg.right_even_max : cfg.right_odd_max;
30 const Bool_t lIsLong = (s % 2) != 0;
31 Double_t shortMax = lIsLong ? rMax : lMax;
32 Double_t longMax = lIsLong ? lMax : rMax;
35 if (shortMax == longMax) {
36 longMax = cfg.strip_e_max;
37 shortMax = 0.25 * cfg.strip_e_max;
40 Form(
";Strip %d Short (%c) #DeltaE [", s, lIsLong ?
'R' :
'L') +
41 cfg.unit_label +
"];" +
42 Form(
"Strip %d Long (%c) #DeltaE [", s, lIsLong ?
'L' :
'R') +
45 new TH2F(PlottingUtils::GetRandomName().Data(), rlTitle, 300,
46 cfg.strip_e_min, shortMax, 300, cfg.strip_e_min, longMax);
50 h.
h1_cathode =
new TH1F(PlottingUtils::GetRandomName().Data(),
51 ";Cathode #DeltaE [" + cfg.unit_label +
"];Counts",
52 400, 0.0, cfg.cathode_max);
54 h.
h1_strip17 =
new TH1F(PlottingUtils::GetRandomName().Data(),
55 ";Strip17 #DeltaE [" + cfg.unit_label +
"];Counts",
56 400, cfg.strip_e_min, cfg.strip_e_max);
61 ";Grid #DeltaE [" + cfg.unit_label +
62 Form(
"];Strip%d #DeltaE [", s1 ? 1 : 0) +
64 200, 0.0, cfg.grid_max, 200, cfg.strip_e_min,
65 s1 ? cfg.strip_e_max : cfg.strip0_max);
67 h.
h1_strip0 =
new TH1F(PlottingUtils::GetRandomName().Data(),
68 ";Strip0 #DeltaE [" + cfg.unit_label +
"];Counts",
69 400, cfg.strip_e_min, cfg.strip0_max);
71 h.
h1_grid =
new TH1F(PlottingUtils::GetRandomName().Data(),
72 ";Grid #DeltaE [" + cfg.unit_label +
"];Counts", 400,
78 const TString &subdir,
79 const TString &plot_suffix) {
80 TString musicName =
"music_strip_energies" + plot_suffix;
81 TString multName =
"multiplicity" + plot_suffix;
82 TString cathName =
"cathode" + plot_suffix;
83 TString strip17Name =
"strip17" + plot_suffix;
87 TString s0Name =
"strip0" + plot_suffix;
88 TString gName =
"grid" + plot_suffix;
90 TCanvas *c_music = PlottingUtils::GetConfiguredCanvas(kFALSE);
92 PlottingUtils::ConfigureAndDraw2DHistogram(h.
h_music, c_music);
93 h.
h_music->GetYaxis()->SetTitleOffset(1.4);
94 c_music->SetLeftMargin(0.18);
96 PlottingUtils::SaveFigure(c_music, musicName, subdir,
97 PlotSaveOptions::kLINEAR);
99 c_music->Write(h.
h_music->GetName(), TObject::kOverwrite);
102 TCanvas *c_mult = PlottingUtils::GetConfiguredCanvas(kFALSE);
104 PlottingUtils::ConfigureAndDrawHistogram(h.
h_mult, kBlue + 1);
106 PlottingUtils::SaveFigure(c_mult, multName, subdir, PlotSaveOptions::kLOG);
109 for (Int_t s = 1; s <= 16; s++) {
110 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
116 TLine *ridge =
nullptr;
117 if (plot_suffix ==
"_normed") {
118 ridge =
new TLine(1.0, 0.0, 0.0, 1.0);
119 ridge->SetLineColor(kRed + 1);
120 ridge->SetLineStyle(2);
121 ridge->SetLineWidth(2);
125 PlottingUtils::SaveFigure(c, TString(
"long_vs_short_s") + s + plot_suffix,
126 subdir, PlotSaveOptions::kLINEAR);
130 if (TVirtualPad *p = c->GetPad(0))
131 p->GetListOfPrimitives()->Remove(ridge);
138 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
140 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_cathode, kBlue + 1);
142 PlottingUtils::SaveFigure(c, cathName, subdir, PlotSaveOptions::kLOG);
149 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
151 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_strip17, kBlue + 1);
153 PlottingUtils::SaveFigure(c, strip17Name, subdir, PlotSaveOptions::kLOG);
160 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
165 PlottingUtils::SaveFigure(c, s0gName, subdir, PlotSaveOptions::kLINEAR);
171 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
173 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_strip0, kBlue + 1);
175 PlottingUtils::SaveFigure(c, s0Name, subdir, PlotSaveOptions::kLOG);
181 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
183 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_grid, kBlue + 1);
185 PlottingUtils::SaveFigure(c, gName, subdir, PlotSaveOptions::kLOG);
191 for (Int_t s = 1; s <= 16; s++)
210 const TString &save_name,
211 const TString &subdir, Double_t y_min,
212 Double_t y_max,
const char *y_title) {
218 TH2F *frame =
new TH2F(PlottingUtils::GetRandomName().Data(),
219 Form(
";Strip;%s", y_title), s_hi - s_lo + 1,
220 s_lo - 0.5, s_hi + 0.5, 100, y_min, y_max);
222 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
226 for (Int_t i = 0; i < Int_t(traces.size()); i++) {
227 traces[i]->SetLineColor(kBlack);
228 traces[i]->SetLineWidth(1);
229 traces[i]->Draw(
"L SAME");
233 PlottingUtils::SaveFigure(c, save_name, subdir, PlotSaveOptions::kLINEAR);
239 const TString &file_label) {
240 TString input_filepath = input_filename +
".root";
242 TFile *input_file = IO::OpenForWriting(input_filepath,
"UPDATE");
243 if (!input_file || input_file->IsZombie()) {
244 std::cerr <<
"[" << file_label
245 <<
"] cannot open UPDATE for normed summary: " << input_filepath
251 TTree *input_tree =
static_cast<TTree *
>(input_file->Get(
"events"));
253 std::cerr <<
"[" << file_label <<
"] no events tree for normed summary"
264 <<
"] no calibration in events file; skipping normed summary build"
275 cfg.unit_label =
"a.u.";
276 cfg.strip_e_min = strip_e_min;
277 cfg.strip_e_max = strip_e_max;
278 cfg.odd_even_split = kFALSE;
279 cfg.left_odd_max = strip_e_max;
280 cfg.left_even_max = strip_e_max;
281 cfg.right_odd_max = strip_e_max;
282 cfg.right_even_max = strip_e_max;
283 cfg.cathode_max = 1.0;
286 cfg.grid_max = strip_e_max;
287 cfg.strip0_max = strip_e_max;
288 cfg.music_energy_bins = 400;
293 Long64_t n_entries = input_tree->GetEntries();
295 << n_entries <<
" events..." << std::endl;
298 std::vector<TGraph *> sample_traces;
299 Long64_t sample_stride = 0;
301 sample_stride = n_entries / Long64_t(
Constants::cfg.SAVE_SAMPLE_TRACES);
302 if (sample_stride < 1)
306 for (Long64_t j = 0; j < n_entries; j++) {
307 input_tree->GetEntry(j);
310 for (Int_t s = 0; s < 18; s++)
313 for (Int_t s = 1; s <= 16; s++) {
314 const Bool_t lIsLong = (s % 2) != 0;
316 lIsLong ? ev.
right[s - 1] : ev.
left[s - 1],
317 lIsLong ? ev.
left[s - 1] : ev.
right[s - 1]);
339 h.
h_mult->Fill(Double_t(mult));
342 if (sample_stride > 0 && j % sample_stride == 0 &&
343 Int_t(sample_traces.size()) <
Constants::cfg.SAVE_SAMPLE_TRACES) {
352 TString subdir =
"events_summary_normed/" + file_label;
356 if (!sample_traces.empty()) {
358 strip_e_min, strip_e_max,
"#DeltaE [a.u.]");
362 for (Int_t i = 0; i < Int_t(sample_traces.size()); i++)
363 delete sample_traces[i];
static void SaveSampleTraces(const std::vector< TGraph * > &traces, const TString &save_name, const TString &subdir, Double_t y_min, Double_t y_max, const char *y_title)
Draw a set of traces overlaid on one frame and save it.