ATLAS Offline Software
AtlasTrackingGeometryCondAlgConfig.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.AccumulatorCache import AccumulatorCache
4 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 from AthenaConfiguration.Enums import LHCPeriod
7 
8 def _setupCondDB(flags, CoolDataBaseFolder, quiet=True):
9 
10  result = ComponentAccumulator()
11 
12  # the tag names
13  materialTagBase = 'AtlasLayerMat_v'
14  version = 21
15  sub_version = ''
16 
17  # Tag an input tag of form TagInfo{Major|Minor}/<tag> or TagInfo(Major|Minor}/<prefix>/<tag>
18  # The tag information string defines how to handle the GeoAtlas in the TagInfo manager
19  # TagInfo : uses the geometry tag as is
20  # TagInfoMajor : only uses the major version of the geometry tag
21  # TagInfoMinor : uses both major and minor version of the geometry tag
22 
23  atlasMaterialTag = materialTagBase + str(version) + sub_version
24  cfolder = CoolDataBaseFolder + '<tag>TagInfoMajor/' + \
25  atlasMaterialTag + '_/GeoAtlas</tag>'
26 
27  if flags.GeoModel.Run < LHCPeriod.Run4:
28  # load the right folders
29  from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
30  result.merge(addFoldersSplitOnline(
31  flags, 'GLOBAL', [cfolder], [cfolder],
32  splitMC=True, className='Trk::LayerMaterialMap'))
33 
34  #redefine tag and folder for ITk, as we use a different schema
35  else:
36  atlasMaterialTag = flags.ITk.trackingGeometry.materialTag + \
37  str(flags.ITk.trackingGeometry.version)
38  if flags.ITk.trackingGeometry.loadLocalDbForMaterialMaps:
39  DataBaseName = flags.ITk.trackingGeometry.localDatabaseName
40  from IOVDbSvc.IOVDbSvcConfig import addFolders
41  result.merge(addFolders(flags,
42  "/GLOBAL/TrackingGeo/LayerMaterialITK",
43  detDb=DataBaseName,
44  tag=atlasMaterialTag,
45  className='Trk::LayerMaterialMap'))
46  else:
47  atlasVersion = flags.ITk.trackingGeometry.geometryTagForMaterialMaps
48 
49  materialFileTag = atlasMaterialTag + '_'+ \
50  atlasVersion
51  print ("Requesting material map for tracking geometry from tag = ", materialFileTag)
52  from IOVDbSvc.IOVDbSvcConfig import addFolders
53  result.merge(addFolders(flags,
54  "/GLOBAL/TrackingGeo/LayerMaterialITK",
55  "GLOBAL_OFL",
56  tag=materialFileTag,
57  db="OFLP200",
58  className="Trk::LayerMaterialMap"))
59  return result
60 
61 def GeometryBuilderCfg(flags, name='AtlasGeometryBuilder',
62  useCond=True,
63  **kwargs):
64  result = ComponentAccumulator()
65 
66  kwargs.setdefault("WorldDimension", [])
67  kwargs.setdefault("WorldMaterialProperties", [])
68 
69  if "TrackingVolumeArrayCreator" not in kwargs:
70  from TrackingGeometryCondAlg.TrkDetDescrToolsConfig import (
71  TrackingVolumeArrayCreatorCfg)
72  TrackingVolumeArrayCreator = result.popToolsAndMerge(
74  result.addPublicTool(TrackingVolumeArrayCreator)
75  kwargs.setdefault("TrackingVolumeArrayCreator",
76  TrackingVolumeArrayCreator)
77 
78  if "TrackingVolumeHelper" not in kwargs:
79  from TrackingGeometryCondAlg.TrkDetDescrToolsConfig import (
80  TrackingVolumeHelperCfg)
81  TrackingVolumeHelper = result.popToolsAndMerge(
83  result.addPublicTool(TrackingVolumeHelper)
84  kwargs.setdefault("TrackingVolumeHelper", TrackingVolumeHelper)
85 
86  # Depending on the job configuration, setup the various detector builders,
87  # and add to atlas_geometry_builder
88  if flags.Detector.GeometryID:
89  from TrackingGeometryCondAlg.InDetTrackingGeometryConfig import (
90  InDetTrackingGeometryBuilderCfg)
91  kwargs.setdefault(
92  "InDetTrackingGeometryBuilder", result.popToolsAndMerge(
93  InDetTrackingGeometryBuilderCfg(flags, useCond=useCond)))
94 
95  elif flags.Detector.GeometryITk:
96  from TrackingGeometryCondAlg.InDetTrackingGeometryConfig import (
97  ITkTrackingGeometryBuilderCfg)
98  kwargs.setdefault(
99  "InDetTrackingGeometryBuilder", result.popToolsAndMerge(
100  ITkTrackingGeometryBuilderCfg(flags, useCond=useCond)))
101 
102 
103  if flags.Detector.GeometryHGTD and useCond:
104  from TrackingGeometryCondAlg.HGTD_TrackingGeometryConfig import (
105  HGTD_TrackingGeometryBuilderCfg)
106  kwargs.setdefault(
107  "HGTD_TrackingGeometryBuilder", result.popToolsAndMerge(
109 
110  if flags.Detector.GeometryCalo:
111  from TrackingGeometryCondAlg.CaloTrackingGeometryConfig import (
112  CaloTrackingGeometryBuilderCfg)
113  kwargs.setdefault(
114  "CaloTrackingGeometryBuilder", result.popToolsAndMerge(
115  CaloTrackingGeometryBuilderCfg(flags, useCond=useCond)))
116 
117  if flags.Detector.GeometryMuon:
118  from TrackingGeometryCondAlg.MuonTrackingGeometryConfig import (
119  MuonTrackingGeometryBuilderCfg)
120  kwargs.setdefault(
121  "MuonTrackingGeometryBuilder", result.popToolsAndMerge(
122  MuonTrackingGeometryBuilderCfg(flags, useCond=useCond)))
123 
124  geometryBuilder = CompFactory.Trk.GeometryBuilderCond(name, **kwargs) \
125  if useCond else \
126  CompFactory.Trk.GeometryBuilder(name, **kwargs)
127  result.setPrivateTools(geometryBuilder)
128  return result
129 
130 @AccumulatorCache
131 def TrackingGeometryCondAlgCfg(flags, name='AtlasTrackingGeometryCondAlg',
132  doMaterialValidation=False,
133  **kwargs):
134  """
135  Sets up the Tracking Geometry Conditions Algorithm
136  """
137  result = ComponentAccumulator()
138 
139  kwargs.setdefault("GeometryBuilder", result.popToolsAndMerge(
140  GeometryBuilderCfg(flags)))
141 
142  # Now set up processors
143  atlas_geometry_processors = []
144 
145  if flags.TrackingGeometry.MaterialSource == 'COOL':
146  if flags.GeoModel.Run < LHCPeriod.Run4:
147  CoolDataBaseFolder = '/GLOBAL/TrackingGeo/LayerMaterialV2'
148  else:
149  CoolDataBaseFolder = '/GLOBAL/TrackingGeo/LayerMaterialITK'
150 
151  from TrackingGeometryCondAlg.TrkDetDescrToolsConfig import (
152  LayerMaterialProviderCfg)
153  atlas_geometry_processors += [ result.popToolsAndMerge(
155  LayerMaterialMapName = CoolDataBaseFolder,
156  LayerMaterialMapKey = CoolDataBaseFolder)) ]
157 
158  # Setup DBs
159  result.merge(_setupCondDB(flags, CoolDataBaseFolder))
160 
161  elif flags.TrackingGeometry.MaterialSource == 'Input':
162  from TrackingGeometryCondAlg.TrkDetDescrToolsConfig import (
163  InputLayerMaterialProviderCfg)
164  atlas_geometry_processors += [ result.popToolsAndMerge(
166 
167  if doMaterialValidation:
168  from TrackingGeometryCondAlg.TrkDetDescrToolsConfig import (
169  LayerMaterialInspectorCfg)
170  atlas_geometry_processors += [ result.popToolsAndMerge(
171  LayerMaterialInspectorCfg(flags)) ]
172 
173  from GaudiKernel.GaudiHandles import PrivateToolHandleArray
174  kwargs.setdefault("GeometryProcessors", PrivateToolHandleArray(
175  atlas_geometry_processors))
176  kwargs.setdefault("TrackingGeometryWriteKey", 'AtlasTrackingGeometry')
177 
178  result.addCondAlgo(CompFactory.Trk.TrackingGeometryCondAlg(name, **kwargs),
179  primary=True)
180 
181  return result
182 
183 
184 if __name__ == '__main__':
185  from AthenaConfiguration.AllConfigFlags import initConfigFlags
186  from AthenaConfiguration.TestDefaults import defaultTestFiles
187  flags = initConfigFlags()
188  flags.Input.Files = defaultTestFiles.RAW_RUN2
189  flags.lock()
190 
192 
193  f = open('TrackingGeometryCondAlgCfg.pkl', 'wb')
194  acc.store(f)
195  f.close()
MuonTrackingGeometryConfig.MuonTrackingGeometryBuilderCfg
def MuonTrackingGeometryBuilderCfg(flags, name='MuonTrackingGeometryBuilder', useCond=True, **kwargs)
Definition: MuonTrackingGeometryConfig.py:41
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
InDetTrackingGeometryConfig.ITkTrackingGeometryBuilderCfg
def ITkTrackingGeometryBuilderCfg(flags, name='ITkTrackingGeometryBuilder', useCond=True, **kwargs)
Definition: InDetTrackingGeometryConfig.py:356
AtlasTrackingGeometryCondAlgConfig.TrackingGeometryCondAlgCfg
def TrackingGeometryCondAlgCfg(flags, name='AtlasTrackingGeometryCondAlg', doMaterialValidation=False, **kwargs)
Definition: AtlasTrackingGeometryCondAlgConfig.py:131
AtlasTrackingGeometryCondAlgConfig.GeometryBuilderCfg
def GeometryBuilderCfg(flags, name='AtlasGeometryBuilder', useCond=True, **kwargs)
Definition: AtlasTrackingGeometryCondAlgConfig.py:61
InDetTrackingGeometryConfig.InDetTrackingGeometryBuilderCfg
def InDetTrackingGeometryBuilderCfg(flags, name='InDetTrackingGeometryBuilder', useCond=True, **kwargs)
Definition: InDetTrackingGeometryConfig.py:220
TrkDetDescrToolsConfig.LayerMaterialProviderCfg
def LayerMaterialProviderCfg(flags, name='AtlasMaterialCondProvider', **kwargs)
Definition: TrkDetDescrToolsConfig.py:213
CaloTrackingGeometryConfig.CaloTrackingGeometryBuilderCfg
def CaloTrackingGeometryBuilderCfg(flags, name='CaloTrackingGeometryBuilder', useCond=True, **kwargs)
Definition: Tracking/TrkConditions/TrackingGeometryCondAlg/python/CaloTrackingGeometryConfig.py:41
TrkDetDescrToolsConfig.TrackingVolumeArrayCreatorCfg
def TrackingVolumeArrayCreatorCfg(flags, name="TrackingVolumeArrayCreator", **kwargs)
Definition: TrkDetDescrToolsConfig.py:47
AtlasTrackingGeometryCondAlgConfig._setupCondDB
def _setupCondDB(flags, CoolDataBaseFolder, quiet=True)
Definition: AtlasTrackingGeometryCondAlgConfig.py:8
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
TrkDetDescrToolsConfig.LayerMaterialInspectorCfg
def LayerMaterialInspectorCfg(flags, name='AtlasLayerMaterialInspector', **kwargs)
Definition: TrkDetDescrToolsConfig.py:226
python.IOVDbSvcConfig.addFoldersSplitOnline
def addFoldersSplitOnline(flags, detDb, onlineFolders, offlineFolders, className=None, extensible=False, addMCString='_OFL', splitMC=False, tag=None, forceDb=None, modifiers='')
Definition: IOVDbSvcConfig.py:153
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
HGTD_TrackingGeometryConfig.HGTD_TrackingGeometryBuilderCfg
def HGTD_TrackingGeometryBuilderCfg(flags, name='HGTD_TrackingGeometryBuilderCond', **kwargs)
Definition: HGTD_TrackingGeometryConfig.py:22
str
Definition: BTagTrackIpAccessor.cxx:11
TrkDetDescrToolsConfig.InputLayerMaterialProviderCfg
def InputLayerMaterialProviderCfg(flags, name='AtlasMaterialProvider', **kwargs)
Definition: TrkDetDescrToolsConfig.py:219
TrkDetDescrToolsConfig.TrackingVolumeHelperCfg
def TrackingVolumeHelperCfg(flags, name='TrackingVolumeHelper', **kwargs)
Definition: TrkDetDescrToolsConfig.py:27