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.TgcRawDataProvider(name = "TgcRawDataProvider" + postFix,
73 ProviderTool = MuonTgcRawDataProviderTool)
74 acc.addEventAlgo(TgcRawDataProvider)
75 # for sTGC
76 if flags.Detector.GeometrysTGC:
77 Muon__STGC_RawDataProviderToolMT=CompFactory.Muon.STGC_RawDataProviderToolMT
78 from MuonConfig.MuonBytestreamDecodeConfig import sTgcRODDecoderCfg
79 MuonsTgcRawDataProviderTool = Muon__STGC_RawDataProviderToolMT(name = "STGC_RawDataProviderToolMT"+postFix,
80 Decoder = acc.popToolsAndMerge(sTgcRODDecoderCfg(flags,
81 name = "sTgcROD_Decoder"+postFix)),
82 RdoLocation = "sTGCRDO_L1")
83 Muon__sTgcRawDataProvider=CompFactory.Muon.sTgcRawDataProvider
84 sTgcRawDataProvider = Muon__sTgcRawDataProvider(name = "sTgcRawDataProvider"+postFix,
85 ProviderTool = MuonsTgcRawDataProviderTool )
86 acc.addEventAlgo(sTgcRawDataProvider)
87
88 # for MM
89 if flags.Detector.GeometryMM:
90 from MuonConfig.MuonBytestreamDecodeConfig import MmRDODDecoderCfg
91 Muon_MM_RawDataProviderToolMT = CompFactory.Muon.MM_RawDataProviderToolMT
92 MuonMmRawDataProviderTool = Muon_MM_RawDataProviderToolMT(name = "MM_RawDataProviderToolMT"+postFix,
93 Decoder = acc.popToolsAndMerge(MmRDODDecoderCfg(flags,
94 name="MM_RODDecoder"+postFix)),
95 RdoLocation = "MMRDO_L1")
96 Muon__MmRawDataProvider = CompFactory.Muon.MM_RawDataProvider
97 MmRawDataProvider = Muon__MmRawDataProvider(name = "MmRawDataProvider"+postFix, ProviderTool = MuonMmRawDataProviderTool )
98 acc.addEventAlgo(MmRawDataProvider)
99
100 return acc
101
102
103def MuonRdoToMuonDigitToolCfg(flags, name="MuonRdoToMuonDigitTool", **kwargs ):
104 result = ComponentAccumulator()
105 kwargs.setdefault("DecodeSTGC_RDO", flags.Detector.GeometrysTGC)
106 kwargs.setdefault("DecodeMM_RDO", flags.Detector.GeometryMM)
107 kwargs.setdefault("DecodeNrpcRDO", flags.Muon.enableNRPC)
108 from MuonConfig.MuonByteStreamCnvTestConfig import STgcRdoDecoderCfg, MMRdoDecoderCfg, MdtRdoDecoderCfg
109 kwargs.setdefault( "stgcRdoDecoderTool", result.popToolsAndMerge(STgcRdoDecoderCfg(flags))
110 if flags.Detector.GeometrysTGC else "" )
111 kwargs.setdefault("mmRdoDecoderTool", result.popToolsAndMerge(MMRdoDecoderCfg(flags))
112 if flags.Detector.GeometryMM else "" )
113 kwargs.setdefault("mdtRdoDecoderTool", result.popToolsAndMerge(MdtRdoDecoderCfg(flags)))
114 #Set N BCs and central BC consistently with RPC readout settings
115 rpcrdo_decode = CompFactory.Muon.RpcRDO_Decoder("RpcRDO_Decoder", BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
116 kwargs.setdefault("rpcRdoDecoderTool", rpcrdo_decode)
117
118 the_tool = CompFactory.MuonRdoToMuonDigitTool (name, **kwargs)
119 result.setPrivateTools(the_tool)
120 return result
121
123 acc = ComponentAccumulator()
124
125 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
126 acc.merge( AtlasFieldCacheCondAlgCfg(flags) )
127 # Read RPCPAD and TGCRDO from the input POOL file (for BS it comes from [Rpc|Tgc]RawDataProvider)
128 suffix = "" if flags.Input.Format is Format.POOL else "_L1"
129 RPCRdoName = "RPCPAD"+suffix
130 TGCRdoName = "TGCRDO"+suffix
131 MMRdoName = "MMRDO"+suffix
132 sTGCRdoName = "sTGCRDO"+suffix
133
134 if flags.Input.Format is Format.POOL:
135 rdoInputs = [
136 ('RpcPadContainer','RPCPAD'),
137 ('TgcRdoContainer','TGCRDO')
138 ]
139 # Read MMRDO and sTGCRDO
140 if flags.Detector.GeometrysTGC or flags.Detector.GeometryMM:
141 rdoInputs += [
142 ('Muon::MM_RawDataContainer','MMRDO'),
143 ('Muon::STGC_RawDataContainer','sTGCRDO')
144 ]
145 if flags.Muon.enableNRPC:
146 rdoInputs += [
147 ('xAOD::NRPCRDOContainer' , 'NRPCRDO'),
148 ('xAOD::NRPCRDOAuxContainer', 'NRPCRDOAux.')
149 ]
150 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
151 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
152
153 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
154 acc.merge(MuonGeoModelCfg(flags))
155
156 from MuonConfig.MuonByteStreamCnvTestConfig import RpcRdoToRpcDigitCfg, TgcRdoToTgcDigitCfg, STGC_RdoToDigitCfg, MM_RdoToDigitCfg
157
158 acc.merge(RpcRdoToRpcDigitCfg(flags, RpcDigitContainer = "RPC_DIGITS_L1", RpcRdoContainer = RPCRdoName ))
159 acc.merge(TgcRdoToTgcDigitCfg(flags, TgcDigitContainer = "TGC_DIGITS_L1", TgcRdoContainer = TGCRdoName ))
160 if flags.Detector.GeometrysTGC:
161 acc.merge(STGC_RdoToDigitCfg(flags, sTgcRdoContainer = sTGCRdoName, sTgcDigitContainer = "sTGC_DIGITS_L1"))
162 if flags.Detector.GeometryMM:
163 acc.merge(MM_RdoToDigitCfg(flags, MmRdoContainer = MMRdoName, MmDigitContainer = "MM_DIGITS_L1" ))
164
165 return acc
166
168 acc = ComponentAccumulator()
169 if not flags.Detector.GeometrysTGC and not flags.Detector.GeometryMM:
170 return acc
171
172 if flags.Input.Format is Format.POOL and flags.Input.isMC:
173 rdoInputs = [
174 ('McEventCollection','TruthEvent'), # for MM trigger
175 ('TrackRecordCollection','MuonEntryLayer'), # for MM trigger
176 ('MuonSimDataCollection','sTGC_SDO') # for sTGC Pad trigger
177 ]
178 from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
179 acc.merge(SGInputLoaderCfg(flags, Load=rdoInputs))
180
181 PadEmulatorTool = CompFactory.NSWL1.PadEmulatorTool("NSWL1__PadEmulatorTool", DoNtuple=flags.Trigger.L1MuonSim.WritesTGCBranches, IsMC = flags.Input.isMC, sTGC_DigitContainerName="sTGC_DIGITS_L1")
182 MMTriggerTool = CompFactory.NSWL1.MMTriggerTool("NSWL1__MMTriggerTool",DoNtuple=flags.Trigger.L1MuonSim.WriteMMBranches, IsMC = flags.Input.isMC, MmDigitContainer="MM_DIGITS_L1")
183 TriggerProcessorTool = CompFactory.NSWL1.TriggerProcessorTool("NSWL1__TriggerProcessorTool")
184
185 nswAlg = CompFactory.NSWL1.NSWL1Simulation("NSWL1Simulation",
186 DoNtuple = flags.Trigger.L1MuonSim.WriteNSWDebugNtuple,
187 DoMM = flags.Trigger.L1MuonSim.doMMTrigger,
188 DoMMDiamonds = flags.Trigger.L1MuonSim.doMMTrigger,
189 DosTGC = flags.Trigger.L1MuonSim.doPadTrigger or flags.Trigger.L1MuonSim.doStripTrigger,
190 DoPad = flags.Trigger.L1MuonSim.doPadTrigger,
191 PadEmulatorTool = PadEmulatorTool,
192 DoStrip = flags.Trigger.L1MuonSim.doStripTrigger,
193 MMTriggerTool = MMTriggerTool,
194 TriggerProcessorTool = TriggerProcessorTool,
195 NSWTrigRDOContainerName = "L1_NSWTrigContainer" )
196 acc.addEventAlgo(nswAlg)
197 return acc
198
200 acc = ComponentAccumulator()
201 rpcAlg = CompFactory.TrigT1RPC("TrigT1RPC",
202 Hardware = True,
203 DataDetail = False,
204 RPCbytestream = False,
205 RPCbytestreamFile = "",
206 RPCDigitContainer = "RPC_DIGITS_L1",
207 useRun3Config = True,
208 NOBXS=flags.Trigger.L1MuonSim.RPCNBX,
209 BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
210 acc.addEventAlgo(rpcAlg)
211 from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg
212 acc.merge( RPCCablingConfigCfg(flags) ) # trigger roads
213 return acc
214
216 acc = ComponentAccumulator()
217 tgcAlg = CompFactory.LVL1TGCTrigger.LVL1TGCTrigger("LVL1TGCTrigger",
218 InputData_perEvent = "TGC_DIGITS_L1",
219 InputRDO = "TGCRDO" if flags.Input.isMC else "TGCRDO_L1",
220 useRun3Config = True,
221 TileMuRcv_Input = "rerunTileMuRcvCnt",
222 TILEMU = True)
223 if (flags.Detector.GeometrysTGC or flags.Detector.GeometryMM):
224 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel.noFI._12.db"
225 tgcAlg.USENSW = True
226 tgcAlg.NSWSideInfo = "AC"
227 tgcAlg.NSWTrigger_Input = "L1_NSWTrigContainer"
228 tgcAlg.FORCENSWCOIN = not flags.Trigger.L1MuonSim.NSWVetoMode
229 tgcAlg.USEBIS78 = flags.Trigger.L1MuonSim.doBIS78
230 else:
231 tgcAlg.MaskFileName12 = "TrigT1TGCMaskedChannel._12.db"
232
233 if flags.Input.Format is Format.BS:
234 from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
235 readBSConfig = ByteStreamReadCfg(flags, ['ByteStreamMetadataContainer/ByteStreamMetadata'])
236 acc.merge(readBSConfig)
237 else:
238 tgcAlg.ByteStreamMetadataRHKey = ''
239 acc.addEventAlgo(tgcAlg)
240
241 from PathResolver import PathResolver
242 bwCW_Run3_filePath=PathResolver.FindCalibFile("TrigT1TGC_CW/BW/CW_BW_Run3.v01.db")
243 acc.merge(addFolders(flags, '<db>sqlite://;schema={0};dbname=OFLP200</db> /TGC/TRIGGER/CW_BW_RUN3'.format(bwCW_Run3_filePath),
244 tag='TgcTriggerCwBwRun3-01',
245 className='CondAttrListCollection'))
246 acc.addCondAlgo(CompFactory.TGCTriggerCondAlg())
247 from MuonConfig.MuonCablingConfig import TGCCablingConfigCfg
248 acc.merge( TGCCablingConfigCfg(flags) )
249 return acc
250
251def MuctpiConfig(flags):
252 acc = ComponentAccumulator()
253 rpcRecRoiTool = CompFactory.LVL1.TrigT1RPCRecRoiTool("TrigT1RPCRecRoiTool", UseRun3Config=True)
254 tgcRecRoiTool = CompFactory.LVL1.TrigT1TGCRecRoiTool("TrigT1TGCRecRoiTool", UseRun3Config=True)
255 trigThresholdDecTool = CompFactory.LVL1.TrigThresholdDecisionTool(name="TrigThresholdDecisionTool",
256 RPCRecRoiTool = rpcRecRoiTool,
257 TGCRecRoiTool = tgcRecRoiTool)
258 muctpiTool = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthTool(name="MUCTPI_AthTool",
259 MuCTPICTPLocation = 'L1MuCTPItoCTPLocation',
260 OverlapStrategyName = flags.Trigger.MUCTPI.OverlapStrategy,
261 LUTXMLFile = flags.Trigger.MUCTPI.LUTXMLFile,
262 BarrelRoIFile = flags.Trigger.MUCTPI.BarrelRoIFile,
263 EndcapForwardRoIFile = flags.Trigger.MUCTPI.EndcapForwardRoIFile,
264 Side0LUTFile = flags.Trigger.MUCTPI.Side0LUTFile,
265 Side1LUTFile = flags.Trigger.MUCTPI.Side1LUTFile,
266 InputSource = 'DIGITIZATION',
267 RPCRecRoiTool = rpcRecRoiTool,
268 TGCRecRoiTool = tgcRecRoiTool,
269 TrigThresholdDecisionTool = trigThresholdDecTool)
270 muctpiAlg = CompFactory.LVL1MUCTPIPHASE1.MUCTPI_AthAlg(name="MUCTPI_AthAlg",
271 MUCTPI_AthTool = muctpiTool)
272 acc.addEventAlgo(muctpiAlg)
273 from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
274 acc.merge(L1ConfigSvcCfg(flags))
275 return acc
276
277
279 acc = ComponentAccumulator()
280
281 if flags.Trigger.L0MuonSim.doEmulation:
282 from L0MuonEmulation.L0MuonSmearingConfig import L0MuonSmearingCfg
283 acc.merge(L0MuonSmearingCfg(flags)) # L0MuonRoI truth emulation
284 return acc
285
286 # otherwise, run-3 step will run.
287 acc.merge(MuonBytestream2RdoConfig(flags)) # data prep for muon bytestream data
288 acc.merge(MuonRdo2DigitConfig(flags)) # input for rpc/tgc trigger simulation
289 acc.merge(RPCTriggerConfig(flags)) # rpc trigger simulation, including bis78 to prepare for bis78-tgc coincidence
290 acc.merge(TMDBConfig(flags)) # for tmdb decision to prepare for tile-muon coincidence
291 acc.merge(NSWTriggerConfig(flags)) # nsw trigger simulation to prepare input for nsw-tgc coincidence
292 acc.merge(TGCTriggerConfig(flags)) # tgc trigger simulation
293 acc.merge(MuctpiConfig(flags)) # muctpi simulation
294
295 return acc
296
297if __name__ == "__main__":
298 import sys
299 from AthenaConfiguration.AllConfigFlags import initConfigFlags
300 flags = initConfigFlags()
301 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']
302 flags.Exec.MaxEvents = 5
303 flags.Concurrency.NumThreads = 1
304 flags.Trigger.triggerMenuSetup = 'MC_pp_run4_v1'
305 flags.Trigger.enableL0Muon = True
306 flags.Trigger.L0MuonSim.doEmulation = True
307 flags.fillFromArgs()
308 flags.lock()
309
310 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
311 acc = MainServicesCfg(flags)
312
313 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
314 acc.merge(PoolReadCfg(flags))
315
316 from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu
317 generateL1Menu(flags)
318
319 acc.merge(L0MuonSimulationCfg(flags))
320
321 acc.printConfig(withDetails=True, summariseProps=True, printDefaults=True)
322 sys.exit(acc.run().isFailure())
static std::string FindCalibFile(const std::string &logical_file_name)
MuonRdoToMuonDigitToolCfg(flags, name="MuonRdoToMuonDigitTool", **kwargs)