Skip to content
Snippets Groups Projects
Commit 6efe2d3a authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

modified: scripts/emcal_barrel_electrons_analysis.cxx

parent c8277630
Branches
Tags
1 merge request!20Restructuring repo
...@@ -52,73 +52,90 @@ void emcal_barrel_electrons_analysis(const char* input_fname = "sim_output/sim_e ...@@ -52,73 +52,90 @@ void emcal_barrel_electrons_analysis(const char* input_fname = "sim_output/sim_e
for (const auto& i: evt) for (const auto& i: evt)
total_edep += i.energyDeposit; total_edep += i.energyDeposit;
result.push_back(total_edep); result.push_back(total_edep);
return result; return result;
}; };
// Sampling fraction = Esampling / Ethrown // 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; std::vector<double> result;
for (const auto& E1 : thrown) { for (const auto& E1 : thrown) {
for (const auto& E2 : sampled) for (const auto& E2 : sampled)
result.push_back(E2/E1); result.push_back(E2 / E1);
} }
return result; return result;
}; };
// Define variables // Define variables
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 Histograms // Define Histograms
auto hEthr = d1.Histo1D({"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5}, "Ethr"); auto hEthr = d1.Histo1D(
auto hNhits = d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", 100, 0.0, 2000.0}, "nhits"); {"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5},
auto hEsim = d1.Histo1D({"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim"); "Ethr");
auto hfsam = d1.Histo1D({"hfsam", "Sampling Fraction; Sampling Fraction; Events", 100, 0.0, 0.1}, "fsam"); 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");
// Event Counts // Event Counts
auto nevents_thrown = d1.Count(); auto nevents_thrown = d1.Count();
std::cout << "Number of Thrown Events: " << (*nevents_thrown) << "\n"; std::cout << "Number of Thrown Events: " << (*nevents_thrown) << "\n";
// Draw Histograms // Draw Histograms
TCanvas *c1 = new TCanvas("c1", "c1", 700, 500); {
c1->SetLogy(1); TCanvas* c1 = new TCanvas("c1", "c1", 700, 500);
hEthr->GetYaxis()->SetTitleOffset(1.4); c1->SetLogy(1);
hEthr->SetLineWidth(2); auto h = hEthr->DrawCopy();
hEthr->SetLineColor(kBlue); h->GetYaxis()->SetTitleOffset(1.4);
hEthr->DrawClone(); h->SetLineWidth(2);
c1->SaveAs("results/emcal_barrel_electrons_Ethr.png"); h->SetLineColor(kBlue);
c1->SaveAs("results/emcal_barrel_electrons_Ethr.pdf"); c1->SaveAs("results/emcal_barrel_electrons_Ethr.png");
c1->SaveAs("results/emcal_barrel_electrons_Ethr.pdf");
TCanvas *c2 = new TCanvas("c2", "c2", 700, 500); }
c2->SetLogy(1);
hNhits->GetYaxis()->SetTitleOffset(1.4); {
hNhits->SetLineWidth(2); TCanvas* c2 = new TCanvas("c2", "c2", 700, 500);
hNhits->SetLineColor(kBlue); c2->SetLogy(1);
hNhits->DrawClone(); auto h = hNhits->DrawCopy();
c2->SaveAs("results/emcal_barrel_electrons_nhits.png"); h->GetYaxis()->SetTitleOffset(1.4);
c2->SaveAs("results/emcal_barrel_electrons_nhits.pdf"); h->SetLineWidth(2);
h->SetLineColor(kBlue);
TCanvas *c3 = new TCanvas("c3", "c3", 700, 500); c2->SaveAs("results/emcal_barrel_electrons_nhits.png");
c3->SetLogy(1); c2->SaveAs("results/emcal_barrel_electrons_nhits.pdf");
hEsim->GetYaxis()->SetTitleOffset(1.4); }
hEsim->SetLineWidth(2);
hEsim->SetLineColor(kBlue); {
hEsim->DrawClone(); TCanvas* c3 = new TCanvas("c3", "c3", 700, 500);
c3->SaveAs("results/emcal_barrel_electrons_Esim.png"); c3->SetLogy(1);
c3->SaveAs("results/emcal_barrel_electrons_Esim.pdf"); auto h = hEsim->DrawCopy();
h->GetYaxis()->SetTitleOffset(1.4);
TCanvas *c4 = new TCanvas("c4", "c4", 700, 500); h->SetLineWidth(2);
c4->SetLogy(1); h->SetLineColor(kBlue);
hfsam->GetYaxis()->SetTitleOffset(1.4); c3->SaveAs("results/emcal_barrel_electrons_Esim.png");
hfsam->SetLineWidth(2); c3->SaveAs("results/emcal_barrel_electrons_Esim.pdf");
hfsam->SetLineColor(kBlue); }
hfsam->Fit("gaus","","",0.01,0.1);
hfsam->GetFunction("gaus")->SetLineWidth(2); {
hfsam->GetFunction("gaus")->SetLineColor(kRed); TCanvas* c4 = new TCanvas("c4", "c4", 700, 500);
hfsam->DrawClone(); c4->SetLogy(1);
c4->SaveAs("results/emcal_barrel_electrons_fsam.png"); auto h = hfsam->DrawCopy();
c4->SaveAs("results/emcal_barrel_electrons_fsam.pdf"); h->GetYaxis()->SetTitleOffset(1.4);
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->Fit("gaus", "", "", 0.01, 0.1);
h->GetFunction("gaus")->SetLineWidth(2);
h->GetFunction("gaus")->SetLineColor(kRed);
c4->SaveAs("results/emcal_barrel_electrons_fsam.png");
c4->SaveAs("results/emcal_barrel_electrons_fsam.pdf");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment