7 "MUSIC strip energies (complete events);Strip;#DeltaE [" +
10 new TH2F(PlottingUtils::GetRandomName().Data(), musicTitle, 18, -0.5,
11 17.5, cfg.music_energy_bins, cfg.strip_e_min, cfg.strip_e_max);
13 new TH1F(PlottingUtils::GetRandomName().Data(),
14 "Event multiplicity (complete events);Multiplicity;Counts", 36,
17 for (Int_t s = 1; s <= 16; s++) {
18 Double_t lMax = cfg.strip_e_max;
19 Double_t rMax = cfg.strip_e_max;
20 if (cfg.odd_even_split) {
21 lMax = (s % 2 == 0) ? cfg.left_even_max : cfg.left_odd_max;
22 rMax = (s % 2 == 0) ? cfg.right_even_max : cfg.right_odd_max;
27 const Bool_t lIsLong = (s % 2) != 0;
28 Double_t shortMax = lIsLong ? rMax : lMax;
29 Double_t longMax = lIsLong ? lMax : rMax;
36 if (shortMax == longMax) {
37 longMax = cfg.strip_e_max;
38 shortMax = 0.25 * cfg.strip_e_max;
41 Form(
";Strip %d Short (%c) #DeltaE [", s, lIsLong ?
'R' :
'L') +
42 cfg.unit_label +
"];" +
43 Form(
"Strip %d Long (%c) #DeltaE [", s, lIsLong ?
'L' :
'R') +
46 new TH2F(PlottingUtils::GetRandomName().Data(), rlTitle, 300,
47 cfg.strip_e_min, shortMax, 300, cfg.strip_e_min, longMax);
51 h.
h1_cathode =
new TH1F(PlottingUtils::GetRandomName().Data(),
52 ";Cathode #DeltaE [" + cfg.unit_label +
"];Counts",
53 400, 0.0, cfg.cathode_max);
55 h.
h1_strip17 =
new TH1F(PlottingUtils::GetRandomName().Data(),
56 ";Strip17 #DeltaE [" + cfg.unit_label +
"];Counts",
57 400, cfg.strip_e_min, cfg.strip_e_max);
61 new TH2F(PlottingUtils::GetRandomName().Data(),
62 ";Grid #DeltaE [" + cfg.unit_label +
"];Strip0 #DeltaE [" +
64 200, 0.0, cfg.grid_max, 200, cfg.strip_e_min, cfg.strip0_max);
66 h.
h1_strip0 =
new TH1F(PlottingUtils::GetRandomName().Data(),
67 ";Strip0 #DeltaE [" + cfg.unit_label +
"];Counts",
68 400, cfg.strip_e_min, cfg.strip0_max);
70 h.
h1_grid =
new TH1F(PlottingUtils::GetRandomName().Data(),
71 ";Grid #DeltaE [" + cfg.unit_label +
"];Counts", 400,
77 const TString &subdir,
78 const TString &plot_suffix) {
79 TString musicName =
"music_strip_energies" + plot_suffix;
80 TString multName =
"multiplicity" + plot_suffix;
81 TString cathName =
"cathode" + plot_suffix;
82 TString strip17Name =
"strip17" + plot_suffix;
83 TString s0gName =
"strip0_vs_grid" + plot_suffix;
84 TString s0Name =
"strip0" + plot_suffix;
85 TString gName =
"grid" + plot_suffix;
87 TCanvas *c_music = PlottingUtils::GetConfiguredCanvas(kFALSE);
89 PlottingUtils::ConfigureAndDraw2DHistogram(h.
h_music, c_music);
90 h.
h_music->GetYaxis()->SetTitleOffset(1.4);
91 c_music->SetLeftMargin(0.18);
93 PlottingUtils::SaveFigure(c_music, musicName, subdir,
94 PlotSaveOptions::kLINEAR);
96 c_music->Write(h.
h_music->GetName(), TObject::kOverwrite);
99 TCanvas *c_mult = PlottingUtils::GetConfiguredCanvas(kFALSE);
101 PlottingUtils::ConfigureAndDrawHistogram(h.
h_mult, kBlue + 1);
103 PlottingUtils::SaveFigure(c_mult, multName, subdir, PlotSaveOptions::kLOG);
106 for (Int_t s = 1; s <= 16; s++) {
107 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
115 TLine *ridge =
nullptr;
116 if (plot_suffix ==
"_normed") {
117 ridge =
new TLine(1.0, 0.0, 0.0, 1.0);
118 ridge->SetLineColor(kRed + 1);
119 ridge->SetLineStyle(2);
120 ridge->SetLineWidth(2);
124 PlottingUtils::SaveFigure(c, TString(
"long_vs_short_s") + s + plot_suffix,
125 subdir, PlotSaveOptions::kLINEAR);
129 if (TVirtualPad *p = c->GetPad(0))
130 p->GetListOfPrimitives()->Remove(ridge);
137 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
139 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_cathode, kBlue + 1);
141 PlottingUtils::SaveFigure(c, cathName, subdir, PlotSaveOptions::kLOG);
148 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
150 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_strip17, kBlue + 1);
152 PlottingUtils::SaveFigure(c, strip17Name, subdir, PlotSaveOptions::kLOG);
159 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
164 PlottingUtils::SaveFigure(c, s0gName, subdir, PlotSaveOptions::kLINEAR);
170 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
172 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_strip0, kBlue + 1);
174 PlottingUtils::SaveFigure(c, s0Name, subdir, PlotSaveOptions::kLOG);
180 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
182 PlottingUtils::ConfigureAndDrawHistogram(h.
h1_grid, kBlue + 1);
184 PlottingUtils::SaveFigure(c, gName, subdir, PlotSaveOptions::kLOG);
190 for (Int_t s = 1; s <= 16; s++)
209 const TString &save_name,
210 const TString &subdir, Double_t y_min,
211 Double_t y_max,
const char *y_title) {
217 TH2F *frame =
new TH2F(PlottingUtils::GetRandomName().Data(),
218 Form(
";Strip;%s", y_title), s_hi - s_lo + 1,
219 s_lo - 0.5, s_hi + 0.5, 100, y_min, y_max);
221 TCanvas *c = PlottingUtils::GetConfiguredCanvas(kFALSE);
225 for (Int_t i = 0; i < Int_t(traces.size()); i++) {
226 traces[i]->SetLineColor(kBlack);
227 traces[i]->SetLineWidth(1);
228 traces[i]->Draw(
"L SAME");
232 PlottingUtils::SaveFigure(c, save_name, subdir, PlotSaveOptions::kLINEAR);
238 const TString &file_label) {
239 TString input_filepath = input_filename +
".root";
241 TFile *input_file = IO::OpenForWriting(input_filepath,
"UPDATE");
242 if (!input_file || input_file->IsZombie()) {
243 std::cerr <<
"[" << file_label
244 <<
"] cannot open UPDATE for normed summary: " << input_filepath
250 TTree *input_tree =
static_cast<TTree *
>(input_file->Get(
"events"));
252 std::cerr <<
"[" << file_label <<
"] no events tree for normed summary"
263 <<
"] no calibration in events file; skipping normed summary build"
274 cfg.unit_label =
"a.u.";
275 cfg.strip_e_min = strip_e_min;
276 cfg.strip_e_max = strip_e_max;
277 cfg.odd_even_split = kFALSE;
278 cfg.left_odd_max = strip_e_max;
279 cfg.left_even_max = strip_e_max;
280 cfg.right_odd_max = strip_e_max;
281 cfg.right_even_max = strip_e_max;
282 cfg.cathode_max = 1.0;
283 cfg.strip17_max = strip_e_max;
285 cfg.strip0_max = strip_e_max;
286 cfg.music_energy_bins = 400;
291 Long64_t n_entries = input_tree->GetEntries();
292 std::cout <<
"[" << file_label <<
"] building normed summary over "
293 << n_entries <<
" events..." << std::endl;
296 std::vector<TGraph *> sample_traces;
297 Long64_t sample_stride = 0;
299 sample_stride = n_entries / Long64_t(
Constants::cfg.SAVE_SAMPLE_TRACES);
300 if (sample_stride < 1)
304 for (Long64_t j = 0; j < n_entries; j++) {
305 input_tree->GetEntry(j);
308 for (Int_t s = 0; s < 18; s++)
311 for (Int_t s = 1; s <= 16; s++) {
312 const Bool_t lIsLong = (s % 2) != 0;
335 h.
h_mult->Fill(Double_t(mult));
338 if (sample_stride > 0 && j % sample_stride == 0 &&
339 Int_t(sample_traces.size()) <
Constants::cfg.SAVE_SAMPLE_TRACES) {
346 TString subdir =
"events_summary_normed/" + file_label;
350 if (!sample_traces.empty()) {
352 strip_e_min, strip_e_max,
"#DeltaE [a.u.]");
356 for (Int_t i = 0; i < Int_t(sample_traces.size()); i++)
357 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.