Skip to content

Commit

Permalink
Update plot_calo_energy_resolution.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BrieucF committed Mar 21, 2024
1 parent 744609c commit 61fab36
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
f = ROOT.TFile(sys.argv[1])
events = f.Get("events")

c = ROOT.TCanvas("c_energyResolution", "")
# raw clusters
c = ROOT.TCanvas("c_clusterEnergyResolution", "")
h = ROOT.TH1F("h_clusterEnergyResolution", ";ECal Barrel Cluster Energy [GeV]; Number of Clusters", 100, 5, 15)
events.Draw("CaloClusters.energy >> h_clusterEnergyResolution")
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", "_clusterEnergyResolution.png"))

h = ROOT.TH1F("h_energyResolution", ";ECal Barrel Cluster Energy [GeV]; Number of Clusters", 100, 5, 15)
events.Draw("CaloClusters.energy >> h_energyResolution")
# MVA calibrated clusters
c = ROOT.TCanvas("c_calibratedClusterEnergyResolution", "")
h = ROOT.TH1F("h_calibratedClusterEnergyResolution", ";ECal Barrel Calibrated Cluster Energy [GeV]; Number of Clusters", 100, 5, 15)
events.Draw("CalibratedCaloClusters.energy >> h_calibratedClusterEnergyResolution")
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)
Expand All @@ -22,4 +39,5 @@
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"))
c.Print(sys.argv[1].replace(".root", "_calibratedClusterEnergyResolution.png"))

0 comments on commit 61fab36

Please sign in to comment.