Skip to content
Snippets Groups Projects

Resolve "pi0 resolution for ECal barrel"

Merged Marshall Scott requested to merge 19-pi0-resolution-for-ecal-barrel into master
Compare and Show latest version
2 files
+ 22
41
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -9,9 +9,9 @@
@@ -9,9 +9,9 @@
#include "dd4pod/Geant4ParticleCollection.h"
#include "dd4pod/Geant4ParticleCollection.h"
#include "dd4pod/CalorimeterHitCollection.h"
#include "dd4pod/CalorimeterHitCollection.h"
//#include <detector_benchmarks/include/benchmark.h>
#include "benchmark.h"
//#include "mt.h"
#include "mt.h"
//#include "util.h"
#include "util.h"
#include "TCanvas.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TStyle.h"
@@ -19,9 +19,7 @@
@@ -19,9 +19,7 @@
#include "TH1.h"
#include "TH1.h"
#include "TF1.h"
#include "TF1.h"
#include "TH1D.h"
#include "TH1D.h"
#include <TFitResult.h>
#include "TFitResult.h"
#include "TSystem.h"
#include <fstream>
using ROOT::RDataFrame;
using ROOT::RDataFrame;
using namespace ROOT::VecOps;
using namespace ROOT::VecOps;
@@ -44,7 +42,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -44,7 +42,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
//TODO: Change test_tag to something else
//TODO: Change test_tag to something else
std:string detector = "Barrel_emcal";
std:string detector = "Barrel_emcal";
double resolutionTarget = 0.1;
double resolutionTarget = 0.1;
/*
eic::util::Test pion0_Energy_resolution{
eic::util::Test pion0_Energy_resolution{
{{"name", fmt::format("{}_energy_resolution", test_tag)},
{{"name", fmt::format("{}_energy_resolution", test_tag)},
{"title", "Pion0 Energy resolution"},
{"title", "Pion0 Energy resolution"},
@@ -52,7 +50,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -52,7 +50,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
fmt::format("Pion0 energy resolution with {}, estimated using a Gaussian fit.", detector)},
fmt::format("Pion0 energy resolution with {}, estimated using a Gaussian fit.", detector)},
{"quantity", "resolution (in %)"},
{"quantity", "resolution (in %)"},
{"target", std::to_string(resolutionTarget)}}};
{"target", std::to_string(resolutionTarget)}}};
*/
ROOT::EnableImplicitMT();
ROOT::EnableImplicitMT();
ROOT::RDataFrame d0("events", input_fname);
ROOT::RDataFrame d0("events", input_fname);
@@ -85,18 +83,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -85,18 +83,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
return result;
return result;
};
};
// Sampling fraction = Esampling / Ethrown
// Layer Sampling fraction = Esampling / Ethrown
auto fsam = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
auto fsam = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
std::vector<double> result;
for (const auto& E1 : thrown) {
for (const auto& E2 : sampled)
result.push_back(E2/E1);
}
return result;
};
// Sampling fraction = Esampling / Ethrown, revised
auto fsam2 = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
std::vector<double> result;
std::vector<double> result;
auto it_sam = sampled.cbegin();
auto it_sam = sampled.cbegin();
auto it_thr = thrown.cbegin();
auto it_thr = thrown.cbegin();
@@ -117,13 +105,13 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -117,13 +105,13 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
return result;
return result;
};
};
// Relative Energy Resolution = (Esampling - Ethrown)/Esampling
// Relative Energy Resolution = (Esampling - Ethrown)/Ethrown
auto eResol_rel = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
auto eResol_rel = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
std::vector<double> result;
std::vector<double> result;
auto it_sam = sampled.cbegin();
auto it_sam = sampled.cbegin();
auto it_thr = thrown.cbegin();
auto it_thr = thrown.cbegin();
for (; it_sam != sampled.end() && it_thr != thrown.end(); ++it_sam, ++it_thr) {
for (; it_sam != sampled.end() && it_thr != thrown.end(); ++it_sam, ++it_thr) {
result.push_back((*it_sam - *it_thr) / *it_sam);
result.push_back((*it_sam - *it_thr) / *it_thr);
}
}
return result;
return result;
};
};
@@ -132,19 +120,16 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -132,19 +120,16 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"})
auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"})
.Define("nhits", nhits, {"EcalBarrelHits"})
.Define("nhits", nhits, {"EcalBarrelHits"})
.Define("Esim", Esim, {"EcalBarrelHits"})
.Define("Esim", Esim, {"EcalBarrelHits"})
//.Define("fsam", fsam, {"Esim","Ethr"})
.Define("fsam", fsam, {"Esim","Ethr"})
.Define("fsam", fsam2, {"Esim","Ethr"})
.Define("dE", eResol, {"Esim","Ethr"})
.Define("dE", eResol, {"Esim", "Ethr"})
.Define("dE_rel", eResol_rel, {"Esim","Ethr"})
.Define("dE_rel", eResol_rel, {"Esim", "Ethr"})
.Define("charge", {"charge"})
;
;
// Define Histograms
// Define Histograms
auto hEthr = d1.Histo1D({"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5}, "Ethr");
auto hEthr = d1.Histo1D({"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5}, "Ethr");
auto hNhits = d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", 100, 0.0, 2000.0}, "nhits");
auto hNhits = d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", 100, 0.0, 2000.0}, "nhits");
auto hEsim = d1.Histo1D({"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim");
auto hEsim = d1.Histo1D({"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim");
auto hfsam = d1.Histo1D({"hfsam", "Sampling Fraction; Sampling Fraction; Events", 100, 0.0, 0.1}, "fsam");
auto hfsam = d1.Histo1D({"hfsam", "Layer Sampling Fraction; Layer Sampling Fraction; Events", 100, 0.0, 0.1}, "fsam");
auto hcharge = d1.Histo1D({"hcharge", "charge; charge; Count", 10, -2, 2}, "charge");
// Event Counts
// Event Counts
auto nevents_thrown = d1.Count();
auto nevents_thrown = d1.Count();
@@ -190,19 +175,11 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -190,19 +175,11 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
c4->SaveAs("results/emcal_barrel_pions_fsam.png");
c4->SaveAs("results/emcal_barrel_pions_fsam.png");
c4->SaveAs("results/emcal_barrel_pions_fsam.pdf");
c4->SaveAs("results/emcal_barrel_pions_fsam.pdf");
TCanvas *c5 = new TCanvas("c5", "c5", 700, 500);
hcharge->GetYaxis()->SetTitleOffset(1.4);
hcharge->SetLineWidth(2);
hcharge->SetLineColor(kBlue);
hcharge->DrawClone();
c5->SaveAs("results/emcal_barrel_pions_charge.png");
c5->SaveAs("results/emcal_barrel_pions_chage.pdf");
//Energy Resolution Work
//Energy Resolution Work
auto hdE = d1.Histo1D({"hdE", "dE; dE[GeV]; Events", 20, -7.5, 7.5}, "dE");//changed from 100
auto hdE = d1.Histo1D({"hdE", "dE; dE[GeV]; Events", 20, -7.5, 7.5}, "dE");//changed from 100
auto hdE_rel = d1.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 20, -7.5, 7.5}, "dE_rel");//changed from 100
auto hdE_rel = d1.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 20, -2, 2}, "dE_rel");//changed from 100
//hdE_rel->Fit("gaus", "", "", -7.5, 7.5);
hdE_rel->Fit("gaus", "", "", -2, 2);
//double* res = hdE_rel->GetFunction("gaus")->GetParameters();
double* res = hdE_rel->GetFunction("gaus")->GetParameters();
//Pass/Fail
//Pass/Fail
/*
/*
@@ -228,8 +205,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
@@ -228,8 +205,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
hdE_rel->GetYaxis()->SetTitleOffset(1.4);
hdE_rel->GetYaxis()->SetTitleOffset(1.4);
hdE_rel->SetLineWidth(2);
hdE_rel->SetLineWidth(2);
hdE_rel->SetLineColor(kBlue);
hdE_rel->SetLineColor(kBlue);
//hdE_rel->GetFunction("gaus")->SetLineWidth(2);
hdE_rel->GetFunction("gaus")->SetLineWidth(2);
//hdE_rel->GetFunction("gaus")->SetLineColor(kRed);
hdE_rel->GetFunction("gaus")->SetLineColor(kRed);
hdE_rel->DrawClone();
hdE_rel->DrawClone();
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png");
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png");
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf");
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf");
Loading