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_RawDataProviderToolMT(name = "RPC_RawDataProviderToolMT" + 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_RawDataProviderToolMT = CompFactory.Muon.MM_RawDataProviderToolMT
94 MuonMmRawDataProviderTool = Muon_MM_RawDataProviderToolMT(name = "MM_RawDataProviderToolMT"+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 ('RpcPadContainer','RPCPAD'),
141 ('TgcRdoContainer','TGCRDO')
142 ]
143 # Read MMRDO and sTGCRDO
144 if flags.Detector.GeometrysTGC or flags.Detector.GeometryMM:
145 rdoInputs += [
146 ('Muon::MM_RawDataContainer','MMRDO'),
147 ('Muon::STGC_RawDataContainer','sTGCRDO')
148 ]
149 if flags.Muon.enableNRPC:
150 rdoInputs += [
151 ('xAOD::NRPCRDOContainer' , 'NRPCRDO'),
152 ('xAOD::NRPCRDOAuxContainer', 'NRPCRDOAux.')
153 ]
154 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
155 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
156
157 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
158 acc.merge(MuonGeoModelCfg(flags))
159
160 from MuonConfig.MuonByteStreamCnvTestConfig import RpcRdoToRpcDigitCfg, TgcRdoToTgcDigitCfg, STGC_RdoToDigitCfg, MM_RdoToDigitCfg
161
162 acc.merge(RpcRdoToRpcDigitCfg(flags, RpcDigitContainer = "RPC_DIGITS_L1", RpcRdoContainer = RPCRdoName ))
163 acc.merge(TgcRdoToTgcDigitCfg(flags, TgcDigitContainer = "TGC_DIGITS_L1", TgcRdoContainer = TGCRdoName ))
164 if flags.Detector.GeometrysTGC:
165 acc.merge(STGC_RdoToDigitCfg(flags, sTgcRdoContainer = sTGCRdoName, sTgcDigitContainer = "sTGC_DIGITS_L1"))
166 if flags.Detector.GeometryMM:
167 acc.merge(MM_RdoToDigitCfg(flags, MmRdoContainer = MMRdoName, MmDigitContainer = "MM_DIGITS_L1" ))
168
169 return acc
170
172 acc = ComponentAccumulator()
173 if not flags.Detector.GeometrysTGC and not flags.Detector.GeometryMM:
174 return acc
175
176 if flags.Input.Format is Format.POOL and flags.Input.isMC:
177 rdoInputs = [
178 ('McEventCollection','TruthEvent'), # for MM trigger
179 ('TrackRecordCollection','MuonEntryLayer'), # for MM trigger
180 ('MuonSimDataCollection','sTGC_SDO') # for sTGC Pad trigger
181 ]
182 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
183 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
184
185 PadEmulatorTool = CompFactory.NSWL1.PadEmulatorTool("NSWL1__PadEmulatorTool", DoNtuple=flags.Trigger.L1MuonSim.WritesTGCBranches, IsMC = flags.Input.isMC, sTGC_DigitContainerName="sTGC_DIGITS_L1")
186 MMTriggerTool = CompFactory.NSWL1.MMTriggerTool("NSWL1__MMTriggerTool",DoNtuple=flags.Trigger.L1MuonSim.WriteMMBranches, IsMC = flags.Input.isMC, MmDigitContainer="MM_DIGITS_L1")
187 TriggerProcessorTool = CompFactory.NSWL1.TriggerProcessorTool("NSWL1__TriggerProcessorTool")
188
189 nswAlg = CompFactory.NSWL1.NSWL1Simulation("NSWL1Simulation",
190 DoNtuple = flags.Trigger.L1MuonSim.WriteNSWDebugNtuple,
191 DoMM = flags.Trigger.L1MuonSim.doMMTrigger,
192 DoMMDiamonds = flags.Trigger.L1MuonSim.doMMTrigger,
193 DosTGC = flags.Trigger.L1MuonSim.doPadTrigger or flags.Trigger.L1MuonSim.doStripTrigger,
194 DoPad = flags.Trigger.L1MuonSim.doPadTrigger,
195 PadEmulatorTool = PadEmulatorTool,
196 DoStrip = flags.Trigger.L1MuonSim.doStripTrigger,
197 MMTriggerTool = MMTriggerTool,
198 TriggerProcessorTool = TriggerProcessorTool,
199 NSWTrigRDOContainerName = "L1_NSWTrigContainer" )
200 acc.addEventAlgo(nswAlg)
201 return acc
202
204 acc = ComponentAccumulator()
205 rpcAlg = CompFactory.TrigT1RPC("TrigT1RPC",
206 Hardware = True,
207 DataDetail = False,
208 RPCbytestream = False,
209 RPCbytestreamFile = "",
210 RPCDigitContainer = "RPC_DIGITS_L1",
211 useRun3Config = True,
212 NOBXS=flags.Trigger.L1MuonSim.RPCNBX,
213 BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
214 acc.addEventAlgo(rpcAlg)
215 from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg
216 acc.merge( RPCCablingConfigCfg(flags) ) # trigger roads
217 return acc
218
220 acc = ComponentAccumulator()
221 tgcAlg = CompFactory.LVL1TGCTrigger.LVL1TGCTrigger("LVL1TGCTrigger",
222 InputData_perEvent = "TGC_DIGITS_L1",
223 InputRDO = "TGCRDO" if flags.Input.isMC else "TGCRDO_L1",
224 useRun3Config = True,
225 TileMuRcv_Input = "rerunTileMuRcvCnt",
226 TILEMU = True)
227 if (flags.Detector.GeometrysTGC or flags.Detector.GeometryMM):
228 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel.noFI._12.db"
229 tgcAlg.USENSW = True
230 tgcAlg.NSWSideInfo = "AC"
231 tgcAlg.NSWTrigger_Input = "L1_NSWTrigContainer"
232 tgcAlg.FORCENSWCOIN = not flags.Trigger.L1MuonSim.NSWVetoMode
233 tgcAlg.USEBIS78 = flags.Trigger.L1MuonSim.doBIS78
234 else:
235 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel._12.db"
236
237 if flags.Input.Format is Format.BS:
238 from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
239 readBSConfig = ByteStreamReadCfg(flags, ['ByteStreamMetadataContainer/ByteStreamMetadata'])
240 acc.merge(readBSConfig)
241 else:
242 tgcAlg.ByteStreamMetadataRHKey = ''
243 acc.addEventAlgo(tgcAlg)
244
245 from PathResolver import PathResolver
246 bwCW_Run3_filePath=PathResolver.FindCalibFile("TrigT1TGC_CW/BW/CW_BW_Run3.v01.db")
247 acc.merge(addFolders(flags, '<db>sqlite://;schema={0};dbname=OFLP200</db> /TGC/TRIGGER/CW_BW_RUN3'.format(bwCW_Run3_filePath),
248 tag='TgcTriggerCwBwRun3-01',
249 className='CondAttrListCollection'))
250 acc.addCondAlgo(CompFactory.TGCTriggerCondAlg())
251 from MuonConfig.MuonCablingConfig import TGCCablingConfigCfg
252 acc.merge( TGCCablingConfigCfg(flags) )
253 return acc
254
255def MuctpiConfig(flags):
256 acc = ComponentAccumulator()
257 rpcRecRoiTool = CompFactory.LVL1.TrigT1RPCRecRoiTool("TrigT1RPCRecRoiTool", UseRun3Config=True)
258 tgcRecRoiTool = CompFactory.LVL1.TrigT1TGCRecRoiTool("TrigT1TGCRecRoiTool", UseRun3Config=True)
259 trigThresholdDecTool = CompFactory.LVL1.TrigThresholdDecisionTool(name="TrigThresholdDecisionTool",
260 RPCRecRoiTool = rpcRecRoiTool,
261 TGCRecRoiTool = tgcRecRoiTool)
262 muctpiTool = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthTool(name="MUCTPI_AthTool",
263 MuCTPICTPLocation = 'L1MuCTPItoCTPLocation',
264 OverlapStrategyName = flags.Trigger.MUCTPI.OverlapStrategy,
265 LUTXMLFile = flags.Trigger.MUCTPI.LUTXMLFile,
266 BarrelRoIFile = flags.Trigger.MUCTPI.BarrelRoIFile,
267 EndcapForwardRoIFile = flags.Trigger.MUCTPI.EndcapForwardRoIFile,
268 Side0LUTFile = flags.Trigger.MUCTPI.Side0LUTFile,
269 Side1LUTFile = flags.Trigger.MUCTPI.Side1LUTFile,
270 InputSource = 'DIGITIZATION',
271 RPCRecRoiTool = rpcRecRoiTool,
272 TGCRecRoiTool = tgcRecRoiTool,
273 TrigThresholdDecisionTool = trigThresholdDecTool)
274 muctpiAlg = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthAlg(name="MUCTPI_AthAlg",
275 MUCTPI_AthTool = muctpiTool)
276 acc.addEventAlgo(muctpiAlg)
277 from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
278 acc.merge(L1ConfigSvcCfg(flags))
279 return acc
280
281
283 acc = ComponentAccumulator()
284
285 if flags.Trigger.L0MuonSim.doEmulation:
286 from L0MuonEmulation.L0MuonSmearingConfig import L0MuonSmearingCfg
287 acc.merge(L0MuonSmearingCfg(flags)) # L0MuonRoI truth emulation
288 return acc
289
290 # otherwise, run-3 step will run.
291 acc.merge(MuonBytestream2RdoConfig(flags)) # data prep for muon bytestream data
292 acc.merge(MuonRdo2DigitConfig(flags)) # input for rpc/tgc trigger simulation
293 acc.merge(RPCTriggerConfig(flags)) # rpc trigger simulation, including bis78 to prepare for bis78-tgc coincidence
294 acc.merge(TMDBConfig(flags)) # for tmdb decision to prepare for tile-muon coincidence
295 acc.merge(NSWTriggerConfig(flags)) # nsw trigger simulation to prepare input for nsw-tgc coincidence
296 acc.merge(TGCTriggerConfig(flags)) # tgc trigger simulation
297 acc.merge(MuctpiConfig(flags)) # muctpi simulation
298
299 return acc
300
301if __name__ == "__main__":
302 import sys
303 from AthenaConfiguration.AllConfigFlags import initConfigFlags
304 flags = initConfigFlags()
305 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']
306 flags.Exec.MaxEvents = 5
307 flags.Concurrency.NumThreads = 1
308 flags.Trigger.triggerMenuSetup = 'MC_pp_run4_v1'
309 flags.Trigger.enableL0Muon = True
310 flags.Trigger.L0MuonSim.doEmulation = True
311 flags.fillFromArgs()
312 flags.lock()
313
314 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
315 acc = MainServicesCfg(flags)
316
317 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
318 acc.merge(PoolReadCfg(flags))
319
320 from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu
321 generateL1Menu(flags)
322
323 acc.merge(L0MuonSimulationCfg(flags))
324
325 acc.printConfig(withDetails=True, summariseProps=True, printDefaults=True)
326 sys.exit(acc.run().isFailure())
static std::string FindCalibFile(const std::string &logical_file_name)
MuonRdoToMuonDigitToolCfg(flags, name="MuonRdoToMuonDigitTool", **kwargs)