ATLAS Offline Software
Loading...
Searching...
No Matches
GeoModelConfigFlags.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.AthConfigFlags import AthConfigFlags
4from AthenaConfiguration.AutoConfigFlags import GetFileMD, DetDescrInfo
5from AthenaConfiguration.Enums import LHCPeriod, ProductionStep, Project
6
7def 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 _deduce_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 deduce 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 deduced from other metadata
42 _deduce_LHCPeriod, type=LHCPeriod, help='LHC Run period')
43 return gcf
44
45 def _deduce_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", _deduce_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 def _deduce_LegacyConditionsAccess(prevFlags):
71 if prevFlags.Common.Project is Project.AthSimulation:
72 return True
73 if prevFlags.Common.ProductionStep is not ProductionStep.Simulation:
74 return False
75 from SimulationConfig.SimEnums import LArParameterization
76 if prevFlags.Sim.ISF.Simulator.usesFastCaloSim() or prevFlags.Sim.LArParameterization is LArParameterization.FastCaloSim:
77 return False
78 return True
79
80 gcf.addFlag("GeoModel.Align.LegacyConditionsAccess", _deduce_LegacyConditionsAccess,
81 help='Flag for using the legacy conditions access infrastructure')
82 # Mainly for G4 which still loads alignment on initialize
83
84 gcf.addFlag("GeoModel.Type",
85 lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.AtlasVersion,prevFlags.GeoModel.SQLiteDB,prevFlags.GeoModel.SQLiteDBFullPath)['Common']['GeoType'],
86 help='Geometry type in {ITKLoI, ITkLoI-VF, etc...}')
87
88 gcf.addFlag("GeoModel.IBLLayout",
89 lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.AtlasVersion,prevFlags.GeoModel.SQLiteDB,prevFlags.GeoModel.SQLiteDBFullPath)['Pixel']['IBLlayout'],
90 help='IBL layer layout in {"planar", "3D", "noIBL"}')
91
92 gcf.addFlag('GeoModel.EMECStandard',False, help='Flag for activating the EMEC description with standard Geant4 shapes: G4GenericTrap')
93
94 gcf.addFlag('GeoModel.SQLiteDB',False, help='Flag for activating GeoModel initialization from SQLite Geometry DB')
95
96 gcf.addFlag('GeoModel.SQLiteDBFullPath','', help='Override default location of the SQLite Geometry DB')
97
98 gcf.addFlag('GeoModel.IgnoreTagDifference',False, help='Ignore geometry tag difference between the configured value and the value read from the input file metadata')
99
100 # Add the DumpGeo config flags
101 from DumpGeo.DumpGeoConfigFlags import createDumpGeoConfigFlags
102 gcf = createDumpGeoConfigFlags(gcf)
103
104 return gcf
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
createGeoModelConfigFlags(analysis=False)