From 7a46deea4401d2d233cdf09b2ed1102c1f346042 Mon Sep 17 00:00:00 2001
From: Maria Zurek <zurek@anl.gov>
Date: Fri, 17 Sep 2021 16:09:07 +0000
Subject: [PATCH] Resolve "Save uncertainty on sampling fraction to calibration
 file"

---
 .../scripts/emcal_barrel_particles_analysis.cxx      | 12 +++++++++++-
 .../scripts/hcal_barrel_energy_scan_analysis.cxx     |  1 +
 .../scripts/hcal_barrel_particles_analysis.cxx       |  1 +
 .../scripts/hcal_barrel_particles_gen.cxx            |  1 +
 .../scripts/hcal_barrel_particles_reader.cxx         |  1 +
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx b/benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx
index 61edb15d..a9613072 100644
--- a/benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx
+++ b/benchmarks/barrel_ecal/scripts/emcal_barrel_particles_analysis.cxx
@@ -5,6 +5,7 @@
 
 #include "ROOT/RDataFrame.hxx"
 #include <iostream>
+#include <fstream>
 #include <fmt/core.h>
 
 #include "dd4pod/Geant4ParticleCollection.h"
@@ -55,6 +56,9 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
   double fSam_mean;
   double fSam_img_mean;
   double fSam_scfi_mean;
+  double fSam_mean_err;
+  double fSam_img_mean_err;
+  double fSam_scfi_mean_err;
 
   ROOT::EnableImplicitMT();
   std::string input_fname = fmt::format("sim_output/sim_emcal_barrel_{}.root", particle_name);
@@ -181,6 +185,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
     h->GetXaxis()->SetRangeUser(down_fit,up_fit);
     TF1 *gaus = h->GetFunction("gaus");
     fSam_mean = gaus->GetParameter(1);
+    fSam_mean_err = gaus->GetParError(1);
     gaus->SetLineWidth(2);
     gaus->SetLineColor(kRed); 
     save_canvas(c4,"fsam",particle_name);
@@ -197,6 +202,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
     h->GetXaxis()->SetRangeUser(down_fit,up_fit);
     TF1 *gaus = h->GetFunction("gaus");
     fSam_img_mean = gaus->GetParameter(1);
+    fSam_img_mean_err = gaus->GetParError(1);
     gaus->SetLineWidth(2);
     gaus->SetLineColor(kRed); 
     save_canvas(c5,"fsamImg",particle_name);
@@ -213,6 +219,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
     h->GetXaxis()->SetRangeUser(down_fit,up_fit);
     TF1 *gaus = h->GetFunction("gaus");
     fSam_scfi_mean = gaus->GetParameter(1);
+    fSam_scfi_mean_err = gaus->GetParError(1);
     gaus->SetLineWidth(2);
     gaus->SetLineColor(kRed); 
     save_canvas(c6,"fsamScFi",particle_name);
@@ -222,8 +229,11 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
     {"particle_name", particle_name},
     {"thrown_energy", Ethr_mean},
     {"sampling_fraction", fSam_mean},
+    {"sampling_fraction_error", fSam_mean_err},
     {"sampling_fraction_img", fSam_img_mean},
-    {"sampling_fraction_scfi", fSam_scfi_mean}      
+    {"sampling_fraction_error_img", fSam_img_mean_err},
+    {"sampling_fraction_scfi", fSam_scfi_mean},
+    {"sampling_fraction_error_scfi", fSam_scfi_mean_err}      
   };
   if (save_calib) {
     std::string calib_output_path = "results/emcal_barrel_calibration.json";
diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx
index 8ac13ba1..1d66a981 100644
--- a/benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx
+++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx
@@ -5,6 +5,7 @@
 
 #include "ROOT/RDataFrame.hxx"
 #include <iostream>
+#include <fstream>
 #include <fmt/core.h>
 
 #include "dd4pod/Geant4ParticleCollection.h"
diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx
index 1ae105d3..fbe72c2a 100644
--- a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx
+++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx
@@ -5,6 +5,7 @@
 
 #include "ROOT/RDataFrame.hxx"
 #include <iostream>
+#include <fstream>
 #include <fmt/core.h>
 
 #include "dd4pod/Geant4ParticleCollection.h"
diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx
index 5c9142e0..297a74f5 100644
--- a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx
+++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx
@@ -15,6 +15,7 @@
 
 #include <cmath>
 #include <iostream>
+#include <fstream>
 #include <math.h>
 #include <random>
 #include <fmt/core.h>
diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx
index 6c16a91f..c21db831 100644
--- a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx
+++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx
@@ -18,6 +18,7 @@
 #include "TMath.h"
 
 #include <iostream>
+#include <fstream>
 #include <fmt/core.h>
 
 #include "hcal_barrel_common_functions.h"
-- 
GitLab