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

modified: scripts/emcal_barrel_pi0_analysis.cxx

parent 5870d400
No related branches found
No related tags found
1 merge request!70Script is still broken.
...@@ -117,121 +117,126 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b ...@@ -117,121 +117,126 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
auto hpid = d1.Histo1D({"hpid", "PID; PID; Count", 100, -220, 220}, "pid"); auto hpid = d1.Histo1D({"hpid", "PID; PID; Count", 100, -220, 220}, "pid");
auto hdau = d1.Histo1D({"hdau", "Number of Daughters; Number of Daughters; Count", 10, 0, 10}, "dau"); auto hdau = d1.Histo1D({"hdau", "Number of Daughters; Number of Daughters; Count", 10, 0, 10}, "dau");
// put this line above GetMean below so it can be lazily evaluated with the histgorams.
auto nevents_thrown = d1.Count();
const double meanE = hEthr->GetMean(); const double meanE = hEthr->GetMean();
// Event Counts // Event Counts
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); TCanvas *c1 = new TCanvas("c1", "c1", 700, 500);
c1->SetLogy(1); c1->SetLogy(1);
fmt::print("0\n");
auto h1 = hEthr->DrawCopy(); auto h1 = hEthr->DrawCopy();
h1->GetYaxis()->SetTitleOffset(1.4); //h1->GetYaxis()->SetTitleOffset(1.4);
h1->SetLineWidth(2); h1->SetLineWidth(2);
h1->SetLineColor(kBlue); h1->SetLineColor(kBlue);
c1->SaveAs("results/emcal_barrel_pi0_Ethr.png"); c1->SaveAs("results/emcal_barrel_pi0_Ethr.png");
c1->SaveAs("results/emcal_barrel_pi0_Ethr.pdf"); c1->SaveAs("results/emcal_barrel_pi0_Ethr.pdf");
TCanvas *c2 = new TCanvas("c2", "c2", 700, 500); fmt::print("1\n");
c2->SetLogy(1);
h1 = hNhits->DrawCopy(); //TCanvas *c2 = new TCanvas("c2", "c2", 700, 500);
h1->GetYaxis()->SetTitleOffset(1.4); //c2->SetLogy(1);
h1->SetLineWidth(2); //h1 = hNhits->DrawCopy();
h1->SetLineColor(kBlue); //h1->GetYaxis()->SetTitleOffset(1.4);
c2->SaveAs("results/emcal_barrel_pi0_nhits.png"); //h1->SetLineWidth(2);
c2->SaveAs("results/emcal_barrel_pi0_nhits.pdf"); //h1->SetLineColor(kBlue);
//c2->SaveAs("results/emcal_barrel_pi0_nhits.png");
TCanvas *c3 = new TCanvas("c3", "c3", 700, 500); //c2->SaveAs("results/emcal_barrel_pi0_nhits.pdf");
c3->SetLogy(1);
h1 = hEsim->DrawCopy(); //TCanvas *c3 = new TCanvas("c3", "c3", 700, 500);
h1->GetYaxis()->SetTitleOffset(1.4); //c3->SetLogy(1);
h1->SetLineWidth(2); //h1 = hEsim->DrawCopy();
h1->SetLineColor(kBlue); //h1->GetYaxis()->SetTitleOffset(1.4);
c3->SaveAs("results/emcal_barrel_pi0_Esim.png"); //h1->SetLineWidth(2);
c3->SaveAs("results/emcal_barrel_pi0_Esim.pdf"); //h1->SetLineColor(kBlue);
//c3->SaveAs("results/emcal_barrel_pi0_Esim.png");
TCanvas *c4 = new TCanvas("c4", "c4", 700, 500); //c3->SaveAs("results/emcal_barrel_pi0_Esim.pdf");
c4->SetLogy(1);
h1 = hfsam->DrawCopy(); //TCanvas *c4 = new TCanvas("c4", "c4", 700, 500);
h1->GetYaxis()->SetTitleOffset(1.4); //c4->SetLogy(1);
h1->SetLineWidth(2); //h1 = hfsam->DrawCopy();
h1->SetLineColor(kBlue); //h1->GetYaxis()->SetTitleOffset(1.4);
h1->Fit("gaus","","",0.005,0.1); //h1->SetLineWidth(2);
h1->GetFunction("gaus")->SetLineWidth(2); //h1->SetLineColor(kBlue);
h1->GetFunction("gaus")->SetLineColor(kRed); //h1->Fit("gaus","","",0.005,0.1);
c4->SaveAs("results/emcal_barrel_pi0_fsam.png"); //h1->GetFunction("gaus")->SetLineWidth(2);
c4->SaveAs("results/emcal_barrel_pi0_fsam.pdf"); //h1->GetFunction("gaus")->SetLineColor(kRed);
//c4->SaveAs("results/emcal_barrel_pi0_fsam.png");
TCanvas *c5 = new TCanvas("c5", "c5", 700, 500); //c4->SaveAs("results/emcal_barrel_pi0_fsam.pdf");
c5->SetLogy(1);
h1 = hpid->DrawCopy(); //TCanvas *c5 = new TCanvas("c5", "c5", 700, 500);
h1->GetYaxis()->SetTitleOffset(1.4); //c5->SetLogy(1);
h1->SetLineWidth(2); //h1 = hpid->DrawCopy();
h1->SetLineColor(kBlue); //h1->GetYaxis()->SetTitleOffset(1.4);
c5->SaveAs("results/emcal_barrel_pi0_pid.png"); //h1->SetLineWidth(2);
c5->SaveAs("results/emcal_barrel_pi0_pid.pdf"); //h1->SetLineColor(kBlue);
//c5->SaveAs("results/emcal_barrel_pi0_pid.png");
TCanvas *c6 = new TCanvas("c6", "c6", 700, 500); //c5->SaveAs("results/emcal_barrel_pi0_pid.pdf");
c5->SetLogy(1);
h1 = hdau->DrawCopy(); //TCanvas *c6 = new TCanvas("c6", "c6", 700, 500);
h1->GetYaxis()->SetTitleOffset(1.4); //c5->SetLogy(1);
h1->SetLineWidth(2); //h1 = hdau->DrawCopy();
h1->SetLineColor(kBlue); //h1->GetYaxis()->SetTitleOffset(1.4);
c6->SaveAs("results/emcal_barrel_pi0_dau.png"); //h1->SetLineWidth(2);
c6->SaveAs("results/emcal_barrel_pi0_dau.pdf"); //h1->SetLineColor(kBlue);
//c6->SaveAs("results/emcal_barrel_pi0_dau.png");
// Energy Resolution Calculation //c6->SaveAs("results/emcal_barrel_pi0_dau.pdf");
std::string test_tag = "Barrel_emcal_pi0";// TODO: Change test_tag to something else
std:string detEle = "Barrel_emcal"; //// Energy Resolution Calculation
//std::string test_tag = "Barrel_emcal_pi0";// TODO: Change test_tag to something else
// Energy resolution in the barrel region (-1 < eta < 1) //std:string detEle = "Barrel_emcal";
// Taken from : Initial considerations for EMCal of the EIC detector by A. Bazilevsky
// sigma_E / E = 12% / E^0.5 convoluted with 2% //// Energy resolution in the barrel region (-1 < eta < 1)
// sigma_E / E = [ (0.12/E^0.5)^2 + 0.02^2]^0.5, with E in [GeV] //// Taken from : Initial considerations for EMCal of the EIC detector by A. Bazilevsky
//// sigma_E / E = 12% / E^0.5 convoluted with 2%
double resolutionTarget = TMath::Sqrt(0.12 * 0.12 / meanE + 0.02 * 0.02); //// sigma_E / E = [ (0.12/E^0.5)^2 + 0.02^2]^0.5, with E in [GeV]
//
common_bench::Test pi0_energy_resolution{ //double resolutionTarget = TMath::Sqrt(0.12 * 0.12 / meanE + 0.02 * 0.02);
{{"name", fmt::format("{}_energy_resolution", test_tag)},
{"title", "Pi0 Energy resolution"}, //common_bench::Test pi0_energy_resolution{
{"description", // {{"name", fmt::format("{}_energy_resolution", test_tag)},
fmt::format("Pi0 energy resolution for {}, estimated using a Gaussian fit.", detEle)}, // {"title", "Pi0 Energy resolution"},
{"quantity", "resolution (in %)"}, // {"description",
{"target", std::to_string(resolutionTarget)}} // fmt::format("Pi0 energy resolution for {}, estimated using a Gaussian fit.", detEle)},
}; // {"quantity", "resolution (in %)"},
// {"target", std::to_string(resolutionTarget)}}
// Histograms and Fitting //};
auto hdE = d1.Histo1D({"hdE", "dE; dE[GeV]; Events", 100, -3.0, 3.0}, "dE");
auto hdE_rel = d1.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 100, -3.0, 3.0}, "dE_rel"); //// Histograms and Fitting
auto hdEcopy = hdE->DrawCopy(); //auto hdE = d1.Histo1D({"hdE", "dE; dE[GeV]; Events", 100, -3.0, 3.0}, "dE");
hdEcopy->Fit("gaus", "", "", -3.0, 3.0); //auto hdE_rel = d1.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 100, -3.0, 3.0}, "dE_rel");
double* res = hdEcopy->GetFunction("gaus")->GetParameters(); //auto hdEcopy = hdE->DrawCopy();
double sigmaOverE = res[2] / meanE; //hdEcopy->Fit("gaus", "", "", -3.0, 3.0);
//double* res = hdEcopy->GetFunction("gaus")->GetParameters();
// Pass/Fail //double sigmaOverE = res[2] / meanE;
sigmaOverE <= resolutionTarget ? pi0_energy_resolution.pass(sigmaOverE) : pi0_energy_resolution.fail(sigmaOverE);
std::printf("Energy Resolution is %f\n", res[2]); //// Pass/Fail
//sigmaOverE <= resolutionTarget ? pi0_energy_resolution.pass(sigmaOverE) : pi0_energy_resolution.fail(sigmaOverE);
// Energy Resolution Histogram Plotting //std::printf("Energy Resolution is %f\n", res[2]);
auto *cdE = new TCanvas("cdE", "cdE", 700, 500);
cdE->SetLogy(1); //// Energy Resolution Histogram Plotting
h1 = hdEcopy->DrawCopy(); //auto *cdE = new TCanvas("cdE", "cdE", 700, 500);
hdEcopy->GetYaxis()->SetTitleOffset(1.4); //cdE->SetLogy(1);
hdEcopy->SetLineWidth(2); //h1 = hdEcopy->DrawCopy();
hdEcopy->SetLineColor(kBlue); //hdEcopy->GetYaxis()->SetTitleOffset(1.4);
hdEcopy->GetFunction("gaus")->SetLineWidth(2); //hdEcopy->SetLineWidth(2);
hdEcopy->GetFunction("gaus")->SetLineColor(kRed); //hdEcopy->SetLineColor(kBlue);
cdE->SaveAs("results/emcal_barrel_pi0_dE.png"); //hdEcopy->GetFunction("gaus")->SetLineWidth(2);
cdE->SaveAs("results/emcal_barrel_pi0_dE.pdf"); //hdEcopy->GetFunction("gaus")->SetLineColor(kRed);
//cdE->SaveAs("results/emcal_barrel_pi0_dE.png");
auto *cdE_rel = new TCanvas("cdE_rel", "cdE_rel", 700, 500); //cdE->SaveAs("results/emcal_barrel_pi0_dE.pdf");
h1 = hdE_rel->DrawCopy();
hdE_rel->GetYaxis()->SetTitleOffset(1.4); //auto *cdE_rel = new TCanvas("cdE_rel", "cdE_rel", 700, 500);
hdE_rel->SetLineWidth(2); //h1 = hdE_rel->DrawCopy();
hdE_rel->SetLineColor(kBlue); //hdE_rel->GetYaxis()->SetTitleOffset(1.4);
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png"); //hdE_rel->SetLineWidth(2);
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf"); //hdE_rel->SetLineColor(kBlue);
//cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png");
common_bench::write_test({pi0_energy_resolution}, fmt::format("results/{}_pi0.json", detEle)); //cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf");
//common_bench::write_test({pi0_energy_resolution}, fmt::format("results/{}_pi0.json", detEle));
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment