From eb7bbccfae47c2ef9450a40bd265df7eb99aa5ab Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wouter.deconinck@umanitoba.ca>
Date: Wed, 13 Oct 2021 17:31:04 +0000
Subject: [PATCH] Analysis script
---
...chrotron_tests.cxx => synchrotron_raw.cxx} | 2 +-
.../synchrotron/analysis/synchrotron_sim.cxx | 41 +++++++++++++++++++
benchmarks/synchrotron/synchrotron.sh | 8 +++-
3 files changed, 49 insertions(+), 2 deletions(-)
rename benchmarks/synchrotron/analysis/{synchrotron_tests.cxx => synchrotron_raw.cxx} (89%)
create mode 100644 benchmarks/synchrotron/analysis/synchrotron_sim.cxx
diff --git a/benchmarks/synchrotron/analysis/synchrotron_tests.cxx b/benchmarks/synchrotron/analysis/synchrotron_raw.cxx
similarity index 89%
rename from benchmarks/synchrotron/analysis/synchrotron_tests.cxx
rename to benchmarks/synchrotron/analysis/synchrotron_raw.cxx
index 71c37671..3798cd86 100644
--- a/benchmarks/synchrotron/analysis/synchrotron_tests.cxx
+++ b/benchmarks/synchrotron/analysis/synchrotron_raw.cxx
@@ -19,7 +19,7 @@ R__LOAD_LIBRARY(libDD4pod.so)
#include "eicd/ReconstructedParticleCollection.h"
-void synchrotron_tests(const char* fname = "rec.root"){
+void synchrotron_raw(const char* fname = "rec_synchrotron.raw.root"){
fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running synchrotron analysis...\n");
diff --git a/benchmarks/synchrotron/analysis/synchrotron_sim.cxx b/benchmarks/synchrotron/analysis/synchrotron_sim.cxx
new file mode 100644
index 00000000..10a4a98f
--- /dev/null
+++ b/benchmarks/synchrotron/analysis/synchrotron_sim.cxx
@@ -0,0 +1,41 @@
+#include <cmath>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "ROOT/RDataFrame.hxx"
+#include "Math/Vector4D.h"
+#include "TCanvas.h"
+
+#include <nlohmann/json.hpp>
+using json = nlohmann::json;
+
+R__LOAD_LIBRARY(libfmt.so)
+#include "fmt/core.h"
+#include "fmt/color.h"
+
+R__LOAD_LIBRARY(libeicd.so)
+R__LOAD_LIBRARY(libDD4pod.so)
+
+#include "eicd/ReconstructedParticleCollection.h"
+
+void synchrotron_raw(const char* fname = "sim_synchrotron.root"){
+
+ fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running synchrotron analysis...\n");
+
+ // Run this in multi-threaded mode if desired
+ ROOT::EnableImplicitMT();
+ ROOT::RDataFrame df("events", fname);
+
+ // Define variables
+ auto df0 = df
+ .Define("n_VertexBarrelHits", "VertexBarrelHits.size()")
+ .Define("n_VertexEndcapHits", "VertexEndcapHits.size()")
+ ;
+
+ auto n_VertexBarrelHits = df0.Mean("n_VertexBarrelHits");
+ auto n_VertexEndcapHits = df0.Mean("n_VertexEncdapHits");
+
+ std::cout << "n_VertexBarrelHits = " << n_VertexBarrelHits << " / ev" << std::endl;
+ std::cout << "n_VertexEndcapHits = " << n_VertexEndcapHits << " / ev" << std::endl;
+}
diff --git a/benchmarks/synchrotron/synchrotron.sh b/benchmarks/synchrotron/synchrotron.sh
index e4c112d4..e103ba35 100644
--- a/benchmarks/synchrotron/synchrotron.sh
+++ b/benchmarks/synchrotron/synchrotron.sh
@@ -146,7 +146,13 @@ if [[ -n "${DO_ANA}" || -n "${DO_ALL}" ]] ; then
mkdir -p results/synchrotron
# here you can add as many scripts as you want.
- root -b -q "benchmarks/synchrotron/analysis/synchrotron_tests.cxx+(\"${JUGGLER_REC_FILE/.root/.raw.root}\")"
+ root -b -q "benchmarks/synchrotron/analysis/synchrotron_sim.cxx+(\"${JUGGLER_SIM_FILE}\")"
+ if [[ "$?" -ne "0" ]] ; then
+ echo "ERROR running root script"
+ exit 1
+ fi
+
+ root -b -q "benchmarks/synchrotron/analysis/synchrotron_raw.cxx+(\"${JUGGLER_REC_FILE/.root/.raw.root}\")"
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running root script"
exit 1
--
GitLab