ATLAS Offline Software
GeoModelConfigFlags.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4 from AthenaConfiguration.AutoConfigFlags import GetFileMD, DetDescrInfo
5 from AthenaConfiguration.Enums import LHCPeriod, ProductionStep, Project
6 
7 def createGeoModelConfigFlags(analysis=False):
8  gcf=AthConfigFlags()
9 
10  def __getTrigTag(flags):
11  from TriggerJobOpts.TriggerConfigFlags import trigGeoTag
12  return trigGeoTag(flags)
13 
14  gcf.addFlag("GeoModel.AtlasVersion", lambda flags :
15  (__getTrigTag(flags) if flags.Trigger.doLVL1 or flags.Trigger.doHLT else None) or
16  GetFileMD(flags.Input.Files).get("GeoAtlas", None), help='ATLAS Geometry version tag')
17 
18  # Special handling of analysis releases where we only want AtlasVersion and Run
19  if analysis:
20  def _deduct_LHCPeriod(prevFlags):
21  import logging
22  log = logging.getLogger("GeoModelConfigFlags")
23  log.info('Deducing LHC Run period from the geometry tag name "%s" as database access is not available in analysis releases', prevFlags.GeoModel.AtlasVersion)
24  if not prevFlags.GeoModel.AtlasVersion:
25  raise ValueError('No geometry tag specified')
26 
27  if prevFlags.GeoModel.AtlasVersion.startswith("ATLAS-R1"):
28  period = LHCPeriod.Run1
29  elif prevFlags.GeoModel.AtlasVersion.startswith("ATLAS-R2"):
30  period = LHCPeriod.Run2
31  elif prevFlags.GeoModel.AtlasVersion.startswith("ATLAS-R3"):
32  period = LHCPeriod.Run3
33  elif prevFlags.GeoModel.AtlasVersion.startswith("ATLAS-P2-RUN4"):
34  period = LHCPeriod.Run4
35  else:
36  raise ValueError(f'Can not deduct LHC Run period from "{prevFlags.GeoModel.AtlasVersion}", please set "flags.GeoModel.Run" manually.')
37 
38  log.info('Using LHC Run period "%s"', period.value)
39  return period
40 
41  gcf.addFlag("GeoModel.Run", # Run deducted from other metadata
42  _deduct_LHCPeriod, type=LHCPeriod, help='LHC Run period')
43  return gcf
44 
45  def _deduct_LHCPeriod(prevFlags):
46  if prevFlags.GeoModel.AtlasVersion:
47  return LHCPeriod(DetDescrInfo(prevFlags.GeoModel.AtlasVersion,prevFlags.GeoModel.SQLiteDB,prevFlags.GeoModel.SQLiteDBFullPath)['Common']['Run'])
48 
49  if prevFlags.Input.isMC:
50  raise ValueError('No geometry tag specified')
51 
52  if 2022 <= prevFlags.Input.DataYear:
53  return LHCPeriod.Run3
54  if 2015 <= prevFlags.Input.DataYear <= 2018:
55  return LHCPeriod.Run2
56  if 2010 <= prevFlags.Input.DataYear <= 2013:
57  return LHCPeriod.Run1
58 
59  raise RuntimeError('Can not determine LHC period from the data project name')
60 
61  gcf.addFlag("GeoModel.Run", _deduct_LHCPeriod, type=LHCPeriod, help='LHC Run period')
62 
63  gcf.addFlag('GeoModel.Layout', 'atlas', help='Geometry layout') # replaces global.GeoLayout
64 
65  gcf.addFlag("GeoModel.Align.Dynamic",
66  lambda prevFlags : prevFlags.GeoModel.Run >= LHCPeriod.Run2 and not prevFlags.Input.isMC, help='Flag for using dynamic alignment')
67  # TODO: dynamic alignment is for now enabled by default for data overlay
68  # to disable, add 'and prevFlags.Common.ProductionStep not in [ProductionStep.Simulation, ProductionStep.Overlay]'
69 
70  gcf.addFlag("GeoModel.Align.LegacyConditionsAccess",
71  lambda prevFlags : prevFlags.Common.Project is Project.AthSimulation or prevFlags.Common.ProductionStep is ProductionStep.Simulation,
72  help='Flag for using the legacy conditions access infrastructure')
73  # Mainly for G4 which still loads alignment on initialize
74 
75  gcf.addFlag("GeoModel.Type",
76  lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.AtlasVersion,prevFlags.GeoModel.SQLiteDB,prevFlags.GeoModel.SQLiteDBFullPath)['Common']['GeoType'],
77  help='Geometry type in {ITKLoI, ITkLoI-VF, etc...}')
78 
79  gcf.addFlag("GeoModel.IBLLayout",
80  lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.AtlasVersion,prevFlags.GeoModel.SQLiteDB,prevFlags.GeoModel.SQLiteDBFullPath)['Pixel']['IBLlayout'],
81  help='IBL layer layout in {"planar", "3D", "noIBL"}')
82 
83  gcf.addFlag('GeoModel.SQLiteDB',False, help='Flag for activating GeoModel initialization from SQLite Geometry DB')
84 
85  gcf.addFlag('GeoModel.SQLiteDBFullPath','', help='Override default location of the SQLite Geometry DB')
86 
87  gcf.addFlag('GeoModel.IgnoreTagDifference',False, help='Ignore geometry tag difference between the configured value and the value read from the input file metadata')
88 
89  return gcf
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True)
Definition: AutoConfigFlags.py:51
python.TriggerConfigFlags.trigGeoTag
def trigGeoTag(flags)
Definition: TriggerConfigFlags.py:27
python.GeoModelConfigFlags.createGeoModelConfigFlags
def createGeoModelConfigFlags(analysis=False)
Definition: GeoModelConfigFlags.py:7
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.AutoConfigFlags.DetDescrInfo
def DetDescrInfo(geoTag, sqliteDB, sqliteDBFullPath)
Definition: AutoConfigFlags.py:117