From 6311c2adc0cc8b93affc2149e68b9d9d403d437f Mon Sep 17 00:00:00 2001
From: Rhys Edward Owen <rhys.owen@cern.ch>
Date: Fri, 21 Mar 2025 14:43:00 +0100
Subject: [PATCH 1/2] Add option for LAr FW 6

LATOME fimware version v6 (HLS) is currently under testing. Processing
data to ensure that there are no simulation mis matches with L1Calo can
be done with this monitoring script but changes to the LAr readout mean
that a special db tag must be used.

This does not fit into the exisitng provision to overide the DB with a
local sqlite file so a new option is added for ease of running the job.
---
 .../TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py b/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
index a38d41076568..555d4b9d1e85 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
@@ -97,6 +97,7 @@ parser.add_argument('--stream',default="*",help="stream to lookup files in")
 parser.add_argument('--fexReadoutFilter',action='store_true',help="If specified, will skip events without fexReadout")
 parser.add_argument('--dbOverrides',default=None,nargs="+",type=str,help="specify overrides of COOL database folders in form <folder>=<dbPath>, example: /TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib=mytest.db ")
 parser.add_argument('--postConfig',default=[],nargs="+",type=str,help="specify component properties to apply at the end of the config")
+parser.add_argument('--LArFW6',action='store_true',help="Configure conditions data base for Latome HLS fimware")
 args = flags.fillFromArgs(parser=parser)
 if args.runNumber is not None:
   # todo: if an exact event number is provided, we can in theory use the event index and rucio to obtain a filename:
@@ -392,6 +393,12 @@ if any([s.name=="AthenaEventLoopMgr" for s in cfg.getServices()]): cfg.getServic
 if any([s.name=="AvalancheSchedulerSvc" for s in cfg.getServices()]):
   cfg.getService("AvalancheSchedulerSvc").ShowDataDependencies=True
 
+if args.LArFW6 :
+  print("Overriding DB for LAr FW6")
+  from IOVDbSvc.IOVDbSvcConfig import addOverride
+  cfg.merge(addOverride(flags,"/LAR/Identifier/LatomeMapping","LARIdentifierLatomeMapping-fw6"))
+  
+
 if type(args.dbOverrides)==list:
   from IOVDbSvc.IOVDbSvcConfig import addOverride
   #examples:
-- 
GitLab


From 07b3ec5b7091b39b86c4925ebdb2d2d761621842 Mon Sep 17 00:00:00 2001
From: Rhys Edward Owen <rhys.owen@cern.ch>
Date: Fri, 21 Mar 2025 16:43:32 +0100
Subject: [PATCH 2/2] Generalise dbOveride

Sugestion and code from @will to generalise existing db overide function
instead of adding single use flag
---
 .../share/L1CaloPhase1Monitoring.py           | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py b/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
index 555d4b9d1e85..ba57f3405851 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/share/L1CaloPhase1Monitoring.py
@@ -95,9 +95,8 @@ parser.add_argument('--lumiBlock',default=None,help="specify to select a lumiBlo
 parser.add_argument('--evtNumber',default=None,nargs="+",type=int,help="specify to select an evtNumber")
 parser.add_argument('--stream',default="*",help="stream to lookup files in")
 parser.add_argument('--fexReadoutFilter',action='store_true',help="If specified, will skip events without fexReadout")
-parser.add_argument('--dbOverrides',default=None,nargs="+",type=str,help="specify overrides of COOL database folders in form <folder>=<dbPath>, example: /TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib=mytest.db ")
+parser.add_argument('--dbOverrides',default=None,nargs="+",type=str,help="specify overrides of COOL database folders in form <folder>=<dbPath> or <folder>:<tag>[=<dbPath>] to override a tag, example: /TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib=mytest.db ")
 parser.add_argument('--postConfig',default=[],nargs="+",type=str,help="specify component properties to apply at the end of the config")
-parser.add_argument('--LArFW6',action='store_true',help="Configure conditions data base for Latome HLS fimware")
 args = flags.fillFromArgs(parser=parser)
 if args.runNumber is not None:
   # todo: if an exact event number is provided, we can in theory use the event index and rucio to obtain a filename:
@@ -393,12 +392,6 @@ if any([s.name=="AthenaEventLoopMgr" for s in cfg.getServices()]): cfg.getServic
 if any([s.name=="AvalancheSchedulerSvc" for s in cfg.getServices()]):
   cfg.getService("AvalancheSchedulerSvc").ShowDataDependencies=True
 
-if args.LArFW6 :
-  print("Overriding DB for LAr FW6")
-  from IOVDbSvc.IOVDbSvcConfig import addOverride
-  cfg.merge(addOverride(flags,"/LAR/Identifier/LatomeMapping","LARIdentifierLatomeMapping-fw6"))
-  
-
 if type(args.dbOverrides)==list:
   from IOVDbSvc.IOVDbSvcConfig import addOverride
   #examples:
@@ -406,14 +399,23 @@ if type(args.dbOverrides)==list:
   #cfg.merge( addOverride(flags, folder="/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts", db="sqlite://;schema=/afs/cern.ch/user/w/will/calib.sqlite;dbname=L1CALO",tag="" ) )
   for override in args.dbOverrides:
     print(override)
-    folderName,dbPath = override.split("=",1)
+    folderName,dbPath = override.split("=",1) if "=" in override else (override,"")
     if folderName == "": raise ValueError("Cannot parse dbOverride: " + override)
-    if ";dbname=" not in dbPath: dbPath += ";dbname=CONDBR2"
-    dbPath,dbInst = dbPath.split(";dbname=")
-    if not os.path.exists(dbPath): raise ValueError("dbOverride file doesn't exist: " + dbPath)
+    db = ""
+    if dbPath != "":
+      if ";dbname=" not in dbPath: dbPath += ";dbname=CONDBR2"
+      dbPath,dbInst = dbPath.split(";dbname=")
+      if not os.path.exists(dbPath): raise ValueError("dbOverride file doesn't exist: " + dbPath)
+      db = f"sqlite://;schema={dbPath};dbname={dbInst}"
+    tag = ""
+    if ":" in folderName:
+      folderName,tag = folderName.split(":",1)
     if folderName[0] != "/": folderName = "/TRIGGER/L1Calo/V1/Calibration/" + folderName
-    log.info(" ".join(("Overriding COOL folder:",folderName,dbPath,dbInst)))
-    cfg.merge( addOverride(flags,folder=folderName,db=f"sqlite://;schema={dbPath};dbname={dbInst}",tag=""))
+    log.info(" ".join(("Overriding COOL folder:",folderName,db,tag)))
+    if db=="":
+      cfg.merge( addOverride(flags,folder=folderName,tag=tag))
+    else:
+      cfg.merge( addOverride(flags,folder=folderName,db=db,tag=tag))
 
 
 # configure output AOD if requested
-- 
GitLab