From 1d6efdd771d69d60d2800e55a39408307b4702cf Mon Sep 17 00:00:00 2001
From: Marshall Scott <mbscott@anl.gov>
Date: Mon, 26 Apr 2021 21:57:51 -0400
Subject: [PATCH] Testing new fsam

---
 .../scripts/emcal_barrel_pions_analysis.cxx        | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx b/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx
index 25dd4e55..bdc92d07 100644
--- a/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx
+++ b/benchmarks/barrel_ecal/scripts/emcal_barrel_pions_analysis.cxx
@@ -84,11 +84,23 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
     return result;
   };
 
+  // Sampling fraction = Esampling / Ethrown, revised
+  auto fsam2 = [](const std::vector<double>& sampled, const std::vector<double>& thrown) {
+    std::vector<double> result;
+    auto it_sam = sampled.cbegin();
+    auto it_thr = thrown.cbegin();
+    for (; it_sam != sampled.end() && it_thr != thrown.end(); ++it_sam, ++it_thr) {
+        result.push_back(*it_sam / *it_thr);
+    }
+    return result;
+  };
+
   // Define variables
   auto d1 = d0.Define("Ethr",  Ethr,  {"mcparticles"})
 	      .Define("nhits", nhits, {"EcalBarrelHits"})
 	      .Define("Esim",  Esim,  {"EcalBarrelHits"})
-	      .Define("fsam",  fsam,  {"Esim","Ethr"})
+	      //.Define("fsam",  fsam,  {"Esim","Ethr"})
+        .Define("fsam",  fsam2,  {"Esim","Ethr"})
         .Define("dE", "Ethr-Esim")
         .Define("dE_rel", "(Ethr - Esim)/Esim")
 	      ;
-- 
GitLab