Skip to content
Snippets Groups Projects
Commit 6ca90009 authored by Maria Zurek's avatar Maria Zurek
Browse files

Resolve "Add reading sampling fraction from electrons benchmarks"

parent 35fca2fc
No related branches found
No related tags found
1 merge request!52Resolve "Add reading sampling fraction from electrons benchmarks"
...@@ -28,6 +28,7 @@ stages: ...@@ -28,6 +28,7 @@ stages:
- initialize - initialize
- data_init - data_init
- simulate - simulate
- calibrate
- benchmarks - benchmarks
- collect - collect
- deploy - deploy
......
...@@ -32,6 +32,17 @@ sim:emcal_barrel_pions_electrons: ...@@ -32,6 +32,17 @@ sim:emcal_barrel_pions_electrons:
- bash benchmarks/barrel_ecal/run_emcal_barrel_electrons.sh - bash benchmarks/barrel_ecal/run_emcal_barrel_electrons.sh
- bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh piminus - bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh piminus
calib:emcal_barrel_electrons:
extends: .det_benchmark
stage: calibrate
needs:
- ["sim:emcal_barrel_electrons"]
script:
- ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_electron.root
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("electron", true)'
- echo "JSON file(s) from analysis:" ; cat results/*.json
bench:emcal_barrel_pions: bench:emcal_barrel_pions:
extends: .det_benchmark extends: .det_benchmark
stage: benchmarks stage: benchmarks
...@@ -40,24 +51,22 @@ bench:emcal_barrel_pions: ...@@ -40,24 +51,22 @@ bench:emcal_barrel_pions:
script: script:
- root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx+ - root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx+
bench:emcal_barrel_pi0: bench:emcal_barrel_electrons_scan:
extends: .det_benchmark extends: .det_benchmark
stage: benchmarks stage: benchmarks
needs: needs:
- ["sim:emcal_barrel_pi0"] - ["sim:emcal_barrel_electrons"]
script: script:
- root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx+ - if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("electron")' ; fi
bench:emcal_barrel_electrons: bench:emcal_barrel_pi0:
extends: .det_benchmark extends: .det_benchmark
stage: benchmarks stage: benchmarks
needs: needs:
- ["sim:emcal_barrel_electrons"] - ["sim:emcal_barrel_pi0", "calib:emcal_barrel_electrons"]
script: script:
- ls -lhtR sim_output/ - echo "JSON file(s) from analysis:" ; cat results/*.json
- rootls -t sim_output/sim_emcal_barrel_electron.root - root -b -q benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx+
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("electron")'
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("electron")' ; fi
bench:emcal_barrel_photons: bench:emcal_barrel_photons:
extends: .det_benchmark extends: .det_benchmark
...@@ -67,7 +76,7 @@ bench:emcal_barrel_photons: ...@@ -67,7 +76,7 @@ bench:emcal_barrel_photons:
script: script:
- ls -lhtR sim_output/ - ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_photon.root - rootls -t sim_output/sim_emcal_barrel_photon.root
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("photon")' - root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("photon", false)'
- if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("photon")' ; fi - if [[ "$RUN_EXTENDED_BENCHMARK" == "true" ]] ; then root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx+("photon")' ; fi
bench:emcal_barrel_pions_electrons: bench:emcal_barrel_pions_electrons:
...@@ -85,7 +94,12 @@ collect_results:barrel_ecal: ...@@ -85,7 +94,12 @@ collect_results:barrel_ecal:
extends: .det_benchmark extends: .det_benchmark
stage: collect stage: collect
needs: needs:
- ["bench:emcal_barrel_electrons", "bench:emcal_barrel_photons", "bench:emcal_barrel_pions", "bench:emcal_barrel_pi0", "bench:emcal_barrel_pions_electrons"] - "calib:emcal_barrel_electrons"
- "bench:emcal_barrel_electrons_scan"
- "bench:emcal_barrel_photons"
- "bench:emcal_barrel_pions"
- "bench:emcal_barrel_pi0"
- "bench:emcal_barrel_pions_electrons"
script: script:
- ls -lrht - ls -lrht
- echo " FIX ME" - echo " FIX ME"
......
...@@ -10,7 +10,7 @@ if (( $JUGGLER_N_EVENTS < $MIN_N_EVENTS )); then ...@@ -10,7 +10,7 @@ if (( $JUGGLER_N_EVENTS < $MIN_N_EVENTS )); then
echo "Setting JUGGLER_N_EVENTS to ${MIN_N_EVENTS}" echo "Setting JUGGLER_N_EVENTS to ${MIN_N_EVENTS}"
fi fi
#0.5 1 2 3 4 7 15 20 #0.5 1 2 3 4 7 15 20
for E in 0.5 1 2 3 4 7 15 20 for E in 0.5 1 2 3 4 5 7 10 15 20
do do
export E_START="$E" export E_START="$E"
export E_END="$E" export E_END="$E"
......
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
#include "TH1.h" #include "TH1.h"
#include "TF1.h" #include "TF1.h"
#include "TH1D.h" #include "TH1D.h"
#include <nlohmann/json.hpp>
#include "emcal_barrel_common_functions.h" #include "emcal_barrel_common_functions.h"
using ROOT::RDataFrame; using ROOT::RDataFrame;
using namespace ROOT::VecOps; using namespace ROOT::VecOps;
using json = nlohmann::json;
void save_canvas(TCanvas* c, std::string label) void save_canvas(TCanvas* c, std::string label)
{ {
...@@ -34,7 +36,7 @@ void save_canvas(TCanvas* c, std::string label, std::string particle_label) ...@@ -34,7 +36,7 @@ void save_canvas(TCanvas* c, std::string label, std::string particle_label)
save_canvas(c, label_with_E); save_canvas(c, label_with_E);
} }
void emcal_barrel_particles_analysis(std::string particle_name = "electron") void emcal_barrel_particles_analysis(std::string particle_name = "electron", bool save_calib = false)
{ {
// Setting for graphs // Setting for graphs
gROOT->SetStyle("Plain"); gROOT->SetStyle("Plain");
...@@ -47,13 +49,18 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron") ...@@ -47,13 +49,18 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
gStyle->SetPadLeftMargin(0.14); gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.14); gStyle->SetPadRightMargin(0.14);
json j;
// variables that will be saved in the JSON file
double Ethr_mean;
double fSam_mean;
ROOT::EnableImplicitMT(); ROOT::EnableImplicitMT();
std::string input_fname = fmt::format("sim_output/sim_emcal_barrel_{}.root", particle_name); std::string input_fname = fmt::format("sim_output/sim_emcal_barrel_{}.root", particle_name);
ROOT::RDataFrame d0("events", input_fname); ROOT::RDataFrame d0("events", input_fname);
// Environment Variables // Environment Variables
std::string detector_path = ""; std::string detector_path = "";
std::string detector_name = "topside"; std::string detector_name = "athena";
if(std::getenv("DETECTOR_PATH")) { if(std::getenv("DETECTOR_PATH")) {
detector_path = std::getenv("DETECTOR_PATH"); detector_path = std::getenv("DETECTOR_PATH");
} }
...@@ -117,6 +124,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron") ...@@ -117,6 +124,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
TCanvas* c1 = new TCanvas("c1", "c1", 700, 500); TCanvas* c1 = new TCanvas("c1", "c1", 700, 500);
c1->SetLogy(1); c1->SetLogy(1);
auto h = hEthr->DrawCopy(); auto h = hEthr->DrawCopy();
Ethr_mean = h->GetMean();
h->SetLineWidth(2); h->SetLineWidth(2);
h->SetLineColor(kBlue); h->SetLineColor(kBlue);
save_canvas(c1,"Ethr",particle_name); save_canvas(c1,"Ethr",particle_name);
...@@ -154,9 +162,22 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron") ...@@ -154,9 +162,22 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
h->Fit("gaus", "", "", down_fit, up_fit); h->Fit("gaus", "", "", down_fit, up_fit);
h->GetXaxis()->SetRangeUser(0.,up_fit); h->GetXaxis()->SetRangeUser(0.,up_fit);
TF1 *gaus = h->GetFunction("gaus"); TF1 *gaus = h->GetFunction("gaus");
fSam_mean = gaus->GetParameter(1);
gaus->SetLineWidth(2); gaus->SetLineWidth(2);
gaus->SetLineColor(kRed); gaus->SetLineColor(kRed);
save_canvas(c4,"fsam",particle_name); save_canvas(c4,"fsam",particle_name);
} }
j[particle_name] = {
{"particle_name", particle_name},
{"thrown_energy", Ethr_mean},
{"sampling_fraction", fSam_mean}
};
if (save_calib) {
std::string calib_output_path = "results/emcal_barrel_calibration.json";
std::cout << "Saving calibration results to " << calib_output_path << std::endl;
std::ofstream o(calib_output_path);
o << std::setw(4) << j << std::endl;
}
} }
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#include "TF1.h" #include "TF1.h"
#include "TH1D.h" #include "TH1D.h"
#include "TFitResult.h" #include "TFitResult.h"
#include <nlohmann/json.hpp>
using ROOT::RDataFrame; using ROOT::RDataFrame;
using namespace ROOT::VecOps; using namespace ROOT::VecOps;
using json = nlohmann::json;
void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_barrel_pi0.root") void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_barrel_pi0.root")
{ {
...@@ -56,12 +58,15 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b ...@@ -56,12 +58,15 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
{"quantity", "resolution (in %)"}, {"quantity", "resolution (in %)"},
{"target", std::to_string(resolutionTarget)}}}; {"target", std::to_string(resolutionTarget)}}};
json j;
std::ifstream prev_steps_ifstream("results/emcal_barrel_calibration.json");
prev_steps_ifstream >> j;
ROOT::EnableImplicitMT(); ROOT::EnableImplicitMT();
ROOT::RDataFrame d0("events", input_fname); ROOT::RDataFrame d0("events", input_fname);
// Sampling Fraction // Sampling Fraction
double samp_frac = 0.0136; double samp_frac = j["electron"]["sampling_fraction"];
// Thrown Energy [GeV] // Thrown Energy [GeV]
auto Ethr = [](std::vector<dd4pod::Geant4ParticleData> const& input) { auto Ethr = [](std::vector<dd4pod::Geant4ParticleData> const& input) {
...@@ -139,7 +144,7 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b ...@@ -139,7 +144,7 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
auto hEthr = d1.Histo1D({"hEthr", "Thrown Energy; Thrown Energy [GeV]; Events", 100, 0.0, 7.5}, "Ethr"); 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 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 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 hfsam = d1.Histo1D({"hfsam", "Sampling Fraction; Sampling Fraction; Events", 150, 0.0, 0.15}, "fsam");
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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment