From 744609c3251f80d9430137abc2ae2145d84d76a0 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 21 Mar 2024 13:24:00 +0100 Subject: [PATCH] Add script to plot calo energy resolution --- .../plot_calo_energy_resolution.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 full-detector-simulations/FCCeeGeneralOverview/plot_calo_energy_resolution.py diff --git a/full-detector-simulations/FCCeeGeneralOverview/plot_calo_energy_resolution.py b/full-detector-simulations/FCCeeGeneralOverview/plot_calo_energy_resolution.py new file mode 100644 index 00000000..88893a46 --- /dev/null +++ b/full-detector-simulations/FCCeeGeneralOverview/plot_calo_energy_resolution.py @@ -0,0 +1,25 @@ +import sys +import ROOT + +# prevent ROOT to display anything +ROOT.gROOT.SetBatch(ROOT.kTRUE) + +f = ROOT.TFile(sys.argv[1]) +events = f.Get("events") + +c = ROOT.TCanvas("c_energyResolution", "") + +h = ROOT.TH1F("h_energyResolution", ";ECal Barrel Cluster Energy [GeV]; Number of Clusters", 100, 5, 15) +events.Draw("CaloClusters.energy >> h_energyResolution") +fit_range_min = h.GetXaxis().GetBinCenter(h.GetMaximumBin()) - 3 * h.GetRMS() +fit_range_max = h.GetXaxis().GetBinCenter(h.GetMaximumBin()) + 3 * h.GetRMS() +fit_result = h.Fit("gaus", "SQ", "", fit_range_min, fit_range_max) +mean = str(round(fit_result.Get().Parameter(1), 2)) +resolution = str(round(fit_result.Get().Parameter(2), 2)) +legend = ROOT.TLegend(0.47, 0.65, 0.8, 0.8) +legend.SetBorderSize(0) +legend.SetFillStyle(0) +legend.AddEntry(ROOT.nullptr, "#color[2]{#mu: %s GeV}"%mean, "") +legend.AddEntry(ROOT.nullptr, "#color[2]{#sigma = %s GeV}"%resolution, "") +legend.Draw() +c.Print(sys.argv[1].replace(".root", "_energyResolution.png"))