ATLAS Offline Software
Loading...
Searching...
No Matches
MUON1.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2#====================================================================
3# DAOD_MUON1.py
4# This defines the component accumulator version of DAOD_MUON1
5# It requires the flag MUON1 in Derivation_tf.py
6#====================================================================
7
8from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9from AthenaConfiguration.ComponentFactory import CompFactory
10from AthenaConfiguration.Enums import MetadataCategory
11import AthenaCommon.SystemOfUnits as Units
12
13
15 MuonContainer="Muons",
16 IdTrackContainer="InDetTrackParticles",
17 applyTrigger = False):
18 acc = ComponentAccumulator()
19 from DerivationFrameworkMuons.MuonsToolsConfig import DiMuonTaggingAlgCfg
20
21 acc.merge(DiMuonTaggingAlgCfg(flags,
22 name = "DiMuonTaggingZmumuOC",
23 Mu1PtMin = 4.*Units.GeV,
24 Mu1AbsEtaMax = 2.75,
25 Mu1RequireQual = True,
26 Mu2PtMin = 2.*Units.GeV,
27 UseTrackProbe = True,
28 MuonContainerKey = MuonContainer,
29 TrackContainerKey = IdTrackContainer,
30 InvariantMassLow = 60*Units.GeV,
31 IDTrackThinningConeSize = 0.4,
32 applyTrigger = applyTrigger,
33 BranchPrefix = "Muon1ZmumuOC"))
34
35
36 acc.merge(DiMuonTaggingAlgCfg(flags,
37 name = "DiMuonTaggingZmumuSC",
38 Mu1PtMin = 4.*Units.GeV,
39 Mu1AbsEtaMax = 2.75,
40 Mu1RequireQual = True,
41 Mu2PtMin = 2.*Units.GeV,
42 UseTrackProbe = True,
43 MuonContainerKey = MuonContainer,
44 TrackContainerKey = IdTrackContainer,
45 OppositeCharge = False,
46 applyTrigger = applyTrigger,
47 InvariantMassLow = 60*Units.GeV,
48 BranchPrefix = "Muon1ZmumuSC"))
49 # Jpsi
50 acc.merge(DiMuonTaggingAlgCfg(flags,
51 name = "DiMuonTaggingJpsi",
52 Mu1PtMin = 4.*Units.GeV,
53 Mu1AbsEtaMax = 2.75,
54 Mu1RequireQual = True,
55 Mu2PtMin = 2.*Units.GeV,
56 UseTrackProbe = True,
57 MuonContainerKey = MuonContainer,
58 TrackContainerKey = IdTrackContainer,
59 applyTrigger = applyTrigger,
60 InvariantMassLow = 2.0*Units.GeV,
61 InvariantMassHigh = 4.8*Units.GeV,
62 BranchPrefix = "Muon1JPsi"))
63
64 acc.merge(DiMuonTaggingAlgCfg(flags,
65 name = "DiMuonTaggingUpsilon",
66 Mu1PtMin = 4.*Units.GeV,
67 Mu1AbsEtaMax = 2.75,
68 Mu1RequireQual = True,
69 Mu2PtMin = 2.*Units.GeV,
70 MuonContainerKey = MuonContainer,
71 TrackContainerKey = IdTrackContainer,
72 InvariantMassLow = 7.0*Units.GeV,
73 InvariantMassHigh = 13.*Units.GeV,
74 applyTrigger = applyTrigger,
75 BranchPrefix = "Muon1Upsilon"))
76 if flags.Input.isMC:
77
78 acc.merge(DiMuonTaggingAlgCfg(flags,
79 name = "MuonTruthTagging",
80 Mu1PtMin = 2.*Units.GeV,
81 Mu1RequireQual = True,
82 Mu2PtMin = 60.*Units.TeV, # Dummy value
83 UseTrackProbe = True,
84 MuonContainerKey = MuonContainer,
85 TrackContainerKey = IdTrackContainer,
86 OppositeCharge = False,
87 InvariantMassLow = 60*Units.TeV, # Dummy value
88 applyTrigger = applyTrigger,
89 IDTrackThinningConeSize = 0.1,
90 BranchPrefix = "TruthMuon"))
91
92 return acc
93
94
95# Main algorithm config
96def MUON1KernelCfg(flags, name='MUON1Kernel', **kwargs):
97 """Configure the derivation framework driving algorithm (kernel) for MUON1"""
98 acc = ComponentAccumulator()
99 stream_name= 'StreamDAOD_MUON1'
100
101 kwargs.setdefault("MuonContainer", "Muons")
102 kwargs.setdefault("IdTrkContainer", "InDetTrackParticles")
103 kwargs.setdefault("MsTrkContainer", "ExtrapolatedMuonTrackParticles")
104 kwargs.setdefault("scheduleThinning", True)
105
106
107 # --------------------
108 # Common augmentations
109 # --------------------
110 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
111 acc.merge(PhysCommonAugmentationsCfg(flags, TriggerListsHelper = kwargs['TriggerListsHelper']))
112
113
114 diMuonSelAcc = Muon1SelectionCfg(flags,
115 MuonContainer= kwargs["MuonContainer"],
116 IdTrackContainer=kwargs["IdTrkContainer"])
117 # ------------
118 # Augmentation
119 # ------------
120 # Strings for applying cuts based on augmentations
121 muonThinFlags = ["pass{flag}".format(flag = algo.BranchPrefix) for algo in diMuonSelAcc.getEventAlgos()]
122 skimmingORs = [f"DIMU_{flag} > 0" for flag in muonThinFlags]
123 trkThinFlags = [muonThinFlags[i] for i, algo in enumerate(diMuonSelAcc.getEventAlgos()) if algo.UseTrackProbe ]
124 acc.merge(diMuonSelAcc)
125
126
127
128 if flags.Input.isMC:
129 from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import MuonTruthClassifierFallbackCfg
130 MUON1MuonTruthClassifierFallback = acc.getPrimaryAndMerge(MuonTruthClassifierFallbackCfg(flags,
131 name = "MUON1MuonTruthClassifierFallback",
132 ContainerKey = kwargs["MuonContainer"]))
133 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel("MuonTruthClassifierFallBack",
134 AugmentationTools=[MUON1MuonTruthClassifierFallback]))
135 from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import MuonTruthIsolationDecorAlgCfg
136 acc.merge(MuonTruthIsolationDecorAlgCfg(flags,
137 name = "MUON1MuonTruthIsolationAlg",
138 ContainerKey = kwargs["MuonContainer"]))
139
140
141
142 from DerivationFrameworkMuons.JPsiVertexFitSetupCfg import AddMCPJPsiVertexFitCfg
143 acc.merge(AddMCPJPsiVertexFitCfg(flags,
144 prefix='Muon1',
145 IdTrkContainer = kwargs["IdTrkContainer"],
146 MuonContainer = kwargs["MuonContainer"]))
147
148 from DerivationFrameworkMuons.TrackIsolationDecoratorConfig import TrackIsolationCfg
149 acc.merge(TrackIsolationCfg(flags,
150 TrackCollection=kwargs["IdTrkContainer"]))
151 acc.merge(TrackIsolationCfg(flags,
152 TrackCollection=kwargs["MsTrkContainer"]))
153
154
155 from DerivationFrameworkMuons.MuonsToolsConfig import MuonCaloDepositAlgCfg
156 acc.merge(MuonCaloDepositAlgCfg(flags,
157 name = "MuonCaloDepositAlg",
158 ContainerKey= kwargs["MuonContainer"]))
159 acc.merge(MuonCaloDepositAlgCfg(flags,
160 name = "IdTrkCaloDepositDecorator",
161 ContainerKey= kwargs["IdTrkContainer"]))
162
163
164 from DerivationFrameworkMuons.MuonsToolsConfig import MuonTPExtrapolationAlgCfg
165 acc.merge(MuonTPExtrapolationAlgCfg(flags,
166 name = "MuonTPExtrapolationAlgMUON1",
167 ContainerKey= kwargs["MuonContainer"],
168 TrackSelections = ["passMuon1JPsi"]))
169
170 acc.merge(MuonTPExtrapolationAlgCfg(flags,
171 name = "MuonTPTrigExtrapolationMUON1",
172 ContainerKey= kwargs["IdTrkContainer"],
173 TrackSelections = ["passMuon1JPsi"]))
174
175
176 # --------
177 # Skimming
178 # --------
179 MUON1SkimmingTools = []
180 skimming_expression = '||'.join(skimmingORs)
181 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import xAODStringSkimmingToolCfg
182 MUON1SkimmingTool1 = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(flags,
183 name = "MUON1SkimmingTool1",
184 expression = skimming_expression))
185 MUON1SkimmingTools.append(MUON1SkimmingTool1)
186
187 # --------
188 # Thinning
189 # --------
190
191 # Thinning tools
192 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import CaloClusterThinningCfg
193 from DerivationFrameworkMuons.MuonsToolsConfig import AnalysisMuonThinningAlgCfg
194 MUON1ThinningTools = []
195 if kwargs["scheduleThinning"]:
196 fwdTracks = "InDetForwardTrackParticles"
197 if fwdTracks not in flags.Input.Collections:
198 fwdTracks = ""
199 acc.merge(AnalysisMuonThinningAlgCfg(flags,
200 name = "AnalysisMuonThinningAlgMUON1",
201 MuonPassFlags = ["{cont}.{passDecor}".format(cont = kwargs["MuonContainer"],
202 passDecor = passDecor) for passDecor in muonThinFlags],
203 TrkPassFlags =["{cont}.{passDecor}".format(cont = kwargs["IdTrkContainer"],
204 passDecor = passDecor) for passDecor in trkThinFlags],
205 IdTrkFwdThinning=fwdTracks,
206 StreamName = stream_name))
207
208
209 # keep topoclusters around muons
210 MUON1ThinningTool1 = acc.getPrimaryAndMerge(CaloClusterThinningCfg(flags,
211 name = "MUON1ThinningTool4",
212 StreamName = stream_name,
213 SGKey = "Muons",
214 SelectionString = "Muons.pt>4*GeV",
215 TopoClCollectionSGKey = "CaloCalTopoClusters",
216 ConeSize = 0.5))
217 MUON1ThinningTools.append(MUON1ThinningTool1)
218
219
220 muon1CellThinAlg = CompFactory.CaloThinCellsByClusterAlg(
221 'MUON1_CaloThinCellsByClusterAlg_MuonClusterCollection',
222 StreamName = stream_name,
223 Clusters = 'MuonClusterCollection',
224 Cells = 'AllCalo')
225 acc.addEventAlgo(muon1CellThinAlg)
226
227
228
229 from DerivationFrameworkBPhys.commonBPHYMethodsCfg import Thin_vtxTrkCfg
230 MUON1Thin_vtxTrk = acc.getPrimaryAndMerge(Thin_vtxTrkCfg(flags,
231 name = "MUON1Thin_vtxTrk",
232 StreamName = stream_name,
233 TrackParticleContainerName = "InDetTrackParticles",
234 VertexContainerNames = ["Muon1JpsiCandidates"],
235 PassFlags = ["passed_Jpsi"] ))
236 MUON1ThinningTools.append(MUON1Thin_vtxTrk)
237
238
239 if flags.Input.isMC:
240 from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import MenuTruthThinningCfg
241 MUON1TruthThinningTool = acc.getPrimaryAndMerge(MenuTruthThinningCfg(flags,
242 name = "MUON1TruthThinningTool",
243 StreamName = stream_name,
244 WritePartons = False,
245 WriteHadrons = False,
246 WriteCHadrons = False,
247 WriteBHadrons = True,
248 WriteGeant = False,
249 WriteTauHad = False,
250 PartonPtThresh = -1.0,
251 WriteBSM = True,
252 WriteBosons = True,
253 WriteBosonProducts = False,
254 WriteBSMProducts = True,
255 WriteTopAndDecays = False,
256 WriteEverything = False,
257 WriteAllLeptons = True,
258 WriteLeptonsNotFromHadrons = False,
259 WriteNotPhysical = False,
260 WriteFirstN = -1,
261 PreserveAncestors = False,
262 PreserveParentsSiblingsChildren = True,
263 PreserveGeneratorDescendants = False))
264 # Not sure what this should be set to nowadays
265 #SimBarcodeOffset = DerivationFrameworkSimBarcodeOffset)
266 MUON1ThinningTools.append(MUON1TruthThinningTool)
267
268 # --------------------
269 # The kernel algorithm
270 # --------------------
271
272
273 from IsolationSelection.IsolationSelectionConfig import IsoCloseByAlgsCfg
274 acc.merge(IsoCloseByAlgsCfg(flags, isPhysLite = True))
275
276
277 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name,
278 SkimmingTools = MUON1SkimmingTools,
279 ThinningTools = MUON1ThinningTools))
280 return acc
281
282
283def MUON1Cfg(flags):
284 stream_name = 'StreamDAOD_MUON1'
285 acc = ComponentAccumulator()
286
287 # Get the lists of triggers needed for trigger matching.
288 # This is needed at this scope (for the slimming) and further down in the config chain
289 # for actually configuring the matching, so we create it here and pass it down
290 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
291 MUON1TriggerListsHelper = TriggerListsHelper(flags)
292
293
294
295 # Common augmentations
296 acc.merge(MUON1KernelCfg(flags, name="MUON1Kernel", StreamName = stream_name, TriggerListsHelper = MUON1TriggerListsHelper))
297
298 # LeptonTaggers isolation to schedule PLIT
299 from LeptonTaggers.LeptonTaggersConfig import DecoratePLITAlgsCfg
300 acc.merge(DecoratePLITAlgsCfg(flags))
301
302 # ============================
303 # Define contents of the format
304 # =============================
305 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
306 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
307 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
308
309 isoCones = [f"pt{cone}cone{size}_Nonprompt_All_MaxWeightTTVA_pt{pt}" for cone in ["", "var"] for size in range(20,50,10) for pt in [500, 1000] ]
310 isoCones += [f"{cone}{size}" for cone in ["topoetcone", "neflowisol"] for size in range(20,50,10)]
311
312 decorationsID = ["TTVA_AMVFVertices" , "TTVA_AMVFWeights", "vx", "vy", "vz"]
313 decorationsME = []
314 decoartionsMuon = ["EnergyLossSigma"]
315
316 decorationsID += isoCones
317 decorationsME += isoCones
318 CaloDeposDecors = ["CaloDeposits", "CaloElosses", "CaloDepType"]
319 decorationsID += CaloDeposDecors
320 decoartionsMuon += CaloDeposDecors
321 tpExtrapolations = ["EtaTriggerPivot", "PhiTriggerPivot", "DecoratedPivotEtaPhi"]
322 decorationsID += tpExtrapolations
323 decoartionsMuon += tpExtrapolations
324
325
326 MUON1SlimmingHelper = SlimmingHelper("MUON1SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
327 MUON1SlimmingHelper.SmartCollections = ["EventInfo",
328 "Electrons",
329 "Photons",
330 "Muons",
331 "PrimaryVertices",
332 "InDetTrackParticles",
333 "AntiKt4EMTopoJets",
334 "AntiKt4EMPFlowJets",
335 "MET_Baseline_AntiKt4EMTopo",
336 "MET_Baseline_AntiKt4EMPFlow",
337 "TauJets",
338 "TauJets_MuonRM",
339 "DiTauJets",
340 "DiTauJetsLowPt",
341 "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets",
342 ]
343
344 excludedVertexAuxData = "-vxTrackAtVertex.-MvfFitInfo.-isInitialized.-VTAV"
345 StaticContent = []
346 StaticContent += ["xAOD::VertexContainer#SoftBVrtClusterTool_Tight_Vertices"]
347 StaticContent += ["xAOD::VertexAuxContainer#SoftBVrtClusterTool_Tight_VerticesAux." + excludedVertexAuxData]
348 StaticContent += ["xAOD::VertexContainer#SoftBVrtClusterTool_Medium_Vertices"]
349 StaticContent += ["xAOD::VertexAuxContainer#SoftBVrtClusterTool_Medium_VerticesAux." + excludedVertexAuxData]
350 StaticContent += ["xAOD::VertexContainer#SoftBVrtClusterTool_Loose_Vertices"]
351 StaticContent += ["xAOD::VertexAuxContainer#SoftBVrtClusterTool_Loose_VerticesAux." + excludedVertexAuxData]
352 StaticContent += ["xAOD::VertexContainer#Muon1JpsiCandidates"]
353 StaticContent += ["xAOD::VertexAuxContainer#Muon1JpsiCandidatesAux."+excludedVertexAuxData]
354 StaticContent += ["CaloCellContainer#DFMUONCellContainer"]
355 StaticContent += ["CaloClusterCellLinkContainer#MuonClusterCollection_links"]
356
357 MUON1SlimmingHelper.StaticContent = StaticContent
358
359 from IsolationSelection.IsolationSelectionConfig import setupIsoCloseBySlimmingVariables
360 setupIsoCloseBySlimmingVariables(MUON1SlimmingHelper)
361 # Extra content
362 MUON1SlimmingHelper.ExtraVariables += ["AntiKt4EMTopoJets.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
363 "AntiKt4EMPFlowJets.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
364 "TruthPrimaryVertices.t.x.y.z",
365 "PrimaryVertices.trackWeights",
366 "MuonSegments.chiSquared.numberDoF.nPrecisionHits.x.y.z",
367 "Muons." +".".join(decoartionsMuon),
368 "InDetTrackParticles."+ ".".join(decorationsID),
369 "ExtrapolatedMuonTrackParticles." +".".join(decorationsME),
370 "CaloCalTopoClusters.calE.calEta.calM.calPhi.e_sampl.rawM.rawPhi.rawEta.rawE",
371 "EventInfo.GenFiltHT.GenFiltMET.GenFiltHTinclNu.GenFiltPTZ.GenFiltFatJ",
372 "TauJets.dRmax.etOverPtLeadTrk",
373 "TauJets_MuonRM.dRmax.etOverPtLeadTrk",
374 "CombinedMuonTrackParticles.vx.vy.vz",
375 "MuonSpectrometerTrackParticles.vx.vy.vz",
376 "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET.ex.ey",
377 "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_mht.ex.ey"]
378
379 # LeptonTaggers PLIT content
380 from LeptonTaggers.LeptonTaggersConfig import GetExtraPLITVariablesForDxAOD
381 MUON1SlimmingHelper.ExtraVariables += GetExtraPLITVariablesForDxAOD()
382
383 # Truth content
384 if flags.Input.isMC:
385 MUON1SlimmingHelper.AllVariables += ["TruthEvents", "TruthParticles", "TruthVertices", "MuonTruthParticles"]
386
387 MUON1SlimmingHelper.AllVariables += ["MuonClusterCollection"]
388
389 # Trigger content
390 MUON1SlimmingHelper.IncludeTriggerNavigation = False
391 MUON1SlimmingHelper.IncludeJetTriggerContent = False
392 MUON1SlimmingHelper.IncludeMuonTriggerContent = True
393 MUON1SlimmingHelper.IncludeEGammaTriggerContent = False
394 MUON1SlimmingHelper.IncludeTauTriggerContent = False
395 MUON1SlimmingHelper.IncludeEtMissTriggerContent = False
396 MUON1SlimmingHelper.IncludeBJetTriggerContent = False
397 MUON1SlimmingHelper.IncludeBPhysTriggerContent = True
398 MUON1SlimmingHelper.IncludeMinBiasTriggerContent = False
399
400 # Trigger matching
401 # Run 2
402 if flags.Trigger.EDMVersion == 2:
403 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
404 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = MUON1SlimmingHelper,
405 OutputContainerPrefix = "TrigMatch_",
406 TriggerList = MUON1TriggerListsHelper.Run2TriggerNamesTau)
407 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = MUON1SlimmingHelper,
408 OutputContainerPrefix = "TrigMatch_",
409 TriggerList = MUON1TriggerListsHelper.Run2TriggerNamesNoTau)
410
411 # Custom (B-physics) muon chains not in PHYS
412 from DerivationFrameworkMuons.MuonsExtraTriggerConfig import MuonExtraTriggerHelper
413 ExtraHelper = MuonExtraTriggerHelper(flags,MUON1TriggerListsHelper)
414 acc.merge(ExtraHelper.Run2MatchAugmentationCfg(flags))
415 ExtraHelper.AddRun2MatchingToSlimmingHelper(SlimmingHelper = MUON1SlimmingHelper,
416 OutputContainerPrefix = "TrigMatch_")
417
418 # Run 3, or Run 2 with navigation conversion
419 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
420 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
421 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(MUON1SlimmingHelper)
422
423 # Output stream
424 MUON1ItemList = MUON1SlimmingHelper.GetItemList()
425 acc.merge(OutputStreamCfg(flags, "DAOD_MUON1", ItemList=MUON1ItemList, AcceptAlgs=["MUON1Kernel"]))
426 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_MUON1", AcceptAlgs=["MUON1Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
427
428 return acc
429
MUON1Cfg(flags)
Definition MUON1.py:283
Muon1SelectionCfg(flags, MuonContainer="Muons", IdTrackContainer="InDetTrackParticles", applyTrigger=False)
Definition MUON1.py:17
MUON1KernelCfg(flags, name='MUON1Kernel', **kwargs)
Definition MUON1.py:96