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
1 file
+ 28
40
Compare changes
  • Side-by-side
  • Inline
@@ -55,6 +55,9 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
ROOT::EnableImplicitMT();
ROOT::RDataFrame d0("events", input_fname);
// Sampling Fraction
double samp_frac = 1.0;
// Thrown Energy [GeV]
auto Ethr = [](std::vector<dd4pod::Geant4ParticleData> const& input) {
std::vector<double> result;
@@ -86,53 +89,56 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
return result;
};
// Energy Resolution = Esampling - Ethrown
auto eResol = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
// Energy Resolution = Esampling/Sampling_fraction - Ethrown
auto eResol = [samp_frac](const std::vector<double>& sampled, const std::vector<double>& thrown) {
std::vector<double> result;
auto it_sam = sampled.cbegin();
auto it_thr = thrown.cbegin();
for (; it_sam != sampled.end() && it_thr != thrown.end(); ++it_sam, ++it_thr) {
result.push_back(*it_sam - *it_thr);
result.push_back(*it_sam / samp_frac - *it_thr);
}
return result;
};
// Relative Energy Resolution = (Esampling - Ethrown)/Ethrown
auto eResol_rel = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
// Relative Energy Resolution = (Esampling/Sampling fraction - Ethrown)/Ethrown
auto eResol_rel = [samp_frac](const std::vector<double>& sampled, const std::vector<double>& thrown) {
std::vector<double> result;
auto it_sam = sampled.cbegin();
auto it_thr = thrown.cbegin();
for (; it_sam != sampled.end() && it_thr != thrown.end(); ++it_sam, ++it_thr) {
result.push_back((*it_sam - *it_thr) / *it_thr);
result.push_back((*it_sam / samp_frac - *it_thr) / *it_thr);
}
return result;
};
// Relative Energy Resolution = (Esampling - Ethrown)/Ethrown
// Returns the pdgID of the particle
auto getpid = [](std::vector<dd4pod::Geant4ParticleData> const& input) {
return input[2].pdgID;
};
// Define variables
auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"})
.Define("nhits", nhits, {"EcalBarrelHits"})
.Define("Esim", Esim, {"EcalBarrelHits"})
.Define("Esim_hcal", Esim, {"HcalBarrelHits"})
.Define("Esim_crycal", Esim, {"CrystalEcalHits"})
.Define("fsam", fsam, {"Esim","Ethr"})
.Define("dE", eResol, {"Esim","Ethr"})
.Define("dE_rel", eResol_rel, {"Esim","Ethr"})
.Define("pid", getpid, {"mcparticles"})
;
auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"})
.Define("nhits", nhits, {"EcalBarrelHits"})
.Define("Esim", Esim, {"EcalBarrelHits"})
.Define("fsam", fsam, {"Esim","Ethr"})
.Define("pid", getpid, {"mcparticles"})
;
// Define Histograms
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 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 hpid = d1.Histo1D({"hpid", "PID; PID; Count", 100, -220, 220}, "pid");
auto hhcal = d1.Histo1D({"hhcal", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim_hcal");
auto hcrycal = d1.Histo1D({"hcrycal", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim_crycal");
auto hpid = d1.Histo1D({"hpid", "PID; PID; Count", 100, -220, 220}, "pid");
// Set sampling Fraction, ideally this will be taken from a json file
samp_frac = hfsam -> GetMean();
auto d2 = d1.Define("dE", eResol, {"Esim","Ethr"})
.Define("dE_rel", eResol_rel, {"Esim","Ethr"})
;
// Event Counts
auto nevents_thrown = d1.Count();
@@ -187,27 +193,9 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
c5->SaveAs("results/emcal_barrel_pions_pid.png");
c5->SaveAs("results/emcal_barrel_pions_pid.pdf");
TCanvas *c6 = new TCanvas("c6", "c6", 700, 500);
c6->SetLogy(1);
hhcal->GetYaxis()->SetTitleOffset(1.4);
hhcal->SetLineWidth(2);
hhcal->SetLineColor(kBlue);
hhcal->DrawClone();
c6->SaveAs("results/emcal_barrel_pions_hcal.png");
c6->SaveAs("results/emcal_barrel_pions_hcal.pdf");
TCanvas *c7 = new TCanvas("c7", "c7", 700, 500);
c7->SetLogy(1);
hcrycal->GetYaxis()->SetTitleOffset(1.4);
hcrycal->SetLineWidth(2);
hcrycal->SetLineColor(kBlue);
hcrycal->DrawClone();
c7->SaveAs("results/emcal_barrel_pions_crycal.png");
c7->SaveAs("results/emcal_barrel_pions_crycal.pdf");
//Energy Resolution Work
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, -2, 2}, "dE_rel");//changed from 100
auto hdE = d2.Histo1D({"hdE", "dE; dE[GeV]; Events", 20, -7.5, 7.5}, "dE");//changed from 100
auto hdE_rel = d2.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 20, -2, 2}, "dE_rel");//changed from 100
hdE_rel->Fit("gaus", "", "", -2, 2);
double* res = hdE_rel->GetFunction("gaus")->GetParameters();
Loading