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

Save analysis results to JSON file

parent 413312d4
No related branches found
No related tags found
1 merge request!52Resolve "Add reading sampling fraction from electrons benchmarks"
......@@ -57,6 +57,7 @@ bench:emcal_barrel_electrons:
- 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")'
- echo "JSON file(s) from analysis:" ; cat *.json
- 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:
......@@ -68,6 +69,7 @@ bench:emcal_barrel_photons:
- ls -lhtR sim_output/
- rootls -t sim_output/sim_emcal_barrel_photon.root
- root -b -q 'benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx+("photon")'
- echo "JSON file(s) from analysis:" ; cat *.json
- 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:
......
......@@ -16,11 +16,13 @@
#include "TH1.h"
#include "TF1.h"
#include "TH1D.h"
#include <nlohmann/json.hpp>
#include "emcal_barrel_common_functions.h"
using ROOT::RDataFrame;
using namespace ROOT::VecOps;
using json = nlohmann::json;
void save_canvas(TCanvas* c, std::string label)
{
......@@ -47,13 +49,18 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
gStyle->SetPadLeftMargin(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();
std::string input_fname = fmt::format("sim_output/sim_emcal_barrel_{}.root", particle_name);
ROOT::RDataFrame d0("events", input_fname);
// Environment Variables
std::string detector_path = "";
std::string detector_name = "topside";
std::string detector_name = "athena";
if(std::getenv("DETECTOR_PATH")) {
detector_path = std::getenv("DETECTOR_PATH");
}
......@@ -117,6 +124,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
TCanvas* c1 = new TCanvas("c1", "c1", 700, 500);
c1->SetLogy(1);
auto h = hEthr->DrawCopy();
Ethr_mean = h->GetMean();
h->SetLineWidth(2);
h->SetLineColor(kBlue);
save_canvas(c1,"Ethr",particle_name);
......@@ -154,9 +162,18 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron")
h->Fit("gaus", "", "", down_fit, up_fit);
h->GetXaxis()->SetRangeUser(0.,up_fit);
TF1 *gaus = h->GetFunction("gaus");
fSam_mean = gaus->GetParameter(1);
gaus->SetLineWidth(2);
gaus->SetLineColor(kRed);
save_canvas(c4,"fsam",particle_name);
}
j[particle_name] = {
{"particle_name", particle_name},
{"thrown_energy", Ethr_mean},
{"sampling_fraction", fSam_mean}
};
std::ofstream o("emcal_barrel_particles_analyses.json");
o << std::setw(4) << j << std::endl;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment