ATLAS Offline Software
MDT_DigitizationConfig.py
Go to the documentation of this file.
1 """Define methods to construct configured MDT Digitization tools and algorithms
2 
3 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 """
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import BeamType, ProductionStep
8 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
9 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
10 from MuonConfig.MuonByteStreamCnvTestConfig import MdtDigitToMdtRDOCfg
11 from MuonConfig.MuonCablingConfig import MDTCablingConfigCfg
12 from DigitizationConfig.TruthDigitizationOutputConfig import TruthDigitizationOutputCfg
13 from DigitizationConfig.PileUpToolsConfig import PileUpToolsCfg
14 from DigitizationConfig.PileUpMergeSvcConfig import PileUpMergeSvcCfg, PileUpXingFolderCfg
15 
16 
17 # The earliest and last bunch crossing times for which interactions will be sent
18 # to the MdtDigitizationTool.
20  return -800
21 
22 
24  # was 800 for large time window
25  return 150
26 
27 
28 def MDT_RangeCfg(flags, name="MDT_Range", **kwargs):
29  """Return a PileUpXingFolder tool configured for MDT"""
30  kwargs.setdefault("FirstXing", MDT_FirstXing())
31  kwargs.setdefault("LastXing", MDT_LastXing())
32  kwargs.setdefault("CacheRefreshFrequency", 1.0)
33  if flags.Muon.usePhaseIIGeoSetup:
34  kwargs.setdefault("ItemList", ["xAOD::MuonSimHitContainer#xMdtSimHits",
35  "xAOD::MuonSimHitAuxContainer#xMdtSimHitsAux."])
36  else:
37  kwargs.setdefault("ItemList", ["MDTSimHitCollection#MDT_Hits"])
38  return PileUpXingFolderCfg(flags, name, **kwargs)
39 
40 
41 def RT_Relation_DB_DigiToolCfg(flags, name="RT_Relation_DB_DigiTool", **kwargs):
42  """Return an RT_Relation_DB_DigiTool"""
43  acc = ComponentAccumulator()
44  acc.setPrivateTools(CompFactory.RT_Relation_DB_DigiTool(name, **kwargs))
45  return acc
46 
47 
48 def MDT_Response_DigiToolCfg(flags, name="MDT_Response_DigiTool",**kwargs):
49  """Return a configured MDT_Response_DigiTool"""
50  acc = ComponentAccumulator()
51  kwargs.setdefault("DoQballGamma", (flags.Input.SpecialConfiguration.get("MDT_QballConfig", "False") == "True"))
52  MDT_Response_DigiTool = CompFactory.MDT_Response_DigiTool
53  acc.setPrivateTools(MDT_Response_DigiTool(name, **kwargs))
54  return acc
55 
56 
57 def MDT_DigitizationToolCommonCfg(flags, name="MdtDigitizationTool", **kwargs):
58  """Return ComponentAccumulator with common MdtDigitizationTool config"""
59  from MuonConfig.MuonCondAlgConfig import MdtCondDbAlgCfg # MT-safe conditions access
60  from MuonConfig.MuonCalibrationConfig import MdtCalibDbAlgCfg
61 
62  acc = ComponentAccumulator()
63  acc.merge(MdtCondDbAlgCfg(flags))
64  acc.merge(MdtCalibDbAlgCfg(flags))
65 
66 
67  if not flags.Muon.usePhaseIIGeoSetup:
68  kwargs.setdefault("DiscardEarlyHits", True)
69  kwargs.setdefault("UseTof", flags.Beam.Type is not BeamType.Cosmics)
70  kwargs.setdefault("DoQballCharge", (flags.Input.SpecialConfiguration.get("MDT_QballConfig", "False") == "True"))
71  kwargs.setdefault("DigitizationTool", acc.popToolsAndMerge(MDT_Response_DigiToolCfg(flags)))
72  else:
73 
74  from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
75  acc.merge(ActsGeometryContextAlgCfg(flags))
76  kwargs.setdefault("useTwinTubes", True)
77  if kwargs["useTwinTubes"]:
78  from MuonConfig.MuonCablingConfig import MdtTwinTubeMapCondAlgCfg
79  acc.merge(MdtTwinTubeMapCondAlgCfg(flags))
80  kwargs.setdefault("DigitizationTool", acc.popToolsAndMerge(RT_Relation_DB_DigiToolCfg(flags)))
81  kwargs.setdefault("SimHitKey", "xMdtSimHits")
82  kwargs.setdefault("StreamName", "MdtDigitForklifting")
83 
84  if flags.Digitization.DoXingByXingPileUp:
85  kwargs.setdefault("FirstXing", MDT_FirstXing())
86  kwargs.setdefault("LastXing", MDT_LastXing())
87  from RngComps.RngCompsConfig import AthRNGSvcCfg
88  kwargs.setdefault("RndmSvc", acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)))
89  if not flags.Muon.usePhaseIIGeoSetup:
90  acc.setPrivateTools(CompFactory.MdtDigitizationTool(name, **kwargs))
91  else:
92  acc.setPrivateTools(CompFactory.MuonR4.MdtDigitizationTool(name, **kwargs))
93  return acc
94 
95 
96 def MDT_DigitizationToolCfg(flags, name="MdtDigitizationTool", **kwargs):
97  """Return ComponentAccumulator with configured MdtDigitizationTool"""
98  acc = ComponentAccumulator()
99  if flags.Digitization.PileUp:
100  intervals = []
101  if not flags.Digitization.DoXingByXingPileUp:
102  intervals += [acc.popToolsAndMerge(MDT_RangeCfg(flags))]
103  kwargs.setdefault("PileUpMergeSvc", acc.getPrimaryAndMerge(PileUpMergeSvcCfg(flags, Intervals=intervals)).name)
104  else:
105  kwargs.setdefault("PileUpMergeSvc", '')
106  kwargs.setdefault("OnlyUseContainerName", flags.Digitization.PileUp)
107  kwargs.setdefault("OutputObjectName", "MDT_DIGITS")
108  if flags.Common.ProductionStep == ProductionStep.PileUpPresampling:
109  kwargs.setdefault("OutputSDOName", flags.Overlay.BkgPrefix + "MDT_SDO")
110  else:
111  kwargs.setdefault("OutputSDOName", "MDT_SDO")
112  tool = acc.popToolsAndMerge(MDT_DigitizationToolCommonCfg(flags, name, **kwargs))
113  acc.setPrivateTools(tool)
114  return acc
115 
116 
117 def MDT_OverlayDigitizationToolCfg(flags, name="Mdt_OverlayDigitizationTool", **kwargs):
118  """Return ComponentAccumulator with MdtDigitizationTool configured for Overlay"""
119  kwargs.setdefault("OnlyUseContainerName", False)
120  kwargs.setdefault("OutputObjectName", flags.Overlay.SigPrefix + "MDT_DIGITS")
121  kwargs.setdefault("OutputSDOName", flags.Overlay.SigPrefix + "MDT_SDO")
122  kwargs.setdefault("PileUpMergeSvc", '')
123  return MDT_DigitizationToolCommonCfg(flags, name, **kwargs)
124 
125 
126 def MDT_OutputCfg(flags):
127  """Return ComponentAccumulator with Output for MDT. Not standalone."""
128  acc = ComponentAccumulator()
129  if flags.Output.doWriteRDO:
130  ItemList = ["MdtCsmContainer#*"]
131  if flags.Digitization.EnableTruth:
132  for pref in [flags.Overlay.SigPrefix, flags.Overlay.BkgPrefix, ""]:
133 
134  ItemList += [f"MuonSimDataCollection#{pref}MDT_SDO"]
135 
136  ItemList += [f"xAOD::MuonSimHitContainer#{pref}MDT_SDO", f"xAOD::MuonSimHitAuxContainer#{pref}MDT_SDOAux."]
137  acc.merge(TruthDigitizationOutputCfg(flags))
138  acc.merge(OutputStreamCfg(flags, "RDO", ItemList))
139  return acc
140 
141 
142 def MDT_DigitizationBasicCfg(flags, **kwargs):
143  """Return ComponentAccumulator for MDT digitization"""
144  acc = MuonGeoModelCfg(flags)
145  if "PileUpTools" not in kwargs:
146  PileUpTools = acc.popToolsAndMerge(MDT_DigitizationToolCfg(flags))
147  kwargs["PileUpTools"] = PileUpTools
148  acc.merge(PileUpToolsCfg(flags, **kwargs))
149  return acc
150 
151 
152 def MDT_OverlayDigitizationBasicCfg(flags, **kwargs):
153  """Return ComponentAccumulator with MDT Overlay digitization"""
154  acc = MuonGeoModelCfg(flags)
155  from MuonConfig.MuonCalibrationConfig import MdtCalibDbAlgCfg
156  acc.merge(MdtCalibDbAlgCfg(flags))
157 
158  if flags.Common.ProductionStep != ProductionStep.FastChain:
159  from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
160  if flags.Muon.usePhaseIIGeoSetup:
161  acc.merge(SGInputLoaderCfg(flags, ["xAOD::MuonSimHitContainer#xMdtSimHits",
162  "xAOD::MuonSimHitAuxContainer#xMdtSimHitsAux."]))
163  else:
164  acc.merge(SGInputLoaderCfg(flags, ["MDTSimHitCollection#MDT_Hits"]))
165 
166  kwargs.setdefault("DigitizationTool", acc.popToolsAndMerge(MDT_OverlayDigitizationToolCfg(flags)))
167 
168  if flags.Concurrency.NumThreads > 0:
169  kwargs.setdefault("Cardinality", flags.Concurrency.NumThreads)
170 
171  # Set common overlay extra inputs
172  kwargs.setdefault("ExtraInputs", flags.Overlay.ExtraInputs)
173 
174  acc.addEventAlgo(CompFactory.MuonDigitizer(name="MDT_OverlayDigitizer", **kwargs))
175  return acc
176 
177 
178 # with output defaults
179 def MDT_DigitizationCfg(flags, **kwargs):
180  """Return ComponentAccumulator for MDT digitization and Output"""
181  acc = MDT_DigitizationBasicCfg(flags, **kwargs)
182  acc.merge(MDT_OutputCfg(flags))
183  return acc
184 
185 
187  """Return ComponentAccumulator with MDT digitization and Digit to MDTCSM RDO"""
188  acc = MDT_DigitizationCfg(flags)
189  acc.merge(MDTCablingConfigCfg(flags))
190  acc.merge(MdtDigitToMdtRDOCfg(flags))
191  return acc
MDT_Response_DigiTool
Definition: MDT_Response_DigiTool.h:26
python.MDT_DigitizationConfig.MDT_Response_DigiToolCfg
def MDT_Response_DigiToolCfg(flags, name="MDT_Response_DigiTool", **kwargs)
Definition: MDT_DigitizationConfig.py:48
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.MDT_DigitizationConfig.MDT_DigitizationBasicCfg
def MDT_DigitizationBasicCfg(flags, **kwargs)
Definition: MDT_DigitizationConfig.py:142
python.MDT_DigitizationConfig.MDT_OutputCfg
def MDT_OutputCfg(flags)
Definition: MDT_DigitizationConfig.py:126
python.MDT_DigitizationConfig.MDT_DigitizationToolCommonCfg
def MDT_DigitizationToolCommonCfg(flags, name="MdtDigitizationTool", **kwargs)
Definition: MDT_DigitizationConfig.py:57
python.MuonCablingConfig.MdtTwinTubeMapCondAlgCfg
def MdtTwinTubeMapCondAlgCfg(flags, name="MdtTwinTubeCondAlg", **kwargs)
Definition: MuonCablingConfig.py:150
python.TruthDigitizationOutputConfig.TruthDigitizationOutputCfg
def TruthDigitizationOutputCfg(flags)
Definition: TruthDigitizationOutputConfig.py:9
python.MDT_DigitizationConfig.RT_Relation_DB_DigiToolCfg
def RT_Relation_DB_DigiToolCfg(flags, name="RT_Relation_DB_DigiTool", **kwargs)
Definition: MDT_DigitizationConfig.py:41
python.MDT_DigitizationConfig.MDT_DigitizationToolCfg
def MDT_DigitizationToolCfg(flags, name="MdtDigitizationTool", **kwargs)
Definition: MDT_DigitizationConfig.py:96
python.MuonCondAlgConfig.MdtCondDbAlgCfg
def MdtCondDbAlgCfg(flags, **kwargs)
Definition: MuonCondAlgConfig.py:13
python.MuonCablingConfig.MDTCablingConfigCfg
def MDTCablingConfigCfg(flags, name="MuonMDT_CablingAlg", **kwargs)
Definition: MuonCablingConfig.py:100
SGInputLoaderConfig.SGInputLoaderCfg
def SGInputLoaderCfg(flags, Load=None, **kwargs)
Definition: SGInputLoaderConfig.py:7
python.MDT_DigitizationConfig.MDT_FirstXing
def MDT_FirstXing()
Definition: MDT_DigitizationConfig.py:19
AlignmentAlgsConfig.ActsGeometryContextAlgCfg
def ActsGeometryContextAlgCfg(flags, name="GeometryContextAlg", **kwargs)
Setup the Geometry context algorithm.
Definition: AlignmentAlgsConfig.py:125
python.PileUpToolsConfig.PileUpToolsCfg
def PileUpToolsCfg(flags, **kwargs)
Definition: PileUpToolsConfig.py:14
python.MDT_DigitizationConfig.MDT_DigitizationDigitToRDOCfg
def MDT_DigitizationDigitToRDOCfg(flags)
Definition: MDT_DigitizationConfig.py:186
python.MDT_DigitizationConfig.MDT_LastXing
def MDT_LastXing()
Definition: MDT_DigitizationConfig.py:23
python.MuonByteStreamCnvTestConfig.MdtDigitToMdtRDOCfg
def MdtDigitToMdtRDOCfg(flags, name="MdtDigitToMdtRDO", **kwargs)
Definition: MuonByteStreamCnvTestConfig.py:164
python.MuonGeometryConfig.MuonGeoModelCfg
def MuonGeoModelCfg(flags)
Definition: MuonGeometryConfig.py:28
python.MDT_DigitizationConfig.MDT_RangeCfg
def MDT_RangeCfg(flags, name="MDT_Range", **kwargs)
Definition: MDT_DigitizationConfig.py:28
python.PileUpMergeSvcConfig.PileUpXingFolderCfg
def PileUpXingFolderCfg(flags, name="PileUpXingFolder", **kwargs)
Definition: PileUpMergeSvcConfig.py:35
python.MDT_DigitizationConfig.MDT_DigitizationCfg
def MDT_DigitizationCfg(flags, **kwargs)
Definition: MDT_DigitizationConfig.py:179
python.MuonCalibrationConfig.MdtCalibDbAlgCfg
def MdtCalibDbAlgCfg(flags, name="MdtCalibDbAlg", **kwargs)
Definition: MuonCalibrationConfig.py:100
python.MDT_DigitizationConfig.MDT_OverlayDigitizationToolCfg
def MDT_OverlayDigitizationToolCfg(flags, name="Mdt_OverlayDigitizationTool", **kwargs)
Definition: MDT_DigitizationConfig.py:117
python.PileUpMergeSvcConfig.PileUpMergeSvcCfg
def PileUpMergeSvcCfg(flags, name="PileUpMergeSvc", Intervals=[], **kwargs)
Definition: PileUpMergeSvcConfig.py:10
python.MDT_DigitizationConfig.MDT_OverlayDigitizationBasicCfg
def MDT_OverlayDigitizationBasicCfg(flags, **kwargs)
Definition: MDT_DigitizationConfig.py:152
RngCompsConfig.AthRNGSvcCfg
def AthRNGSvcCfg(flags, name="AthRNGSvc")
Definition: RngCompsConfig.py:51