From 3cc0485e66c838faa842f7d806698e7ec28e624c Mon Sep 17 00:00:00 2001
From: FASER Reco <faserrec@lxplus713.cern.ch>
Date: Tue, 22 Aug 2023 14:22:55 +0200
Subject: [PATCH] Script updates for new alignment

---
 .../Reconstruction/scripts/faser_reco.py              | 11 +++++++++--
 .../NtupleDumper/scripts/faser_ntuple_maker.py        | 10 +++++++++-
 .../NoisyStripFinder/share/NoisyStripFinderJob.py     |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py
index 744aafa0..d819c329 100755
--- a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py
+++ b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py
@@ -25,6 +25,8 @@ parser.add_argument("file_path",
                     help="Fully qualified path of the raw input file")
 parser.add_argument("-g", "--geom", default="",
                     help="Specify geometry (if it can't be parsed from run number)\n Values: TI12Data03 (2022 TI12)")
+parser.add_argument("-c", "--config", default="",
+                    help="Specify conditions tag (default depends on geometry)")
 parser.add_argument("-r", "--reco", default="",
                     help="Specify reco tag (to append to output filename)")
 parser.add_argument("-n", "--nevents", type=int, default=-1,
@@ -134,12 +136,12 @@ elif runtype == "TestBeamData" or runtype == "TestBeamMC":
 # New TI12 geometry (ugh)
 elif runtype == "TI12Data02":
     ConfigFlags.GeoModel.FaserVersion = "FASER-02" 
-    ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
+    ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"  # 2023 alignment
 
 # Final 2022 TI12 geometry
 elif runtype == "TI12Data03":
     ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" 
-    ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
+    ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"  # 2023 alignment
     useCal = True
     if not args.isMC:
         useLHC = True
@@ -149,6 +151,11 @@ else:
     print("Specify correct type or update list")
     sys.exit(1)
 
+# Override global tag if requested
+if len(args.config)>0:
+    print(f"Override ConfigFlags.IOVDb.GlobalTag = {args.config}") 
+    ConfigFlags.IOVDb.GlobalTag = args.config
+
 # Must use original input string here, as pathlib mangles double // in path names
 ConfigFlags.Input.Files = [ args.file_path ]
 
diff --git a/PhysicsAnalysis/NtupleDumper/scripts/faser_ntuple_maker.py b/PhysicsAnalysis/NtupleDumper/scripts/faser_ntuple_maker.py
index 1f4b990c..9ac7d2c5 100755
--- a/PhysicsAnalysis/NtupleDumper/scripts/faser_ntuple_maker.py
+++ b/PhysicsAnalysis/NtupleDumper/scripts/faser_ntuple_maker.py
@@ -44,6 +44,9 @@ parser.add_argument("--isMC", action='store_true',
 parser.add_argument("--partial", action='store_true',
                     help="Allow partial input files")
 
+parser.add_argument("-c", "--config", default="",
+                    help="Specify conditions tag (default: OFLCOND-FASER-04)")
+
 parser.add_argument("--trigFilt", action='store_true',
                     help="apply trigger event filter")
 parser.add_argument("--scintFilt", action='store_true',
@@ -230,7 +233,12 @@ Configurable.configurableRun3Behavior = True
 
 # Configure
 ConfigFlags.Input.Files = filelist
-ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"         # Always needed; must match FaserVersionS
+if len(args.config) == 0:
+    ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"         # Always needed; must match FaserVersionS
+else:
+    print(f"Setting ConfigFlags.IOVDb.GlobalTag = {args.config}")
+    ConfigFlags.IOVDb.GlobalTag = args.config
+
 ConfigFlags.Input.isMC = args.isMC
 if args.isMC:
     ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"           # Use MC conditions 
diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderJob.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderJob.py
index e8c30445..d593c317 100755
--- a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderJob.py
+++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderJob.py
@@ -39,7 +39,7 @@ for filename in args.file:
         filelist.append(filename)
 
 ConfigFlags.Input.Files = args.file
-ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
+ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"
 #ConfigFlags.IOVDb.DatabaseInstance = "OFLP200"
 ConfigFlags.IOVDb.DatabaseInstance = "CONDBR3"
 ConfigFlags.Input.ProjectName = "data22"
-- 
GitLab