From 4d8ab8d2ea33ecc9d794e46fdcea2584dbe318e4 Mon Sep 17 00:00:00 2001 From: Marshall Scott <mbscott@anl.gov> Date: Wed, 28 Apr 2021 09:51:26 -0400 Subject: [PATCH] Changed resolution to (thr-sam)/thr --- .../scripts/emcal_barrel_pions_analysis.cxx | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx b/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx index 44058a21..c3a478d0 100644 --- a/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx +++ b/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx @@ -117,24 +117,17 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal return result; }; - // Relative Energy Resolution = (Esampling - Ethrown)/Esampling + // Relative Energy Resolution = (Esampling - Ethrown)/Ethrownnnn auto eResol_rel = [](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_sam); + result.push_back((*it_sam - *it_thr) / *it_thr); } return result; }; - // Thrown Energy [GeV] - auto charge = [](std::vector<dd4pod::Geant4ParticleData> const& input) { - std::vector<double> result; - result.push_back(input[2].charge); - return result; - }; - // Define variables auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"}) .Define("nhits", nhits, {"EcalBarrelHits"}) @@ -143,7 +136,6 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal .Define("fsam", fsam2, {"Esim","Ethr"}) .Define("dE", eResol, {"Esim", "Ethr"}) .Define("dE_rel", eResol_rel, {"Esim", "Ethr"}) - .Define("charge", charge, {"mcparticles"}) ; // Define Histograms @@ -151,7 +143,6 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal 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 hcharge = d1.Histo1D({"hcharge", "charge; charge; Count", 10, -2, 2}, "charge"); // Event Counts auto nevents_thrown = d1.Count(); @@ -197,19 +188,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.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 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 - //hdE_rel->Fit("gaus", "", "", -7.5, 7.5); - //double* res = hdE_rel->GetFunction("gaus")->GetParameters(); + hdE_rel->Fit("gaus", "", "", -7.5, 7.5); + double* res = hdE_rel->GetFunction("gaus")->GetParameters(); //Pass/Fail /* @@ -219,7 +202,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal pion0_energy_resolution.fail(res[2]); } */ - //std::printf("Energy Resolution is %f\n", res[2]); + std::printf("Energy Resolution is %f\n", res[2]); //Energy Resolution Histogram Plotting auto *cdE = new TCanvas("cdE", "cdE", 700, 500); @@ -235,8 +218,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal hdE_rel->GetYaxis()->SetTitleOffset(1.4); hdE_rel->SetLineWidth(2); hdE_rel->SetLineColor(kBlue); - //hdE_rel->GetFunction("gaus")->SetLineWidth(2); - //hdE_rel->GetFunction("gaus")->SetLineColor(kRed); + hdE_rel->GetFunction("gaus")->SetLineWidth(2); + hdE_rel->GetFunction("gaus")->SetLineColor(kRed); hdE_rel->DrawClone(); cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png"); cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf"); -- GitLab