From 51d18951333769f9c5e9cab7543be92ae22eebc0 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Mon, 8 Nov 2021 02:17:35 +0000
Subject: [PATCH] Sanitize hepmc3 inputs for files from S3

---
 benchmarks/dis/dis.sh                 | 2 +-
 benchmarks/dis/get.sh                 | 3 ++-
 benchmarks/dvcs/dvcs.sh               | 2 +-
 benchmarks/synchrotron/synchrotron.sh | 2 +-
 benchmarks/u_omega/u_omega.sh         | 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/benchmarks/dis/dis.sh b/benchmarks/dis/dis.sh
index e6881a76..4d59b2a7 100755
--- a/benchmarks/dis/dis.sh
+++ b/benchmarks/dis/dis.sh
@@ -62,7 +62,7 @@ PLOT_TAG=${CONFIG}
 echo "Running Geant4 simulation"
 npsim --runType batch \
       --part.minimalKineticEnergy 1000*GeV  \
-      -v WARNING \
+      -v INFO \
       --numberOfEvents ${JUGGLER_N_EVENTS} \
       --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \
       --inputFiles ${GEN_FILE} \
diff --git a/benchmarks/dis/get.sh b/benchmarks/dis/get.sh
index f6625a54..ab94d394 100644
--- a/benchmarks/dis/get.sh
+++ b/benchmarks/dis/get.sh
@@ -56,8 +56,9 @@ fi
 ## =============================================================================
 ## Step 3: Copy the file (about 180 lines per event in DIS NC files)
 nlines=$((180*${JUGGLER_N_EVENTS}))
+DATA_URL=S3/eictest/ATHENA/EVGEN/DIS/NC/${EBEAM}x${PBEAM}/minQ2=1/pythia8NCDIS_${EBEAM}x${PBEAM}_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc
 mc config host add S3 https://dtn01.sdcc.bnl.gov:9000 ${S3_ACCESS_KEY} ${S3_SECRET_KEY}
-mc head -n ${nlines} S3/eictest/ATHENA/EVGEN/DIS/NC/${EBEAM}x${PBEAM}/minQ2=1/pythia8NCDIS_${EBEAM}x${PBEAM}_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc > ${TMP_PATH}/${GEN_TAG}.hepmc
+mc head -n ${nlines} ${DATA_URL} | sanitize_hepmc3 | sed -e 's| \-\?421 | 321 |g' > ${TMP_PATH}/${GEN_TAG}.hepmc
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR downloading file"
   exit 1
diff --git a/benchmarks/dvcs/dvcs.sh b/benchmarks/dvcs/dvcs.sh
index c05c3486..dbb667ad 100644
--- a/benchmarks/dvcs/dvcs.sh
+++ b/benchmarks/dvcs/dvcs.sh
@@ -90,7 +90,7 @@ echo "JUGGLER_DETECTOR    = ${JUGGLER_DETECTOR}"
 ## Step 1. Get the data
 if [[ -n "${DATA_INIT}" || -n "${DO_ALL}" ]] ; then
   mc -C . config host add S3 https://dtn01.sdcc.bnl.gov:9000 $S3_ACCESS_KEY $S3_SECRET_KEY
-  mc -C . cat  --insecure ${DATA_URL} |  head  -n 1004 > "${JUGGLER_MC_FILE}"
+  mc -C . head  -n 1004 --insecure ${DATA_URL} |  sanitize_hepmc3 > "${JUGGLER_MC_FILE}"
   if [[ "$?" -ne "0" ]] ; then
     echo "Failed to download hepmc file"
     exit 1
diff --git a/benchmarks/synchrotron/synchrotron.sh b/benchmarks/synchrotron/synchrotron.sh
index e103ba35..43ce7782 100644
--- a/benchmarks/synchrotron/synchrotron.sh
+++ b/benchmarks/synchrotron/synchrotron.sh
@@ -90,7 +90,7 @@ echo "JUGGLER_DETECTOR    = ${JUGGLER_DETECTOR}"
 ## Step 1. Get the data
 if [[ -n "${DATA_INIT}" || -n "${DO_ALL}" ]] ; then
   mc -C . config host add S3 https://dtn01.sdcc.bnl.gov:9000 $S3_ACCESS_KEY $S3_SECRET_KEY
-  mc -C . head -n $((2+5*${JUGGLER_N_EVENTS})) --insecure ${DATA_URL} > ${JUGGLER_MC_FILE}
+  mc -C . head -n $((2+5*${JUGGLER_N_EVENTS})) --insecure ${DATA_URL} | sanitize_hepmc3 > ${JUGGLER_MC_FILE}
   if [[ "$?" -ne "0" ]] ; then
     echo "Failed to download hepmc files"
     exit 1
diff --git a/benchmarks/u_omega/u_omega.sh b/benchmarks/u_omega/u_omega.sh
index 23bbf403..17634195 100644
--- a/benchmarks/u_omega/u_omega.sh
+++ b/benchmarks/u_omega/u_omega.sh
@@ -89,7 +89,7 @@ echo "JUGGLER_DETECTOR    = ${JUGGLER_DETECTOR}"
 ## Step 1. Get the data
 if [[ -n "${DATA_INIT}" || -n "${DO_ALL}" ]] ; then
   mc -C . config host add S3 https://dtn01.sdcc.bnl.gov:9000 $S3_ACCESS_KEY $S3_SECRET_KEY
-  mc -C . cat  --insecure ${DATA_URL} |  head  -n 1004 > "${JUGGLER_MC_FILE}"
+  mc -C . head  -n 1004  --insecure ${DATA_URL} | sanitize_hepmc3 > "${JUGGLER_MC_FILE}"
   if [[ "$?" -ne "0" ]] ; then
     echo "Failed to download hepmc file"
     exit 1
-- 
GitLab