From 8e045c5dcdb32e77493e6468f9d5d2b4a0864659 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wouter.deconinck@umanitoba.ca>
Date: Tue, 5 Oct 2021 23:29:50 +0000
Subject: [PATCH] Resolve "Job Failed #349161" - B0_far_forward_protons

---
 .rootlogon.C                                       | 14 ++++++++++++++
 .../gen_far_forward_protons.cxx                    |  6 ++++--
 .../hits_far_forward_protons.cxx                   |  2 ++
 .../print_far_forward_protons.cxx                  |  0
 .../rec_far_forward_protons.cxx                    |  2 ++
 benchmarks/far_forward/config.yml                  |  1 +
 benchmarks/far_forward/far_forward_protons.sh      |  8 ++++----
 7 files changed, 27 insertions(+), 6 deletions(-)
 create mode 100644 .rootlogon.C
 rename benchmarks/far_forward/{scripts => analysis}/gen_far_forward_protons.cxx (97%)
 rename benchmarks/far_forward/{scripts => analysis}/hits_far_forward_protons.cxx (99%)
 rename benchmarks/far_forward/{scripts => analysis}/print_far_forward_protons.cxx (100%)
 rename benchmarks/far_forward/{scripts => analysis}/rec_far_forward_protons.cxx (99%)

diff --git a/.rootlogon.C b/.rootlogon.C
new file mode 100644
index 00000000..39661747
--- /dev/null
+++ b/.rootlogon.C
@@ -0,0 +1,14 @@
+{
+  // Ensure fmt is loaded
+  R__LOAD_LIBRARY(libfmt);
+  //
+  // top-level include-dir
+  gROOT->ProcessLine(".include include");
+
+  // setup a local build directory so we don't polute our source code with
+  // ROOT dictionaries etc. if desired
+  const char* build_dir = gSystem->Getenv("ROOT_BUILD_DIR");
+  if (build_dir) {
+    gSystem->SetBuildDir(build_dir);
+  }
+}
diff --git a/benchmarks/far_forward/scripts/gen_far_forward_protons.cxx b/benchmarks/far_forward/analysis/gen_far_forward_protons.cxx
similarity index 97%
rename from benchmarks/far_forward/scripts/gen_far_forward_protons.cxx
rename to benchmarks/far_forward/analysis/gen_far_forward_protons.cxx
index 1b363ca1..a3c5ba62 100644
--- a/benchmarks/far_forward/scripts/gen_far_forward_protons.cxx
+++ b/benchmarks/far_forward/analysis/gen_far_forward_protons.cxx
@@ -4,10 +4,12 @@
 #include "HepMC3/Print.h"
 
 #include <iostream>
-#include<random>
-#include<cmath>
+#include <random>
+#include <cmath>
 #include <math.h>
+
 #include <TMath.h>
+#include <TRandom.h>
 
 using namespace HepMC3;
 
diff --git a/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx b/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx
similarity index 99%
rename from benchmarks/far_forward/scripts/hits_far_forward_protons.cxx
rename to benchmarks/far_forward/analysis/hits_far_forward_protons.cxx
index 29ee91f1..860a1b6c 100644
--- a/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx
+++ b/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx
@@ -2,7 +2,9 @@
 #include "TCanvas.h"
 #include "TLegend.h"
 #include "TH1D.h"
+#include "THStack.h"
 #include "TProfile.h"
+#include "Math/Vector4D.h"
 
 #include <iostream>
 
diff --git a/benchmarks/far_forward/scripts/print_far_forward_protons.cxx b/benchmarks/far_forward/analysis/print_far_forward_protons.cxx
similarity index 100%
rename from benchmarks/far_forward/scripts/print_far_forward_protons.cxx
rename to benchmarks/far_forward/analysis/print_far_forward_protons.cxx
diff --git a/benchmarks/far_forward/scripts/rec_far_forward_protons.cxx b/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx
similarity index 99%
rename from benchmarks/far_forward/scripts/rec_far_forward_protons.cxx
rename to benchmarks/far_forward/analysis/rec_far_forward_protons.cxx
index 493ae13a..a12c2d40 100644
--- a/benchmarks/far_forward/scripts/rec_far_forward_protons.cxx
+++ b/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx
@@ -2,7 +2,9 @@
 #include "TCanvas.h"
 #include "TLegend.h"
 #include "TH1D.h"
+#include "THStack.h"
 #include "TProfile.h"
+#include "Math/Vector4D.h"
 
 #include <iostream>
 
diff --git a/benchmarks/far_forward/config.yml b/benchmarks/far_forward/config.yml
index 21347be9..3aa931fe 100644
--- a/benchmarks/far_forward/config.yml
+++ b/benchmarks/far_forward/config.yml
@@ -3,4 +3,5 @@ B0_far_forward_protons:
   stage: run
   timeout: 24 hours
   script:
+    - compile_analyses.py far_forward
     - bash benchmarks/far_forward/far_forward_protons.sh
diff --git a/benchmarks/far_forward/far_forward_protons.sh b/benchmarks/far_forward/far_forward_protons.sh
index 494215c0..44da60d2 100644
--- a/benchmarks/far_forward/far_forward_protons.sh
+++ b/benchmarks/far_forward/far_forward_protons.sh
@@ -70,7 +70,7 @@ if [[ -z "${REC_ONLY}" && -z "${ANALYSIS_ONLY}" ]] ;
 then
 
   ## generate the input events
-  root -b -q "benchmarks/far_forward/scripts/gen_far_forward_protons.cxx(${JUGGLER_N_EVENTS}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
+  root -b -q "benchmarks/far_forward/analysis/gen_far_forward_protons.cxx+(${JUGGLER_N_EVENTS}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
   if [[ "$?" -ne "0" ]] ; then
     echo "ERROR running script"
     exit 1
@@ -108,19 +108,19 @@ mkdir -p results/far_forward/B0
 mkdir -p results/far_forward/RomanPot
 mkdir -p results/far_forward/OffMTracker
 
-root -b -q "benchmarks/far_forward/scripts/print_far_forward_protons.cxx(\"${JUGGLER_REC_FILE}\")"
+root -b -q "benchmarks/far_forward/analysis/print_far_forward_protons.cxx+(\"${JUGGLER_REC_FILE}\")"
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR running root script"
   exit 1
 fi
 
-root -b -q "benchmarks/far_forward/scripts/rec_far_forward_protons.cxx(\"${JUGGLER_REC_FILE}\")"
+root -b -q "benchmarks/far_forward/analysis/rec_far_forward_protons.cxx+(\"${JUGGLER_REC_FILE}\")"
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR running root script"
   exit 1
 fi
 
-root -b -q "benchmarks/far_forward/scripts/hits_far_forward_protons.cxx(\"${JUGGLER_SIM_FILE}\")"
+root -b -q "benchmarks/far_forward/analysis/hits_far_forward_protons.cxx+(\"${JUGGLER_SIM_FILE}\")"
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR running root script"
   exit 1
-- 
GitLab