Skip to content
Snippets Groups Projects

Rework ZDC sampling fraction determination

Merged Wouter Deconinck requested to merge zdc-sampling-fraction-analysis into master
Files
7
@@ -19,8 +19,10 @@
@@ -19,8 +19,10 @@
using ROOT::RDataFrame;
using ROOT::RDataFrame;
using namespace ROOT::VecOps;
using namespace ROOT::VecOps;
void zdc_neutrons_analysis(const char* input_fname = "sim_output/sim_zdc_uniform_neutrons.edm4hep.root")
void analysis_zdc_particles(
{
const std::string& input_fname = "sim_output/sim_zdc_uniform_neutrons.edm4hep.root",
 
const std::string& results_path = "results/far_forward/zdc/"
 
) {
// Setting for graphs
// Setting for graphs
gROOT->SetStyle("Plain");
gROOT->SetStyle("Plain");
gStyle->SetOptFit(1);
gStyle->SetOptFit(1);
@@ -59,25 +61,40 @@ void zdc_neutrons_analysis(const char* input_fname = "sim_output/sim_zdc_uniform
@@ -59,25 +61,40 @@ void zdc_neutrons_analysis(const char* input_fname = "sim_output/sim_zdc_uniform
};
};
// Define variables
// Define variables
auto d1 = d0.Define("Ethr", Ethr, {"MCParticles"})
auto d1 = d0
.Define("nhits", nhits, {"EcalBarrelHits"})
.Define("Ethr", Ethr, {"MCParticles"})
.Define("Esim", Esim, {"EcalBarrelHits"})
.Define("nhits_Ecal", nhits, {"ZDCEcalHits"})
.Define("fsam", fsam, {"Esim", "Ethr"});
.Define("Esim_Ecal", Esim, {"ZDCEcalHits"})
 
.Define("fsam_Ecal", fsam, {"Esim_Ecal", "Ethr_Ecal"})
 
.Define("nhits_Hcal", nhits, {"ZDCHcalHits"})
 
.Define("Esim_Hcal", Esim, {"ZDCHcalHits"})
 
.Define("fsam_Hcal", fsam, {"Esim_Hcal", "Ethr_Hcal"})
 
;
// Define Histograms
// Define Histograms
auto hEthr = d1.Histo1D(
auto hEthr = d1.Histo1D(
{"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5},
{"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5},
"Ethr");
"Ethr");
auto hNhits =
auto hNhits_Ecal =
d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events",
d1.Histo1D({"hNhits_Ecal", "Number of Ecal hits per events; Number of Ecal hits; Events",
100, 0.0, 2000.0},
100, 0.0, 2000.0},
"nhits");
"nhits_Ecal");
auto hEsim = d1.Histo1D(
auto hEsim_Ecal = d1.Histo1D(
{"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0},
{"hEsim_Ecal", "Ecal Energy Deposit; Ecal Energy Deposit [GeV]; Events", 100, 0.0, 1.0},
"Esim");
"Esim_Ecal");
auto hfsam = d1.Histo1D(
auto hfsam_Ecal = d1.Histo1D(
{"hfsam", "Sampling Fraction; Sampling Fraction; Events", 100, 0.0, 0.1},
{"hfsam_Ecal", "Ecal Sampling Fraction; Ecal Sampling Fraction; Events", 100, 0.0, 0.1},
"fsam");
"fsam_Ecal");
 
auto hNhits_Hcal =
 
d1.Histo1D({"hNhits_Hcal", "Number of Hcal hits per events; Number of Hcal hits; Events",
 
100, 0.0, 2000.0},
 
"nhits_Hcal");
 
auto hEsim_Hcal = d1.Histo1D(
 
{"hEsim_Hcal", "Hcal Energy Deposit; Hcal Energy Deposit [GeV]; Events", 100, 0.0, 1.0},
 
"Esim_Hcal");
 
auto hfsam_Hcal = d1.Histo1D(
 
{"hfsam_Hcal", "Hcal Sampling Fraction; Hcal Sampling Fraction; Events", 100, 0.0, 0.1},
 
"fsam_Hcal");
// Event Counts
// Event Counts
auto nevents_thrown = d1.Count();
auto nevents_thrown = d1.Count();
@@ -91,45 +108,83 @@ void zdc_neutrons_analysis(const char* input_fname = "sim_output/sim_zdc_uniform
@@ -91,45 +108,83 @@ void zdc_neutrons_analysis(const char* input_fname = "sim_output/sim_zdc_uniform
//h->GetYaxis()->SetTitleOffset(1.4);
//h->GetYaxis()->SetTitleOffset(1.4);
h->SetLineWidth(2);
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->SetLineColor(kBlue);
c1->SaveAs("results/zdc_neutrons_Ethr.png");
c1->SaveAs(TString(results_path + "/zdc_Ethr.png"));
c1->SaveAs("results/zdc_neutrons_Ethr.pdf");
c1->SaveAs(TString(results_path + "/zdc_Ethr.pdf"));
 
}
 
 
// Ecal
 
{
 
TCanvas* c2 = new TCanvas("c2", "c2", 700, 500);
 
c2->SetLogy(1);
 
auto h = hNhits_Ecal->DrawCopy();
 
//h->GetYaxis()->SetTitleOffset(1.4);
 
h->SetLineWidth(2);
 
h->SetLineColor(kBlue);
 
c2->SaveAs(TString(results_path + "/zdc_nhits_Ecal.png"));
 
c2->SaveAs(TString(results_path + "/zdc_nhits_Ecal.pdf"));
 
}
 
 
{
 
TCanvas* c3 = new TCanvas("c3", "c3", 700, 500);
 
c3->SetLogy(1);
 
auto h = hEsim_Ecal->DrawCopy();
 
//h->GetYaxis()->SetTitleOffset(1.4);
 
h->SetLineWidth(2);
 
h->SetLineColor(kBlue);
 
c3->SaveAs(TString(results_path + "/zdc_Esim_Ecal.png"));
 
c3->SaveAs(TString(results_path + "/zdc_Esim_Ecal.pdf"));
 
}
 
 
std::cout << "derp4\n";
 
{
 
TCanvas* c4 = new TCanvas("c4", "c4", 700, 500);
 
c4->SetLogy(1);
 
auto h = hfsam_Ecal->DrawCopy();
 
//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(TString(results_path + "/zdc_fsam_Ecal.png"));
 
c4->SaveAs(TString(results_path + "/zdc_fsam_Ecal.pdf"));
}
}
std::cout << "derp1\n";
 
// Hcal
{
{
TCanvas* c2 = new TCanvas("c2", "c2", 700, 500);
TCanvas* c2 = new TCanvas("c2", "c2", 700, 500);
c2->SetLogy(1);
c2->SetLogy(1);
auto h = hNhits->DrawCopy();
auto h = hNhits_Hcal->DrawCopy();
//h->GetYaxis()->SetTitleOffset(1.4);
//h->GetYaxis()->SetTitleOffset(1.4);
h->SetLineWidth(2);
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->SetLineColor(kBlue);
c2->SaveAs("results/zdc_neutrons_nhits.png");
c2->SaveAs(TString(results_path + "/zdc_nhits_Hcal.png"));
c2->SaveAs("results/zdc_neutrons_nhits.pdf");
c2->SaveAs(TString(results_path + "/zdc_nhits_Hcal.pdf"));
}
}
{
{
TCanvas* c3 = new TCanvas("c3", "c3", 700, 500);
TCanvas* c3 = new TCanvas("c3", "c3", 700, 500);
c3->SetLogy(1);
c3->SetLogy(1);
auto h = hEsim->DrawCopy();
auto h = hEsim_Hcal->DrawCopy();
//h->GetYaxis()->SetTitleOffset(1.4);
//h->GetYaxis()->SetTitleOffset(1.4);
h->SetLineWidth(2);
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->SetLineColor(kBlue);
c3->SaveAs("results/zdc_neutrons_Esim.png");
c3->SaveAs(TString(results_path + "/zdc_Esim_Hcal.png"));
c3->SaveAs("results/zdc_neutrons_Esim.pdf");
c3->SaveAs(TString(results_path + "/zdc_Esim_Hcal.pdf"));
}
}
std::cout << "derp4\n";
std::cout << "derp4\n";
{
{
TCanvas* c4 = new TCanvas("c4", "c4", 700, 500);
TCanvas* c4 = new TCanvas("c4", "c4", 700, 500);
c4->SetLogy(1);
c4->SetLogy(1);
auto h = hfsam->DrawCopy();
auto h = hfsam_Hcal->DrawCopy();
//h->GetYaxis()->SetTitleOffset(1.4);
//h->GetYaxis()->SetTitleOffset(1.4);
h->SetLineWidth(2);
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->SetLineColor(kBlue);
//h->Fit("gaus", "", "", 0.01, 0.1);
//h->Fit("gaus", "", "", 0.01, 0.1);
//h->GetFunction("gaus")->SetLineWidth(2);
//h->GetFunction("gaus")->SetLineWidth(2);
//h->GetFunction("gaus")->SetLineColor(kRed);
//h->GetFunction("gaus")->SetLineColor(kRed);
c4->SaveAs("results/zdc_neutrons_fsam.png");
c4->SaveAs(TString(results_path + "/zdc_fsam_Hcal.png"));
c4->SaveAs("results/zdc_neutrons_fsam.pdf");
c4->SaveAs(TString(results_path + "/zdc_fsam_Hcal.pdf"));
}
}
}
}
Loading