From eea7cac2a0fc88c8b320ffd132bf846292d26b00 Mon Sep 17 00:00:00 2001
From: Eric Torrence <eric.torrence@cern.ch>
Date: Fri, 13 May 2022 12:47:30 -0700
Subject: [PATCH] Fixes for condor submission

---
 .../scripts/submit_faserMDC_digi.sh           |  8 +++---
 .../mdc/FaserMC-MDC_PG_mumi_logE-101302.json  |  2 +-
 .../mdc/FaserMC-MDC_PG_mupl_logE-101301.json  |  2 +-
 .../Generation/python/faserMDC_pgparser.py    | 26 ++++++++++---------
 .../scripts/faserMDC_particlegun.py           |  3 +--
 .../scripts/submit_faserMDC_particlegun.sh    | 13 +++++++---
 .../scripts/submit_faserMDC_reco.sh           |  8 +++---
 7 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/Control/CalypsoExample/Digitization/scripts/submit_faserMDC_digi.sh b/Control/CalypsoExample/Digitization/scripts/submit_faserMDC_digi.sh
index c03a4329..2070b43f 100755
--- a/Control/CalypsoExample/Digitization/scripts/submit_faserMDC_digi.sh
+++ b/Control/CalypsoExample/Digitization/scripts/submit_faserMDC_digi.sh
@@ -79,12 +79,12 @@ source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
 # Always go back to the starting directory in case paths are relative
 cd "$starting_directory"
 cd "$release_directory"
-asetup
-source build/x8*/setup.sh
+# asetup
+# source build/x8*/setup.sh
 #
 # Do this by hand
-# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.49
-# source "$release_directory/build/x8*/setup.sh"
+asetup --input=calypso/asetup.faser Athena,22.0.49
+source build/x86*/setup.sh
 #
 #
 # Try to find a release tag
diff --git a/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mumi_logE-101302.json b/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mumi_logE-101302.json
index 7c9e9631..1387658b 100644
--- a/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mumi_logE-101302.json
+++ b/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mumi_logE-101302.json
@@ -1,5 +1,5 @@
 {
-    "file_length": 1000,
+    "file_length": 2000,
     "mass": 105.66,
     "maxE": 2000.0,
     "minE": 10.0,
diff --git a/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mupl_logE-101301.json b/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mupl_logE-101301.json
index 47f0f142..dda3d48a 100644
--- a/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mupl_logE-101301.json
+++ b/Control/CalypsoExample/Generation/data/mdc/FaserMC-MDC_PG_mupl_logE-101301.json
@@ -1,5 +1,5 @@
 {
-    "file_length": 1000,
+    "file_length": 2000,
     "mass": 105.66,
     "maxE": 2000.0,
     "minE": 10.0,
diff --git a/Control/CalypsoExample/Generation/python/faserMDC_pgparser.py b/Control/CalypsoExample/Generation/python/faserMDC_pgparser.py
index 7b406cc8..7c41638e 100644
--- a/Control/CalypsoExample/Generation/python/faserMDC_pgparser.py
+++ b/Control/CalypsoExample/Generation/python/faserMDC_pgparser.py
@@ -32,6 +32,8 @@ def faserMDC_pgparser():
                         help="Specify particle mass (in MeV)")
     parser.add_argument("--radius", default=100., type=float,
                         help="Specify radius (in mm)")
+    parser.add_argument("--angle", default=0.015, type=float,
+                        help="Specify angular width (in Rad)")
     parser.add_argument("--zpos", default=None, type=float,
                         help="Specify z position of particles (in mm) (helpful to avoid FASERnu)")
 
@@ -49,20 +51,20 @@ def faserMDC_pgparser():
     parser.add_argument("--noexec", action='store_true',
                         help="Exit after parsing configuration (no execution)")
 
-    args = parser.parse_args()
+    pg_args = parser.parse_args()
 
     # Get defaults
-    if args.conf is not None:
-        for conf_fname in args.conf:
+    if pg_args.conf is not None:
+        for conf_fname in pg_args.conf:
             with open(conf_fname, 'r') as f:
                 parser.set_defaults(**json.load(f))
 
         # Reload arguments to override config file with command line
-        args = parser.parse_args()
+        pg_args = parser.parse_args()
 
     # Print out configuration if requested
-    if args.dump:
-        tmp_args = vars(args).copy()
+    if pg_args.dump:
+        tmp_args = vars(pg_args).copy()
         del tmp_args['dump']  # Don't dump the dump value
         del tmp_args['conf']  # Don't dump the conf file name either
         del tmp_args['nevts'] # Debugging, not part of configuration
@@ -70,7 +72,7 @@ def faserMDC_pgparser():
         print("Configuration:")
         print(json.dumps(tmp_args, indent=4, sort_keys=False))
 
-    if args.noexec:
+    if pg_args.noexec:
         sys.exit(0)
 
     #
@@ -78,13 +80,13 @@ def faserMDC_pgparser():
     #
 
     # Create the file name also (could add gentag here)
-        args.outfile = f"FaserMC-{args.short}-{args.run:06}-{args.segment:05}"
+    pg_args.outfile = f"FaserMC-{pg_args.short}-{pg_args.run:06}-{pg_args.segment:05}"
 
-    if args.tag:
-        args.outfile += f"-{args.tag}"
+    if pg_args.tag:
+        pg_args.outfile += f"-{pg_args.tag}"
 
-    args.outfile += "-HITS.root"
+    pg_args.outfile += "-HITS.root"
 
-    return args
+    return pg_args
 
 # All done
diff --git a/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py b/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py
index 943278e4..abc7ae67 100755
--- a/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py
+++ b/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py
@@ -57,7 +57,6 @@ if __name__ == '__main__':
 #
 # Output file name
 # 
-
     ConfigFlags.Output.HITSFileName = args.outfile
 #
 # Sim ConfigFlags
@@ -86,7 +85,7 @@ if __name__ == '__main__':
     ConfigFlags.Sim.Gun = {
         "Generator" : "SingleParticle", 
         "pid" : args.pid, "mass" : args.mass, 
-        "theta" :  PG.GaussianSampler(0, atan((10*cm)/(7*m)), oneside = True), 
+        "theta" :  PG.GaussianSampler(0, args.angle, oneside = True), 
         "phi" : [0, 2*pi], "radius" : args.radius, 
         "randomSeed" : args.outfile }
 
diff --git a/Control/CalypsoExample/Generation/scripts/submit_faserMDC_particlegun.sh b/Control/CalypsoExample/Generation/scripts/submit_faserMDC_particlegun.sh
index 1b676699..1aa00c89 100755
--- a/Control/CalypsoExample/Generation/scripts/submit_faserMDC_particlegun.sh
+++ b/Control/CalypsoExample/Generation/scripts/submit_faserMDC_particlegun.sh
@@ -84,12 +84,13 @@ source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
 # Always go back to the starting directory in case paths are relative
 cd "$starting_directory"
 cd "$release_directory"
-asetup
-source build/x8*/setup.sh
+# This doesn't seem to work, as we need the --input argument
+#asetup 
+#source build/x8*/setup.sh
 #
 # Do this by hand
-# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.49
-# source "$release_directory/build/x8*/setup.sh"
+asetup --input=calypso/asetup.faser Athena,22.0.49
+source build/x86*/setup.sh
 #
 #
 # Try to find a release tag
@@ -99,6 +100,10 @@ if [[ "$gentag" == "gen/g"???? ]]; then
   gtag=`echo "$gentag" | cut -c 5-10`
   echo "Found gen tag: $gtag"
 fi
+if [[ "$gentag" == "digi/d"???? ]]; then
+  tag=`echo "$recotag" | cut -c 6-11`
+  echo "Found reco tag: $tag"
+fi
 #
 # Move to the run directory
 cd "$starting_directory"
diff --git a/Control/CalypsoExample/Reconstruction/scripts/submit_faserMDC_reco.sh b/Control/CalypsoExample/Reconstruction/scripts/submit_faserMDC_reco.sh
index b969fcf2..60c39ca3 100755
--- a/Control/CalypsoExample/Reconstruction/scripts/submit_faserMDC_reco.sh
+++ b/Control/CalypsoExample/Reconstruction/scripts/submit_faserMDC_reco.sh
@@ -85,12 +85,12 @@ source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
 # Always go back to the starting directory in case paths are relative
 cd "$starting_directory"
 cd "$release_directory"
-asetup
-source build/x8*/setup.sh
+#asetup
+#source build/x8*/setup.sh
 #
 # Do this by hand
-# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.49
-# source "$release_directory/build/x8*/setup.sh"
+asetup --input=calypso/asetup.faser Athena,22.0.49
+source build/x86*/setup.sh
 #
 #
 # Try to find a release tag
-- 
GitLab