ATLAS Offline Software
Loading...
Searching...
No Matches
L0MuonSimulationConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthenaConfiguration.Enums import Format
6from IOVDbSvc.IOVDbSvcConfig import addFolders
7
8def TMDBConfig(flags):
9 acc = ComponentAccumulator()
10
11 # Read MuRcvRawChCnt from the input file (for POOL directly, for BS via converter)
12 if flags.Input.Format is Format.POOL:
13 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
14 acc.merge(SGInputLoaderCfg(flags, ["TileRawChannelContainer/MuRcvRawChCnt"]))
15 else:
16 from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
17 acc.merge(ByteStreamReadCfg(flags, ["TileRawChannelContainer/MuRcvRawChCnt"]))
18
19 from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
20 acc.merge( TileInfoLoaderCfg(flags) )
21
22 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
23 acc.merge(TileCablingSvcCfg(flags))
24
25 from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
26 acc.merge( TileEMScaleCondAlgCfg(flags) )
27
28 tmdbAlg = CompFactory.TileMuonReceiverDecision('TileMuonReceiverDecision'
29 , TileRawChannelContainer = "MuRcvRawChCnt" # input
30 , TileMuonReceiverContainer = "rerunTileMuRcvCnt" # output
31 , ManualRunPeriod = 2 # forcing Run 2 format (=2) for now, until TGC implements Run 3 format (=3)
32 # run 2 thresholds
33 , MuonReceiverEneThreshCellD6Low = 500
34 , MuonReceiverEneThreshCellD6andD5Low = 500
35 , MuonReceiverEneThreshCellD6High = 600
36 , MuonReceiverEneThreshCellD6andD5High = 600
37 # run 3 thresholds
38 , MuonReceiverEneThreshCellD5 = 500
39 , MuonReceiverEneThreshCellD6 = 500
40 , MuonReceiverEneThreshCellD5andD6 = 500)
41 acc.addEventAlgo(tmdbAlg)
42 return acc
43
45 acc = ComponentAccumulator()
46 if flags.Input.isMC:
47 return acc
48
49 postFix = "_L1MuonSim"
50 from MuonConfig.MuonBytestreamDecodeConfig import MuonCacheNames
51 cacheCreator = CompFactory.MuonCacheCreator(RpcCacheKey = MuonCacheNames.RpcCache,
52 TgcCacheKey = MuonCacheNames.TgcCache,
53 MdtCsmCacheKey = MuonCacheNames.MdtCsmCache,
54 CscCacheKey = (MuonCacheNames.CscCache if flags.Detector.GeometryCSC else ""))
55 acc.addEventAlgo(cacheCreator)
56 # for RPC
57 RPCRodDecoder = CompFactory.Muon.RpcROD_Decoder(name = "RpcROD_Decoder" + postFix, NOBXS=flags.Trigger.L1MuonSim.RPCNBX)
58 MuonRpcRawDataProviderTool = CompFactory.Muon.RPC_RawDataProviderTool(name = "RPC_RawDataProviderTool" + postFix,
59 RpcContainerCacheKey = MuonCacheNames.RpcCache,
60 WriteOutRpcSectorLogic = False,
61 Decoder = RPCRodDecoder,
62 RdoLocation = "RPCPAD_L1" )
63 RpcRawDataProvider = CompFactory.Muon.RpcRawDataProvider(name = "RpcRawDataProvider" + postFix,
64 ProviderTool = MuonRpcRawDataProviderTool)
65 acc.addEventAlgo(RpcRawDataProvider)
66 # for TGC
67 TGCRodDecoder = CompFactory.Muon.TGC_RodDecoderReadout(name = "TGC_RodDecoderReadout" + postFix)
68 MuonTgcRawDataProviderTool = CompFactory.Muon.TGC_RawDataProviderToolMT(name = "TGC_RawDataProviderToolMT" + postFix,
69 TgcContainerCacheKey = MuonCacheNames.TgcCache,
70 Decoder = TGCRodDecoder,
71 RdoLocation = "TGCRDO_L1")
72 TgcRawDataProvider = CompFactory.Muon.MuonRawDataProvider(name = f"TgcRawDataProvider{postFix}",
73 ProviderTool = MuonTgcRawDataProviderTool,
74 UseHashIds = True,
75 DecodePerRoI = True)
76 acc.addEventAlgo(TgcRawDataProvider)
77 # for sTGC
78 if flags.Detector.GeometrysTGC:
79 from MuonConfig.MuonBytestreamDecodeConfig import sTgcRODDecoderCfg
80 MuonsTgcRawDataProviderTool = CompFactory.Muon.STGC_RawDataProviderTool(name = "STGC_RawDataProviderToolMT"+postFix,
81 Decoder = acc.popToolsAndMerge(sTgcRODDecoderCfg(flags,
82 name = "sTgcROD_Decoder"+postFix)),
83 RdoLocation = "sTGCRDO_L1")
84 sTgcRawDataProvider = CompFactory.Muon.MuonRawDataProvider(name = f"sTgcRawDataProvider{postFix}",
85 ProviderTool = MuonsTgcRawDataProviderTool,
86 UseHashIds = False,
87 DecodePerRoI = False)
88 acc.addEventAlgo(sTgcRawDataProvider)
89
90 # for MM
91 if flags.Detector.GeometryMM:
92 from MuonConfig.MuonBytestreamDecodeConfig import MmRDODDecoderCfg
93 Muon_MM_RawDataProviderTool = CompFactory.Muon.MM_RawDataProviderTool
94 MuonMmRawDataProviderTool = Muon_MM_RawDataProviderTool(name = "MM_RawDataProviderTool"+postFix,
95 Decoder = acc.popToolsAndMerge(MmRDODDecoderCfg(flags,
96 name="MM_RODDecoder"+postFix)),
97 RdoLocation = "MMRDO_L1")
98 MmRawDataProvider = CompFactory.Muon.MuonRawDataProvider(name = f"MmRawDataProvider{postFix}",
99 ProviderTool = MuonMmRawDataProviderTool,
100 UseHashIds = False,
101 DecodePerRoI = False)
102 acc.addEventAlgo(MmRawDataProvider)
103
104 return acc
105
106
107def MuonRdoToMuonDigitToolCfg(flags, name="MuonRdoToMuonDigitTool", **kwargs ):
108 result = ComponentAccumulator()
109 kwargs.setdefault("DecodeSTGC_RDO", flags.Detector.GeometrysTGC)
110 kwargs.setdefault("DecodeMM_RDO", flags.Detector.GeometryMM)
111 kwargs.setdefault("DecodeNrpcRDO", flags.Muon.enableNRPC)
112 from MuonConfig.MuonByteStreamCnvTestConfig import STgcRdoDecoderCfg, MMRdoDecoderCfg, MdtRdoDecoderCfg
113 kwargs.setdefault( "stgcRdoDecoderTool", result.popToolsAndMerge(STgcRdoDecoderCfg(flags))
114 if flags.Detector.GeometrysTGC else "" )
115 kwargs.setdefault("mmRdoDecoderTool", result.popToolsAndMerge(MMRdoDecoderCfg(flags))
116 if flags.Detector.GeometryMM else "" )
117 kwargs.setdefault("mdtRdoDecoderTool", result.popToolsAndMerge(MdtRdoDecoderCfg(flags)))
118 #Set N BCs and central BC consistently with RPC readout settings
119 rpcrdo_decode = CompFactory.Muon.RpcRDO_Decoder("RpcRDO_Decoder", BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
120 kwargs.setdefault("rpcRdoDecoderTool", rpcrdo_decode)
121
122 the_tool = CompFactory.MuonRdoToMuonDigitTool (name, **kwargs)
123 result.setPrivateTools(the_tool)
124 return result
125
127 acc = ComponentAccumulator()
128
129 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
130 acc.merge( AtlasFieldCacheCondAlgCfg(flags) )
131 # Read RPCPAD and TGCRDO from the input POOL file (for BS it comes from [Rpc|Tgc]RawDataProvider)
132 suffix = "" if flags.Input.Format is Format.POOL else "_L1"
133 RPCRdoName = "RPCPAD"+suffix
134 TGCRdoName = "TGCRDO"+suffix
135 MMRdoName = "MMRDO"+suffix
136 sTGCRdoName = "sTGCRDO"+suffix
137
138 if flags.Input.Format is Format.POOL:
139 rdoInputs = [
140 ('TgcRdoContainer','TGCRDO')
141 ]
142 if "RPCPAD" in flags.Input.Collections:
143 rdoInputs += [
144 ('RpcPadContainer','RPCPAD')
145 ]
146 # Read MMRDO and sTGCRDO
147 if flags.Detector.GeometrysTGC or flags.Detector.GeometryMM:
148 rdoInputs += [
149 ('Muon::MM_RawDataContainer','MMRDO'),
150 ('Muon::STGC_RawDataContainer','sTGCRDO')
151 ]
152 if flags.Muon.enableNRPC:
153 rdoInputs += [
154 ('xAOD::NRPCRDOContainer' , 'NRPCRDO'),
155 ('xAOD::NRPCRDOAuxContainer', 'NRPCRDOAux.')
156 ]
157 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
158 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
159
160 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
161 acc.merge(MuonGeoModelCfg(flags))
162
163 from MuonConfig.MuonByteStreamCnvTestConfig import RpcRdoToRpcDigitCfg, TgcRdoToTgcDigitCfg, STGC_RdoToDigitCfg, MM_RdoToDigitCfg
164
165 acc.merge(RpcRdoToRpcDigitCfg(flags, RpcDigitContainer = "RPC_DIGITS_L1", RpcRdoContainer = RPCRdoName ))
166 acc.merge(TgcRdoToTgcDigitCfg(flags, TgcDigitContainer = "TGC_DIGITS_L1", TgcRdoContainer = TGCRdoName ))
167 if flags.Detector.GeometrysTGC:
168 acc.merge(STGC_RdoToDigitCfg(flags, sTgcRdoContainer = sTGCRdoName, sTgcDigitContainer = "sTGC_DIGITS_L1"))
169 if flags.Detector.GeometryMM:
170 acc.merge(MM_RdoToDigitCfg(flags, MmRdoContainer = MMRdoName, MmDigitContainer = "MM_DIGITS_L1" ))
171
172 return acc
173
175 acc = ComponentAccumulator()
176 if not flags.Detector.GeometrysTGC and not flags.Detector.GeometryMM:
177 return acc
178
179 if flags.Input.Format is Format.POOL and flags.Input.isMC:
180 rdoInputs = [
181 ('McEventCollection','TruthEvent'), # for MM trigger
182 ('TrackRecordCollection','MuonEntryLayer'), # for MM trigger
183 ]
184 if not flags.Muon.usePhaseIIGeoSetup:
185 rdoInputs += [
186 ('MuonSimDataCollection','sTGC_SDO') # for sTGC Pad trigger
187 ]
188 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
189 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
190
191 PadEmulatorTool = CompFactory.NSWL1.PadEmulatorTool("NSWL1__PadEmulatorTool", DoNtuple=flags.Trigger.L1MuonSim.WritesTGCBranches, IsMC = flags.Input.isMC, sTGC_DigitContainerName="sTGC_DIGITS_L1")
192 MMTriggerTool = CompFactory.NSWL1.MMTriggerTool("NSWL1__MMTriggerTool",DoNtuple=flags.Trigger.L1MuonSim.WriteMMBranches, IsMC = flags.Input.isMC, MmDigitContainer="MM_DIGITS_L1")
193 TriggerProcessorTool = CompFactory.NSWL1.TriggerProcessorTool("NSWL1__TriggerProcessorTool")
194
195 nswAlg = CompFactory.NSWL1.NSWL1Simulation("NSWL1Simulation",
196 DoNtuple = flags.Trigger.L1MuonSim.WriteNSWDebugNtuple,
197 DoMM = flags.Trigger.L1MuonSim.doMMTrigger,
198 DoMMDiamonds = flags.Trigger.L1MuonSim.doMMTrigger,
199 DosTGC = flags.Trigger.L1MuonSim.doPadTrigger or flags.Trigger.L1MuonSim.doStripTrigger,
200 DoPad = flags.Trigger.L1MuonSim.doPadTrigger,
201 PadEmulatorTool = PadEmulatorTool,
202 DoStrip = flags.Trigger.L1MuonSim.doStripTrigger,
203 MMTriggerTool = MMTriggerTool,
204 TriggerProcessorTool = TriggerProcessorTool,
205 NSWTrigRDOContainerName = "L1_NSWTrigContainer" )
206 acc.addEventAlgo(nswAlg)
207 return acc
208
210 acc = ComponentAccumulator()
211 rpcAlg = CompFactory.TrigT1RPC("TrigT1RPC",
212 Hardware = True,
213 DataDetail = False,
214 RPCbytestream = False,
215 RPCbytestreamFile = "",
216 RPCDigitContainer = "RPC_DIGITS_L1",
217 useRun3Config = True,
218 NOBXS=flags.Trigger.L1MuonSim.RPCNBX,
219 BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
220 acc.addEventAlgo(rpcAlg)
221 from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg
222 acc.merge( RPCCablingConfigCfg(flags) ) # trigger roads
223 return acc
224
226 acc = ComponentAccumulator()
227 tgcAlg = CompFactory.LVL1TGCTrigger.LVL1TGCTrigger("LVL1TGCTrigger",
228 InputData_perEvent = "TGC_DIGITS_L1",
229 InputRDO = "TGCRDO" if flags.Input.isMC else "TGCRDO_L1",
230 useRun3Config = True,
231 TileMuRcv_Input = "rerunTileMuRcvCnt",
232 TILEMU = True)
233 if (flags.Detector.GeometrysTGC or flags.Detector.GeometryMM):
234 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel.noFI._12.db"
235 tgcAlg.USENSW = True
236 tgcAlg.NSWSideInfo = "AC"
237 tgcAlg.NSWTrigger_Input = "L1_NSWTrigContainer"
238 tgcAlg.FORCENSWCOIN = not flags.Trigger.L1MuonSim.NSWVetoMode
239 tgcAlg.USEBIS78 = flags.Trigger.L1MuonSim.doBIS78
240 else:
241 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel._12.db"
242
243 if flags.Input.Format is Format.BS:
244 from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
245 readBSConfig = ByteStreamReadCfg(flags, ['ByteStreamMetadataContainer/ByteStreamMetadata'])
246 acc.merge(readBSConfig)
247 else:
248 tgcAlg.ByteStreamMetadataRHKey = ''
249 acc.addEventAlgo(tgcAlg)
250
251 from PathResolver import PathResolver
252 bwCW_Run3_filePath=PathResolver.FindCalibFile("TrigT1TGC_CW/BW/CW_BW_Run3.v01.db")
253 acc.merge(addFolders(flags, '<db>sqlite://;schema={0};dbname=OFLP200</db> /TGC/TRIGGER/CW_BW_RUN3'.format(bwCW_Run3_filePath),
254 tag='TgcTriggerCwBwRun3-01',
255 className='CondAttrListCollection'))
256 acc.addCondAlgo(CompFactory.TGCTriggerCondAlg())
257 from MuonConfig.MuonCablingConfig import TGCCablingConfigCfg
258 acc.merge( TGCCablingConfigCfg(flags) )
259 return acc
260
261def MuctpiConfig(flags):
262 acc = ComponentAccumulator()
263 rpcRecRoiTool = CompFactory.LVL1.TrigT1RPCRecRoiTool("TrigT1RPCRecRoiTool", UseRun3Config=True)
264 tgcRecRoiTool = CompFactory.LVL1.TrigT1TGCRecRoiTool("TrigT1TGCRecRoiTool", UseRun3Config=True)
265 trigThresholdDecTool = CompFactory.LVL1.TrigThresholdDecisionTool(name="TrigThresholdDecisionTool",
266 RPCRecRoiTool = rpcRecRoiTool,
267 TGCRecRoiTool = tgcRecRoiTool)
268 muctpiTool = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthTool(name="MUCTPI_AthTool",
269 MuCTPICTPLocation = 'L1MuCTPItoCTPLocation',
270 OverlapStrategyName = flags.Trigger.MUCTPI.OverlapStrategy,
271 LUTXMLFile = flags.Trigger.MUCTPI.LUTXMLFile,
272 BarrelRoIFile = flags.Trigger.MUCTPI.BarrelRoIFile,
273 EndcapForwardRoIFile = flags.Trigger.MUCTPI.EndcapForwardRoIFile,
274 Side0LUTFile = flags.Trigger.MUCTPI.Side0LUTFile,
275 Side1LUTFile = flags.Trigger.MUCTPI.Side1LUTFile,
276 InputSource = 'DIGITIZATION',
277 RPCRecRoiTool = rpcRecRoiTool,
278 TGCRecRoiTool = tgcRecRoiTool,
279 TrigThresholdDecisionTool = trigThresholdDecTool)
280 muctpiAlg = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthAlg(name="MUCTPI_AthAlg",
281 MUCTPI_AthTool = muctpiTool)
282 acc.addEventAlgo(muctpiAlg)
283 from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
284 acc.merge(L1ConfigSvcCfg(flags))
285 return acc
286
287
289 acc = ComponentAccumulator()
290
291 if flags.Trigger.L0MuonSim.doEmulation:
292 from L0MuonEmulation.L0MuonSmearingConfig import L0MuonSmearingCfg
293 acc.merge(L0MuonSmearingCfg(flags)) # L0MuonRoI truth emulation
294 return acc
295
296 # otherwise, run-3 step will run.
297 acc.merge(MuonBytestream2RdoConfig(flags)) # data prep for muon bytestream data
298 acc.merge(MuonRdo2DigitConfig(flags)) # input for rpc/tgc trigger simulation
299 acc.merge(RPCTriggerConfig(flags)) # rpc trigger simulation, including bis78 to prepare for bis78-tgc coincidence
300 acc.merge(TMDBConfig(flags)) # for tmdb decision to prepare for tile-muon coincidence
301 acc.merge(NSWTriggerConfig(flags)) # nsw trigger simulation to prepare input for nsw-tgc coincidence
302 acc.merge(TGCTriggerConfig(flags)) # tgc trigger simulation
303 acc.merge(MuctpiConfig(flags)) # muctpi simulation
304
305 return acc
306
307if __name__ == "__main__":
308 import sys
309 from AthenaConfiguration.AllConfigFlags import initConfigFlags
310 flags = initConfigFlags()
311 flags.Input.Files = ['/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/PhaseIIUpgrade/RDO/ATLAS-P2-RUN4-03-00-00/mc21_14TeV.900498.PG_single_muonpm_Pt100_etaFlatnp0_43.recon.RDO.e8481_s4149_r14697/RDO.33675668._000016.pool.root.1']
312 flags.Exec.MaxEvents = 5
313 flags.Concurrency.NumThreads = 1
314 flags.Trigger.triggerMenuSetup = 'MC_pp_run4_v1'
315 flags.Trigger.enableL0Muon = True
316 flags.Trigger.L0MuonSim.doEmulation = True
317 flags.fillFromArgs()
318 flags.lock()
319
320 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
321 acc = MainServicesCfg(flags)
322
323 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
324 acc.merge(PoolReadCfg(flags))
325
326 from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu
327 generateL1Menu(flags)
328
329 acc.merge(L0MuonSimulationCfg(flags))
330
331 acc.printConfig(withDetails=True, summariseProps=True, printDefaults=True)
332 sys.exit(acc.run().isFailure())
static std::string FindCalibFile(const std::string &logical_file_name)
MuonRdoToMuonDigitToolCfg(flags, name="MuonRdoToMuonDigitTool", **kwargs)