56def DFCommonTruthPhotonToolCfg(flags):
57 """Photon truth collection maker (Currently unused?)"""
58 return TruthCollectionMakerCfg(flags,
59 name = "DFCommonTruthPhotonTool",
60 OutputCollectionName = "TruthPhotons",
61 KeepNavigationInfo = False,
62 ParticleSelectionString = "(abs(TruthParticles.pdgId) == 22) && TruthParticles.isGenStable")
65# this tool is needed for making TruthPhotons from sim samples, where extra cuts are needed. Origin 42 (pi0) and 23 (light meson) cut way down uninteresting photons
66def DFCommonTruthPhotonToolSimCfg(flags):
67 """Tool for making TruthPhotons from sim samples"""
68 return TruthCollectionMakerCfg(flags,
69 name = "DFCommonTruthPhotonToolSim",
70 OutputCollectionName = "TruthPhotons",
71 KeepNavigationInfo = False,
72 ParticleSelectionString = "(abs(TruthParticles.pdgId) == 22) && TruthParticles.isGenStable && ((TruthParticles.classifierParticleOrigin != 42 && TruthParticles.classifierParticleOrigin !=23) || (TruthParticles.pt > 20.0*GeV))")
140def TruthD2DecoratorCfg(flags, name, **kwargs):
141 """Configure the truth D2 decorator tool"""
142 acc = ComponentAccumulator()
143 TruthD2Decorator = CompFactory.DerivationFramework.TruthD2Decorator
144 acc.addPublicTool(TruthD2Decorator(name, **kwargs), primary = True)
148def TruthClassificationDecoratorCfg(flags, name, **kwargs):
149 """Configure the TruthClassificationDecorator tool"""
150 acc = ComponentAccumulator()
151 from MCTruthClassifier.MCTruthClassifierConfig import DFCommonMCTruthClassifierCfg
152 kwargs.setdefault("MCTruthClassifier", acc.addPublicTool(acc.popToolsAndMerge(DFCommonMCTruthClassifierCfg(flags))))
153 TruthClassificationDecorator = CompFactory.DerivationFramework.TruthClassificationDecorator
154 acc.setPrivateTools(TruthClassificationDecorator(name = name, **kwargs))
158def MuonTruthClassifierFallbackCfg(flags, name, **kwargs):
159 """Config the MuonTruthClassifierFallback tool"""
160 acc = ComponentAccumulator()
162 if "MCTruthClassifierTool" not in kwargs:
163 from MCTruthClassifier.MCTruthClassifierConfig import (
164 MCTruthClassifierCfg)
165 kwargs.setdefault("MCTruthClassifierTool", acc.popToolsAndMerge(
166 MCTruthClassifierCfg(flags, name = "MuonTruthClassifierFallbackMCTruthClassifier")))
168 MuonTruthClassifierFallback = CompFactory.DerivationFramework.MuonTruthClassifierFallback
169 acc.addPublicTool(MuonTruthClassifierFallback(name = name, **kwargs),
174def TruthDressingToolCfg(flags, name, **kwargs):
175 """Configure the TruthDressingTool"""
176 acc = ComponentAccumulator()
177 TruthDressingTool = CompFactory.DerivationFramework.TruthDressingTool
178 acc.addPublicTool(TruthDressingTool( name = name, **kwargs),
183def TruthIsolationToolCfg(flags, name, **kwargs):
184 """Configure the truth isolation tool"""
185 acc = ComponentAccumulator()
186 TruthIsolationTool = CompFactory.DerivationFramework.TruthIsolationTool
187 acc.addPublicTool(TruthIsolationTool(name = name, **kwargs),
192def MuonTruthIsolationDecorAlgCfg(flags, name, **kwargs):
193 """Configure the MuonTruthIsolationTool"""
194 acc = ComponentAccumulator()
195 acc.addEventAlgo(CompFactory.DerivationFramework.MuonTruthIsolationDecorAlg(name = name, **kwargs),
200def TruthQGDecorationToolCfg(flags, name, **kwargs):
201 """Configure the quark/gluon decoration tool"""
202 acc = ComponentAccumulator()
203 TruthQGDecorationTool = CompFactory.DerivationFramework.TruthQGDecorationTool
204 acc.addPublicTool(TruthQGDecorationTool(name = name, **kwargs),
209def TruthNavigationDecoratorCfg(flags, name, **kwargs):
210 """Congigure the truth navigation decorator tool"""
211 acc = ComponentAccumulator()
212 kwargs.setdefault("InputCollections", [])
213 kwargs.setdefault("parentDecorKeys", [ key + ".parentLinks" for key in kwargs["InputCollections"] ])
214 kwargs.setdefault("childDecorKeys", [ key + ".childLinks" for key in kwargs["InputCollections"] ])
215 TruthNavigationDecorator = CompFactory.DerivationFramework.TruthNavigationDecorator
216 acc.addPublicTool(TruthNavigationDecorator(name = name, **kwargs),
230def TruthBornLeptonCollectionMakerCfg(flags, name, **kwargs):
231 """Configure the truth Born lepton collection tool"""
232 acc = ComponentAccumulator()
233 TruthBornLeptonCollectionMaker = CompFactory.DerivationFramework.TruthBornLeptonCollectionMaker
234 acc.addPublicTool(TruthBornLeptonCollectionMaker(name = name, **kwargs),
239def HardScatterCollectionMakerCfg(flags, name, **kwargs):
240 """Add a mini-collection for the hard scatter and N subsequent generations"""
241 acc = ComponentAccumulator()
245#add the 'decoration' tool to dress the main truth collection with the classification
246def DFCommonTruthClassificationToolCfg(flags):
247 """dress the main truth collection with the classification"""
248 return TruthClassificationDecoratorCfg(flags,
249 name = "DFCommonTruthClassificationTool",
250 ParticlesKey = "TruthParticles")
253# Hadron origin decoration tools
254def HadronOriginClassifierCfg(flags, name, **kwargs):
255 """get the hadron origin classification"""
256 acc = ComponentAccumulator()
257 HadronOriginClassifier = CompFactory.DerivationFramework.HadronOriginClassifier
258 kwargs.setdefault("DSID", flags.Input.MCChannelNumber)
259 acc.addPublicTool(HadronOriginClassifier(name = name, **kwargs),
264def HadronOriginDecoratorCfg(flags, name, **kwargs):
265 """decorate with the hadron origin classification"""
266 acc = ComponentAccumulator()
267 if not hasattr(kwargs, "ToolName"):
268 kwargs.setdefault("ToolName", acc.getPrimaryAndMerge(HadronOriginClassifierCfg(flags,
269 name="DFCommonHadronOriginClassifier")))
270 acc.addPublicTool(CompFactory.DerivationFramework.HadronOriginDecorator
271 (name = name, **kwargs),
276#add the 'decoration' tools for dressing and isolation
277def DFCommonTruthElectronDressingToolCfg(flags, decorationName = "dressedPhoton"):
278 """Configure the electron truth dressing tool"""
279 return TruthDressingToolCfg(flags,
280 name = "DFCommonTruthElectronDressingTool",
281 dressParticlesKey = "TruthElectrons",
282 usePhotonsFromHadrons = False,
283 dressingConeSize = 0.1,
284 particleIDsToDress = [11],
285 decorationName = decorationName+"_e")
288def DFCommonTruthMuonDressingToolCfg(flags, decorationName = "dressedPhoton"):
289 """Configure the muon truth dressing tool"""
290 return TruthDressingToolCfg(flags,
291 name = "DFCommonTruthMuonDressingTool",
292 dressParticlesKey = "TruthMuons",
293 usePhotonsFromHadrons = False,
294 dressingConeSize = 0.1,
295 particleIDsToDress = [13],
296 decorationName = decorationName+"_mu")
299def DFCommonTruthTauDressingToolCfg(flags):
300 """Configure the tau truth dressing tool"""
301 return TruthDressingToolCfg(flags,
302 name = "DFCommonTruthTauDressingTool",
303 dressParticlesKey = "TruthTaus",
304 usePhotonsFromHadrons = False,
305 dressingConeSize = 0.2, # Tau special
306 particleIDsToDress = [15],
307 decoratePhotons = False)
310def DFCommonTruthElectronIsolationTool1Cfg(flags):
311 """Configure the electron isolation tool, cone=0.2"""
312 return TruthIsolationToolCfg(flags,
313 name = "DFCommonTruthElectronIsolationTool1",
314 isoParticlesKey = "TruthElectrons",
315 allParticlesKey = "TruthParticles",
316 particleIDsToCalculate = [11],
317 IsolationConeSizes = [0.2],
318 IsolationVarNamePrefix = 'etcone',
319 ChargedParticlesOnly = False)
322def DFCommonTruthElectronIsolationTool2Cfg(flags):
323 """Configure the electron isolation tool, cone=0.3"""
324 return TruthIsolationToolCfg(flags,
325 name = "DFCommonTruthElectronIsolationTool2",
326 isoParticlesKey = "TruthElectrons",
327 allParticlesKey = "TruthParticles",
328 particleIDsToCalculate = [11],
329 IsolationConeSizes = [0.3],
330 IsolationVarNamePrefix = 'ptcone',
331 ChargedParticlesOnly = True)
334def DFCommonTruthMuonIsolationTool1Cfg(flags):
335 """Configure the muon isolation tool, cone=0.2"""
336 return TruthIsolationToolCfg(flags,
337 name = "DFCommonTruthMuonIsolationTool1",
338 isoParticlesKey = "TruthMuons",
339 allParticlesKey = "TruthParticles",
340 particleIDsToCalculate = [13],
341 IsolationConeSizes = [0.2],
342 IsolationVarNamePrefix = 'etcone',
343 ChargedParticlesOnly = False)
346def DFCommonTruthMuonIsolationTool2Cfg(flags):
347 """Configure the muon isolation tool, cone=0.3"""
348 return TruthIsolationToolCfg(flags,
349 name = "DFCommonTruthMuonIsolationTool2",
350 isoParticlesKey = "TruthMuons",
351 allParticlesKey = "TruthParticles",
352 particleIDsToCalculate = [13],
353 IsolationConeSizes = [0.3],
354 IsolationVarNamePrefix = 'ptcone',
355 ChargedParticlesOnly = True)
358def DFCommonTruthPhotonIsolationTool1Cfg(flags):
359 """Configure the photon isolation tool, etcone"""
360 return TruthIsolationToolCfg(flags,
361 name = "DFCommonTruthPhotonIsolationTool1",
362 isoParticlesKey = "TruthPhotons",
363 allParticlesKey = "TruthParticles",
364 particleIDsToCalculate = [22],
365 IsolationConeSizes = [0.2],
366 IsolationVarNamePrefix = 'etcone',
367 ChargedParticlesOnly = False)
370def DFCommonTruthPhotonIsolationTool2Cfg(flags):
371 """Configure the photon isolation tool, ptcone"""
372 return TruthIsolationToolCfg(flags,
373 name = "DFCommonTruthPhotonIsolationTool2",
374 isoParticlesKey = "TruthPhotons",
375 allParticlesKey = "TruthParticles",
376 particleIDsToCalculate = [22],
377 IsolationConeSizes = [0.2],
378 IsolationVarNamePrefix = 'ptcone',
379 ChargedParticlesOnly = True)
382def DFCommonTruthPhotonIsolationTool3Cfg(flags):
383 """Configure the photon isolation tool, etcone=0.4"""
384 return TruthIsolationToolCfg(flags,
385 name = "DFCommonTruthPhotonIsolationTool3",
386 isoParticlesKey = "TruthPhotons",
387 allParticlesKey = "TruthParticles",
388 particleIDsToCalculate = [22],
389 IsolationConeSizes = [0.4],
390 IsolationVarNamePrefix = 'etcone',
391 ChargedParticlesOnly = False)
394# Quark/gluon decoration for jets
395def DFCommonTruthDressedWZQGLabelToolCfg(flags):
396 """Configure the QG decoration tool for AntiKt4TruthDressedWZJets"""
397 return TruthQGDecorationToolCfg(flags,
398 name = "DFCommonTruthDressedWZQGLabelTool",
399 JetCollection = "AntiKt4TruthDressedWZJets")
401#==============================================================================
403#==============================================================================
405# Menu truth thinning: removes truth particles on the basis of a menu of
406# options (rather than a string)
407def MenuTruthThinningCfg(flags, name, **kwargs):
408 """Configure the menu truth thinning tool"""
409 acc = ComponentAccumulator()
410 MenuTruthThinning = CompFactory.DerivationFramework.MenuTruthThinning
411 acc.addPublicTool(MenuTruthThinning(name, **kwargs),
415#==============================================================================
417#==============================================================================
418# Truth links on some objects point to the main truth particle container.
419# This re-points the links from the old container to the new container
420def TruthLinkRepointToolCfg(flags, name, **kwargs):
421 """Configure the truth link repointing tool"""
422 acc = ComponentAccumulator()
423 TruthLinkRepointTool = CompFactory.DerivationFramework.TruthLinkRepointTool
424 acc.addPublicTool(TruthLinkRepointTool(name, **kwargs),
429# Makes a small collection of 'primary' vertices, one per event
430# A bit like a collection of 'reconstructable' vertices
431def TruthPVCollectionMakerCfg(flags, name, **kwargs):
432 """Configure the truth PV collection maker tool"""
433 acc = ComponentAccumulator()
434 TruthPVCollectionMaker = CompFactory.DerivationFramework.TruthPVCollectionMaker
435 acc.addPublicTool(TruthPVCollectionMaker(name, **kwargs),
440# Tool for thinning TruthParticles
441def GenericTruthThinningCfg(flags, name, **kwargs):
442 """Configure the GenericTruthThinning tool"""
443 acc = ComponentAccumulator()
444 GenericTruthThinning = CompFactory.DerivationFramework.GenericTruthThinning
445 acc.addPublicTool(GenericTruthThinning(name, **kwargs),