ATLAS Offline Software
ActsEventCnvConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 
5 
7  name: str = "ActsToTrkConverterTool",
8  **kwargs) -> ComponentAccumulator:
10 
11  # Currently this does not work if we are in a muon-only mode
12  if flags.Detector.GeometryITk and 'TrackingGeometryTool' not in kwargs:
13  from ActsConfig.ActsGeometryConfig import ActsTrackingGeometryToolCfg
14  kwargs.setdefault("TrackingGeometryTool", acc.popToolsAndMerge(ActsTrackingGeometryToolCfg(flags)))
15  else:
16  # Disable TrackingGeometryTool
17  kwargs.setdefault("TrackingGeometryTool", "")
18 
19  if flags.Muon.usePhaseIIGeoSetup:
20  kwargs.setdefault("ExtractMuonSurfaces", True)
21 
22  acc.setPrivateTools(CompFactory.ActsTrk.ActsToTrkConverterTool(name, **kwargs))
23  return acc
24 
25 
27  name: str = "",
28  **kwargs) -> ComponentAccumulator:
29  acc = ComponentAccumulator()
30 
31  if 'ConvertorTool' not in kwargs:
32  kwargs.setdefault("ConvertorTool", acc.popToolsAndMerge(ActsToTrkConverterToolCfg(flags)))
33 
34  acc.addEventAlgo(CompFactory.ActsTrk.TrkToActsConvertorAlg(name, **kwargs))
35  return acc
36 
38  name: str = "ActsToTrkConvertorAlg",
39  **kwargs) -> ComponentAccumulator:
40  acc = ComponentAccumulator()
41 
42  # convert proper ACTS track collection
43  # this depends on the ambi resol. activation
44  kwargs.setdefault('ACTSTracksLocation', 'ActsTracks' if not flags.Acts.doAmbiguityResolution else 'ActsResolvedTracks')
45 
46  if 'TrackingGeometryTool' not in kwargs:
47  from ActsConfig.ActsGeometryConfig import ActsTrackingGeometryToolCfg
48  kwargs.setdefault("TrackingGeometryTool", acc.popToolsAndMerge(ActsTrackingGeometryToolCfg(flags)))
49 
50  if 'ATLASConverterTool' not in kwargs:
51  from ActsConfig.ActsEventCnvConfig import ActsToTrkConverterToolCfg
52  kwargs.setdefault("ATLASConverterTool", acc.popToolsAndMerge(ActsToTrkConverterToolCfg(flags)))
53 
54  if 'BoundaryCheckTool' not in kwargs:
55  if flags.Detector.GeometryITk:
56  from InDetConfig.InDetBoundaryCheckToolConfig import ITkBoundaryCheckToolCfg
57  kwargs.setdefault("BoundaryCheckTool", acc.popToolsAndMerge(ITkBoundaryCheckToolCfg(flags)))
58  else:
59  from InDetConfig.InDetBoundaryCheckToolConfig import InDetBoundaryCheckToolCfg
60  kwargs.setdefault("BoundaryCheckTool", acc.popToolsAndMerge(InDetBoundaryCheckToolCfg(flags)))
61 
62  if 'SummaryTool' not in kwargs:
63  from TrkConfig.TrkTrackSummaryToolConfig import InDetTrackSummaryToolCfg
64  kwargs.setdefault("SummaryTool", acc.popToolsAndMerge(InDetTrackSummaryToolCfg(flags)))
65 
66  if flags.Acts.doRotCorrection and 'RotCreatorTool' not in kwargs:
67  if flags.Detector.GeometryITk:
68  from TrkConfig.TrkRIO_OnTrackCreatorConfig import ITkRotCreatorCfg
69  kwargs.setdefault("RotCreatorTool", acc.popToolsAndMerge(ITkRotCreatorCfg(flags, name="ActsRotCreatorTool")))
70  else:
71  from TrkConfig.TrkRIO_OnTrackCreatorConfig import InDetRotCreatorCfg
72  kwargs.setdefault("RotCreatorTool", acc.popToolsAndMerge(InDetRotCreatorCfg(flags, name="ActsRotCreatorTool")))
73 
74  acc.addEventAlgo(CompFactory.ActsTrk.ActsToTrkConvertorAlg(name, **kwargs))
75  return acc
76 
77 def RunTrackConversion(flags, track_collections = [], outputfile='dump.json'):
78  from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg
79  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
80  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
81 
82  cfg = MainServicesCfg(flags)
83 
84  # Set up to read ESD and tracks
85  cfg.merge(PoolReadCfg(flags))
86  for collection in track_collections:
87  cfg.merge(TrackCollectionReadCfg(flags, collection))
88 
89  # Needed to read tracks
90  from TrkEventCnvTools.TrkEventCnvToolsConfig import TrkEventCnvSuperToolCfg
91  cfg.merge(TrkEventCnvSuperToolCfg(flags))
92 
93  # Muon geometry not yet in ActsTrackingGeometrySvcCfg
94  from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
95  cfg.merge(MuonGeoModelCfg(flags))
96 
97  # Now setup the convertor
99  flags, OutputLevel=1, TrackCollectionKeys=track_collections)
100  cfg.merge(acc)
101 
102  # Let's dump the input tracks, and also the output ACTS tracks
103  from DumpEventDataToJSON.DumpEventDataToJSONConfig import DumpEventDataToJSONAlgCfg
105  flags, doExtrap=False, OutputLevel=1,
106  TrackCollectionKeys=track_collections,
107  CscPrepRawDataKey="",
108  MMPrepRawDataKey="",
109  sTgcPrepRawDataKey="",
110  MdtPrepRawDataKey="",
111  RpcPrepRawDataKey="",
112  TgcPrepRawDataKey="",
113  PixelPrepRawDataKey="",
114  SctPrepRawDataKey="",
115  TrtPrepRawDataKey="",
116  CaloCellContainerKey=[""],
117  CaloClusterContainerKeys=[""],
118  MuonContainerKeys=[""],
119  JetContainerKeys=[""],
120  TrackParticleContainerKeys=[""],
121  OutputLocation=outputfile,
122  )
123  cfg.merge(acc)
124  cfg.printConfig(withDetails=True, summariseProps=True)
125 
126  sc = cfg.run()
127  if not sc.isSuccess():
128  import sys
129  sys.exit("Execution failed")
130 
131 
132 if __name__ == "__main__":
133  # To run this, do e.g.
134  # python -m ActsEventCnv.ActsEventCnvConfig --threads=1
135  from AthenaConfiguration.AllConfigFlags import initConfigFlags
136  flags = initConfigFlags()
137  args = flags.fillFromArgs()
138 
139  flags.Input.Files = [
140  '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/PhaseIIUpgrade/ESD/ATLAS-P2-RUN4-03-00-00/ESD.ttbar_mu0.pool.root']
141  from AthenaConfiguration.TestDefaults import defaultConditionsTags
142  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
143  flags.Scheduler.ShowDataDeps = True
144  flags.Scheduler.ShowDataFlow = True
145  flags.Scheduler.CheckDependencies = True
146 
147  # Setup detector flags
148  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
149  setupDetectorFlags(flags, None, use_metadata=True,
150  toggle_geometry=True, keep_beampipe=True)
151 
152  flags.lock()
153  flags.dump()
154  RunTrackConversion(flags)
python.TrkRIO_OnTrackCreatorConfig.ITkRotCreatorCfg
def ITkRotCreatorCfg(flags, name='ITkRotCreator', **kwargs)
Definition: TrkRIO_OnTrackCreatorConfig.py:134
ActsEventCnvConfig.RunTrackConversion
def RunTrackConversion(flags, track_collections=[], outputfile='dump.json')
Definition: ActsEventCnvConfig.py:77
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TrkRIO_OnTrackCreatorConfig.InDetRotCreatorCfg
def InDetRotCreatorCfg(flags, name='InDetRotCreator', **kwargs)
Definition: TrkRIO_OnTrackCreatorConfig.py:13
ActsEventCnvConfig.ActsToTrkConverterToolCfg
ComponentAccumulator ActsToTrkConverterToolCfg(flags, str name="ActsToTrkConverterTool", **kwargs)
Definition: ActsEventCnvConfig.py:6
python.InDetBoundaryCheckToolConfig.ITkBoundaryCheckToolCfg
def ITkBoundaryCheckToolCfg(flags, name='ITkBoundaryCheckTool', **kwargs)
Definition: InDetBoundaryCheckToolConfig.py:102
ActsEventCnvConfig.TrkToActsConvertorAlgCfg
ComponentAccumulator TrkToActsConvertorAlgCfg(flags, str name="", **kwargs)
Definition: ActsEventCnvConfig.py:26
python.TrkEventCnvToolsConfig.TrkEventCnvSuperToolCfg
def TrkEventCnvSuperToolCfg(flags, name='EventCnvSuperTool', **kwargs)
Definition: TrkEventCnvToolsConfig.py:51
python.TrkTrackSummaryToolConfig.InDetTrackSummaryToolCfg
def InDetTrackSummaryToolCfg(flags, name='InDetTrackSummaryTool', **kwargs)
Definition: TrkTrackSummaryToolConfig.py:22
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
ActsEventCnvConfig.ActsToTrkConvertorAlgCfg
ComponentAccumulator ActsToTrkConvertorAlgCfg(flags, str name="ActsToTrkConvertorAlg", **kwargs)
Definition: ActsEventCnvConfig.py:37
DumpEventDataToJSONConfig.DumpEventDataToJSONAlgCfg
def DumpEventDataToJSONAlgCfg(flags, doExtrap=False, doACTSEDM=True, **kwargs)
Definition: DumpEventDataToJSONConfig.py:8
ActsGeometryConfig.ActsTrackingGeometryToolCfg
ComponentAccumulator ActsTrackingGeometryToolCfg(flags, str name="ActsTrackingGeometryTool")
Definition: ActsGeometryConfig.py:100
python.InDetBoundaryCheckToolConfig.InDetBoundaryCheckToolCfg
def InDetBoundaryCheckToolCfg(flags, name='InDetBoundarySearchTool', **kwargs)
Definition: InDetBoundaryCheckToolConfig.py:7
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.MuonGeometryConfig.MuonGeoModelCfg
def MuonGeoModelCfg(flags)
Definition: MuonGeometryConfig.py:28
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.TrackCollectionReadConfig.TrackCollectionReadCfg
def TrackCollectionReadCfg(flags, key)
Definition: TrackCollectionReadConfig.py:28