ATLAS Offline Software
MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.AccumulatorCache import AccumulatorCache
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
6 
7 def TruthSegmentMakerCfg(flags, name = "MuonTruthSegmentMaker", useSDO = True, **kwargs):
8  result = ComponentAccumulator()
9  if not flags.Input.isMC:
10  return result
11 
12  from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
13  result.merge(ActsGeometryContextAlgCfg(flags))
14  containerNames = []
15 
16  if flags.Detector.EnableMDT: containerNames+=["MDT_SDO" if useSDO else "xMdtSimHits"]
17  if flags.Detector.EnableRPC: containerNames+=["RPC_SDO" if useSDO else "xRpcSimHits"]
18  if flags.Detector.EnableTGC: containerNames+=["TGC_SDO" if useSDO else "xTgcSimHits"]
19  if flags.Detector.EnableMM: containerNames+=["MM_SDO" if useSDO else "xMmSimHits"]
20  if flags.Detector.EnablesTGC: containerNames+=["sTGC_SDO" if useSDO else "xStgcSimHits"]
21 
22  from MuonConfig.MuonCalibrationConfig import MdtCalibDbAlgCfg, NswErrorCalibDbAlgCfg
23  if flags.Detector.EnableMDT:
24  result.merge(MdtCalibDbAlgCfg(flags))
25  if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
26  result.merge(NswErrorCalibDbAlgCfg(flags))
27  kwargs.setdefault("SimHitKeys", containerNames)
28 
29  the_alg = CompFactory.MuonR4.TruthSegmentMaker(name, **kwargs)
30  result.addEventAlgo(the_alg, primary = True)
31  return result
32 
33 def MeasToSimHitAssocAlgCfg(flags, name="MeasToSimHitConvAlg", **kwargs):
34  result = ComponentAccumulator()
35  from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
36  result.merge(ActsGeometryContextAlgCfg(flags))
37  the_alg = CompFactory.MuonR4.PrepDataToSimHitAssocAlg(name, **kwargs)
38  result.addEventAlgo(the_alg, primary = True)
39  return result
40 
42  result = ComponentAccumulator()
43  if not flags.Input.isMC:
44  return result
45  from MuonConfig.MuonDataPrepConfig import PrimaryMeasContNamesCfg
46  for cont_name in PrimaryMeasContNamesCfg(flags):
47  simHits = ""
48  if "xMdt" in cont_name:
49  simHits = "MDT_SDO"
50  elif "xRpc" in cont_name:
51  simHits = "RPC_SDO"
52  elif "xTgc" in cont_name:
53  simHits = "TGC_SDO"
54  elif "MM" in cont_name:
55  simHits = "MM_SDO"
56  else:
57  simHits = "sTGC_SDO"
58  result.merge(MeasToSimHitAssocAlgCfg(flags,
59  name=f"{cont_name}PrepDataToSimHitAssoc",
60  SimHits = simHits,
61  Measurements=cont_name,
62  AssocPull = 1. if cont_name=="xAODsTgcPads" else 3. ))
63  return result
64 
65 def SimHitToTruthPartAlgCfg(flags, useSDO = False):
66  result = ComponentAccumulator()
67  if flags.Detector.GeometryMDT:
68  container = "xMdtSimHits" if not useSDO else "MDT_SDO"
69  the_alg = CompFactory.MuonR4.SimHitToTruthPartAssocAlg("MuonMdtSimHitToTruthMappingAlg",
70  SimHitContainer = container,
71  HitIdDecoration = "truthMdtHits")
72  result.addEventAlgo(the_alg)
73  if flags.Detector.GeometryRPC:
74  container = "xRpcSimHits" if not useSDO else "RPC_SDO"
75  the_alg = CompFactory.MuonR4.SimHitToTruthPartAssocAlg("MuonRpcSimHitToTruthMappingAlg",
76  SimHitContainer = container,
77  HitIdDecoration = "truthRpcHits")
78  result.addEventAlgo(the_alg)
79  if flags.Detector.GeometryTGC:
80  container = "xTgcSimHits" if not useSDO else "TGC_SDO"
81  the_alg = CompFactory.MuonR4.SimHitToTruthPartAssocAlg("MuonTgcSimHitToTruthMappingAlg",
82  SimHitContainer = container,
83  HitIdDecoration = "truthTgcHits")
84  result.addEventAlgo(the_alg)
85  if flags.Detector.GeometryMM:
86  container = "xMmSimHits" if not useSDO else "MM_SDO"
87  the_alg = CompFactory.MuonR4.SimHitToTruthPartAssocAlg("MuonMmSimHitToTruthMappingAlg",
88  SimHitContainer = container,
89  HitIdDecoration = "truthMMHits")
90  result.addEventAlgo(the_alg)
91  if flags.Detector.GeometrysTGC:
92  container = "xStgcSimHits" if not useSDO else "sTGC_SDO"
93  the_alg = CompFactory.MuonR4.SimHitToTruthPartAssocAlg("MuonsTGCSimHitToTruthMappingAlg",
94  SimHitContainer = container,
95  HitIdDecoration = "truthStgcHits")
96  result.addEventAlgo(the_alg)
97 
98  return result
99 
100 def TruthHitSummaryAlgCfg(flags, name="MuonTruthHitSummaryAlg", **kwargs):
101  result = ComponentAccumulator()
102  from MuonTrackFindingAlgs.TrackFindingConfig import TrackSummaryToolCfg
103  kwargs.setdefault("SummaryTool", result.popToolsAndMerge(TrackSummaryToolCfg(flags,
104  fillHoles=False, fillOutliers=False,
105  recomputeSegment =False)))
106  the_alg = CompFactory.MuonR4.TruthHitSummaryAlg(name, **kwargs)
107  result.addEventAlgo(the_alg, primary = True)
108  return result
109 
110 def RecoSegmentTruthAssocCfg(flags, **kwargs):
111  result = ComponentAccumulator()
112 
113  kwargs.setdefault("SegmentKey", "")
114  from MuonConfig.MuonDataPrepConfig import PrimaryMeasContNamesCfg
115  kwargs.setdefault("PrdContainer", PrimaryMeasContNamesCfg(flags))
116  the_alg = CompFactory.MuonR4.RecoSegToTruthAssocAlg(**kwargs)
117  result.addEventAlgo(the_alg, primary = True)
118  return result
119 
120 def TruthSegmentToTruthPartAssocCfg(flags, name="MuonTruthSegmentToTruthAssocAlg", **kwargs):
121  result = ComponentAccumulator()
122  hitDecors = []
123  if flags.Detector.GeometryMDT: hitDecors+=["truthMdtHits"]
124  if flags.Detector.GeometryRPC: hitDecors+=["truthRpcHits"]
125  if flags.Detector.GeometryTGC: hitDecors+=["truthTgcHits"]
126  if flags.Detector.GeometryMM: hitDecors+=["truthMMHits"]
127  if flags.Detector.GeometrysTGC: hitDecors+=["truthStgcHits"]
128  kwargs.setdefault("SimHitIds", hitDecors)
129  the_alg = CompFactory.MuonR4.TruthSegToTruthPartAssocAlg(name, **kwargs)
130  result.addEventAlgo(the_alg, primary = True)
131  return result
132 
133 def TrackToTruthPartAssocCfg(flags, **kwargs):
134  result = ComponentAccumulator()
135  hitDecors = []
136  if flags.Detector.GeometryMDT: hitDecors+=["truthMdtHits"]
137  if flags.Detector.GeometryRPC: hitDecors+=["truthRpcHits"]
138  if flags.Detector.GeometryTGC: hitDecors+=["truthTgcHits"]
139  if flags.Detector.GeometryMM: hitDecors+=["truthMMHits"]
140  if flags.Detector.GeometrysTGC: hitDecors+=["truthStgcHits"]
141  kwargs.setdefault("SimHitIds", hitDecors)
142  the_alg = CompFactory.MuonR4.TrackToTruthPartAssocAlg(**kwargs)
143  result.addEventAlgo(the_alg, primary = True)
144  return result
145 
146 
147 @AccumulatorCache
148 def MuonTruthAlgsCfg(flags, useSDO=True, recoAssoc = True):
149  result = ComponentAccumulator()
150  if not flags.Input.isMC:
151  return result
152  if useSDO and recoAssoc:
153  result.merge(TruthHitAssociationCfg(flags))
154 
155  from MuonConfig.MuonTruthAlgsConfig import TruthMuonMakerAlgCfg
156  result.merge(TruthMuonMakerAlgCfg(flags))
157  result.merge(SimHitToTruthPartAlgCfg(flags, useSDO = useSDO))
158  result.merge(TruthSegmentMakerCfg(flags, useSDO = useSDO))
159  result.merge(TruthHitSummaryAlgCfg(flags))
160 
161  # result.merge(MuonTruthHitCountsAlgCfg(flags))
162 
165  result.merge(TruthSegmentToTruthPartAssocCfg(flags))
166 
167  return result
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:342
MuonTruthAlgsConfig.TruthHitAssociationCfg
def TruthHitAssociationCfg(flags)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:41
MuonTruthAlgsConfig.TruthHitSummaryAlgCfg
def TruthHitSummaryAlgCfg(flags, name="MuonTruthHitSummaryAlg", **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:100
MuonTruthAlgsConfig.TruthSegmentMakerCfg
def TruthSegmentMakerCfg(flags, name="MuonTruthSegmentMaker", useSDO=True, **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:7
MuonTruthAlgsConfig.TruthSegmentToTruthPartAssocCfg
def TruthSegmentToTruthPartAssocCfg(flags, name="MuonTruthSegmentToTruthAssocAlg", **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:120
MuonTruthAlgsConfig.MuonTruthAlgsCfg
def MuonTruthAlgsCfg(flags)
Definition: MuonConfig/python/MuonTruthAlgsConfig.py:99
MuonCalibrationConfig.NswErrorCalibDbAlgCfg
def NswErrorCalibDbAlgCfg(flags, name="NswErrorCalibDbAlg", **kwargs)
Definition: MuonCalibrationConfig.py:209
MuonDataPrepConfig.PrimaryMeasContNamesCfg
def PrimaryMeasContNamesCfg(flags)
Definition: MuonDataPrepConfig.py:6
MuonTruthAlgsConfig.TrackToTruthPartAssocCfg
def TrackToTruthPartAssocCfg(flags, **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:133
AlignmentAlgsConfig.ActsGeometryContextAlgCfg
def ActsGeometryContextAlgCfg(flags, name="GeometryContextAlg", **kwargs)
Setup the Geometry context algorithm.
Definition: AlignmentAlgsConfig.py:109
MuonTruthAlgsConfig.MeasToSimHitAssocAlgCfg
def MeasToSimHitAssocAlgCfg(flags, name="MeasToSimHitConvAlg", **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:33
MuonTruthAlgsConfig.RecoSegmentTruthAssocCfg
def RecoSegmentTruthAssocCfg(flags, **kwargs)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:110
TrackFindingConfig.TrackSummaryToolCfg
def TrackSummaryToolCfg(flags, name="MuonTrackSummaryTool", **kwargs)
Definition: TrackFindingConfig.py:34
MuonCalibrationConfig.MdtCalibDbAlgCfg
def MdtCalibDbAlgCfg(flags, name="MdtCalibDbAlg", **kwargs)
Definition: MuonCalibrationConfig.py:128
MuonTruthAlgsConfig.SimHitToTruthPartAlgCfg
def SimHitToTruthPartAlgCfg(flags, useSDO=False)
Definition: MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/python/MuonTruthAlgsConfig.py:65
MuonTruthAlgsConfig.TruthMuonMakerAlgCfg
def TruthMuonMakerAlgCfg(flags, name="TruthMuonMakerAlg", **kwargs)
Definition: MuonConfig/python/MuonTruthAlgsConfig.py:28