58def DFCommonTruthPhotonToolCfg(flags, name = "DFCommonTruthPhotonTool", **kwargs):
59 """Photon truth collection maker (Currently unused?)"""
60 acc = ComponentAccumulator()
61 kwargs.setdefault("OutputCollectionName", "TruthPhotons")
62 kwargs.setdefault("KeepNavigationInfo", False)
63 acc.addPublicTool(CompFactory.DerivationFramework.TruthCollectionMakerPhoton(name = name,**kwargs),
68# 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
69def DFCommonTruthPhotonToolSimCfg(flags, name = "DFCommonTruthPhotonToolSim", **kwargs):
70 """Tool for making TruthPhotons from sim samples"""
71 acc = ComponentAccumulator()
72 kwargs.setdefault("OutputCollectionName", "TruthPhotons")
73 kwargs.setdefault("KeepNavigationInfo", False)
74 acc.addPublicTool(CompFactory.DerivationFramework.TruthCollectionMakerPhotonSim(name = name,**kwargs),
150def TruthD2DecoratorCfg(flags, name, **kwargs):
151 """Configure the truth D2 decorator tool"""
152 acc = ComponentAccumulator()
153 TruthD2Decorator = CompFactory.DerivationFramework.TruthD2Decorator
154 acc.addPublicTool(TruthD2Decorator(name, **kwargs), primary = True)
158def TruthClassificationDecoratorCfg(flags, name, **kwargs):
159 """Configure the TruthClassificationDecorator tool"""
160 acc = ComponentAccumulator()
161 from MCTruthClassifier.MCTruthClassifierConfig import DFCommonMCTruthClassifierCfg
162 kwargs.setdefault("MCTruthClassifier", acc.addPublicTool(acc.popToolsAndMerge(DFCommonMCTruthClassifierCfg(flags))))
163 TruthClassificationDecorator = CompFactory.DerivationFramework.TruthClassificationDecorator
164 acc.setPrivateTools(TruthClassificationDecorator(name = name, **kwargs))
168def MuonTruthClassifierFallbackCfg(flags, name, **kwargs):
169 """Config the MuonTruthClassifierFallback tool"""
170 acc = ComponentAccumulator()
172 if "MCTruthClassifierTool" not in kwargs:
173 from MCTruthClassifier.MCTruthClassifierConfig import (
174 MCTruthClassifierCfg)
175 kwargs.setdefault("MCTruthClassifierTool", acc.popToolsAndMerge(
176 MCTruthClassifierCfg(flags, name = "MuonTruthClassifierFallbackMCTruthClassifier")))
178 MuonTruthClassifierFallback = CompFactory.DerivationFramework.MuonTruthClassifierFallback
179 acc.addPublicTool(MuonTruthClassifierFallback(name = name, **kwargs),
184def TruthDressingToolCfg(flags, name, **kwargs):
185 """Configure the TruthDressingTool"""
186 acc = ComponentAccumulator()
187 TruthDressingTool = CompFactory.DerivationFramework.TruthDressingTool
188 acc.addPublicTool(TruthDressingTool( name = name, **kwargs),
193def TruthIsolationToolCfg(flags, name, **kwargs):
194 """Configure the truth isolation tool"""
195 acc = ComponentAccumulator()
196 TruthIsolationTool = CompFactory.DerivationFramework.TruthIsolationTool
197 acc.addPublicTool(TruthIsolationTool(name = name, **kwargs),
202def MuonTruthIsolationDecorAlgCfg(flags, name, **kwargs):
203 """Configure the MuonTruthIsolationTool"""
204 acc = ComponentAccumulator()
205 acc.addEventAlgo(CompFactory.DerivationFramework.MuonTruthIsolationDecorAlg(name = name, **kwargs),
210def TruthQGDecorationToolCfg(flags, name, **kwargs):
211 """Configure the quark/gluon decoration tool"""
212 acc = ComponentAccumulator()
213 TruthQGDecorationTool = CompFactory.DerivationFramework.TruthQGDecorationTool
214 acc.addPublicTool(TruthQGDecorationTool(name = name, **kwargs),
219def TruthNavigationDecoratorCfg(flags, name, **kwargs):
220 """Congigure the truth navigation decorator tool"""
221 acc = ComponentAccumulator()
222 kwargs.setdefault("InputCollections", [])
223 kwargs.setdefault("parentDecorKeys", [ key + ".parentLinks" for key in kwargs["InputCollections"] ])
224 kwargs.setdefault("childDecorKeys", [ key + ".childLinks" for key in kwargs["InputCollections"] ])
225 TruthNavigationDecorator = CompFactory.DerivationFramework.TruthNavigationDecorator
226 acc.addPublicTool(TruthNavigationDecorator(name = name, **kwargs),
240def TruthBornLeptonCollectionMakerCfg(flags, name, **kwargs):
241 """Configure the truth Born lepton collection tool"""
242 acc = ComponentAccumulator()
243 TruthBornLeptonCollectionMaker = CompFactory.DerivationFramework.TruthBornLeptonCollectionMaker
244 acc.addPublicTool(TruthBornLeptonCollectionMaker(name = name, **kwargs),
249def HardScatterCollectionMakerCfg(flags, name, **kwargs):
250 """Add a mini-collection for the hard scatter and N subsequent generations"""
251 acc = ComponentAccumulator()
255#add the 'decoration' tool to dress the main truth collection with the classification
256def DFCommonTruthClassificationToolCfg(flags):
257 """dress the main truth collection with the classification"""
258 return TruthClassificationDecoratorCfg(flags,
259 name = "DFCommonTruthClassificationTool",
260 ParticlesKey = "TruthParticles")
263# Hadron origin decoration tools
264def HadronOriginClassifierCfg(flags, name, **kwargs):
265 """get the hadron origin classification"""
266 acc = ComponentAccumulator()
267 HadronOriginClassifier = CompFactory.DerivationFramework.HadronOriginClassifier
268 kwargs.setdefault("DSID", flags.Input.MCChannelNumber)
269 acc.addPublicTool(HadronOriginClassifier(name = name, **kwargs),
274def HadronOriginDecoratorCfg(flags, name, **kwargs):
275 """decorate with the hadron origin classification"""
276 acc = ComponentAccumulator()
277 if "ToolName" not in kwargs:
278 kwargs.setdefault("ToolName", acc.getPrimaryAndMerge(HadronOriginClassifierCfg(flags,
279 name="DFCommonHadronOriginClassifier")))
280 acc.addPublicTool(CompFactory.DerivationFramework.HadronOriginDecorator
281 (name = name, **kwargs),
286#add the 'decoration' tools for dressing and isolation
287def DFCommonTruthElectronDressingToolCfg(flags, decorationName = "dressedPhoton"):
288 """Configure the electron truth dressing tool"""
289 return TruthDressingToolCfg(flags,
290 name = "DFCommonTruthElectronDressingTool",
291 dressParticlesKey = "TruthElectrons",
292 usePhotonsFromHadrons = False,
293 dressingConeSize = 0.1,
294 particleIDsToDress = [11],
295 decorationName = decorationName+"_e")
298def DFCommonTruthMuonDressingToolCfg(flags, decorationName = "dressedPhoton"):
299 """Configure the muon truth dressing tool"""
300 return TruthDressingToolCfg(flags,
301 name = "DFCommonTruthMuonDressingTool",
302 dressParticlesKey = "TruthMuons",
303 usePhotonsFromHadrons = False,
304 dressingConeSize = 0.1,
305 particleIDsToDress = [13],
306 decorationName = decorationName+"_mu")
309def DFCommonTruthTauDressingToolCfg(flags):
310 """Configure the tau truth dressing tool"""
311 return TruthDressingToolCfg(flags,
312 name = "DFCommonTruthTauDressingTool",
313 dressParticlesKey = "TruthTaus",
314 usePhotonsFromHadrons = False,
315 dressingConeSize = 0.2, # Tau special
316 particleIDsToDress = [15],
317 decoratePhotons = False)
320def DFCommonTruthElectronIsolationTool1Cfg(flags):
321 """Configure the electron isolation tool, cone=0.2"""
322 return TruthIsolationToolCfg(flags,
323 name = "DFCommonTruthElectronIsolationTool1",
324 isoParticlesKey = "TruthElectrons",
325 allParticlesKey = "TruthParticles",
326 particleIDsToCalculate = [11],
327 IsolationConeSizes = [0.2],
328 IsolationVarNamePrefix = 'etcone',
329 ChargedParticlesOnly = False)
332def DFCommonTruthElectronIsolationTool2Cfg(flags):
333 """Configure the electron isolation tool, cone=0.3"""
334 return TruthIsolationToolCfg(flags,
335 name = "DFCommonTruthElectronIsolationTool2",
336 isoParticlesKey = "TruthElectrons",
337 allParticlesKey = "TruthParticles",
338 particleIDsToCalculate = [11],
339 IsolationConeSizes = [0.3],
340 IsolationVarNamePrefix = 'ptcone',
341 ChargedParticlesOnly = True)
344def DFCommonTruthMuonIsolationTool1Cfg(flags):
345 """Configure the muon isolation tool, cone=0.2"""
346 return TruthIsolationToolCfg(flags,
347 name = "DFCommonTruthMuonIsolationTool1",
348 isoParticlesKey = "TruthMuons",
349 allParticlesKey = "TruthParticles",
350 particleIDsToCalculate = [13],
351 IsolationConeSizes = [0.2],
352 IsolationVarNamePrefix = 'etcone',
353 ChargedParticlesOnly = False)
356def DFCommonTruthMuonIsolationTool2Cfg(flags):
357 """Configure the muon isolation tool, cone=0.3"""
358 return TruthIsolationToolCfg(flags,
359 name = "DFCommonTruthMuonIsolationTool2",
360 isoParticlesKey = "TruthMuons",
361 allParticlesKey = "TruthParticles",
362 particleIDsToCalculate = [13],
363 IsolationConeSizes = [0.3],
364 IsolationVarNamePrefix = 'ptcone',
365 ChargedParticlesOnly = True)
368def DFCommonTruthPhotonIsolationTool1Cfg(flags):
369 """Configure the photon isolation tool, etcone"""
370 return TruthIsolationToolCfg(flags,
371 name = "DFCommonTruthPhotonIsolationTool1",
372 isoParticlesKey = "TruthPhotons",
373 allParticlesKey = "TruthParticles",
374 particleIDsToCalculate = [22],
375 IsolationConeSizes = [0.2],
376 IsolationVarNamePrefix = 'etcone',
377 ChargedParticlesOnly = False)
380def DFCommonTruthPhotonIsolationTool2Cfg(flags):
381 """Configure the photon isolation tool, ptcone"""
382 return TruthIsolationToolCfg(flags,
383 name = "DFCommonTruthPhotonIsolationTool2",
384 isoParticlesKey = "TruthPhotons",
385 allParticlesKey = "TruthParticles",
386 particleIDsToCalculate = [22],
387 IsolationConeSizes = [0.2],
388 IsolationVarNamePrefix = 'ptcone',
389 ChargedParticlesOnly = True)
392def DFCommonTruthPhotonIsolationTool3Cfg(flags):
393 """Configure the photon isolation tool, etcone=0.4"""
394 return TruthIsolationToolCfg(flags,
395 name = "DFCommonTruthPhotonIsolationTool3",
396 isoParticlesKey = "TruthPhotons",
397 allParticlesKey = "TruthParticles",
398 particleIDsToCalculate = [22],
399 IsolationConeSizes = [0.4],
400 IsolationVarNamePrefix = 'etcone',
401 ChargedParticlesOnly = False)
404# Quark/gluon decoration for jets
405def DFCommonTruthDressedWZQGLabelToolCfg(flags):
406 """Configure the QG decoration tool for AntiKt4TruthDressedWZJets"""
407 return TruthQGDecorationToolCfg(flags,
408 name = "DFCommonTruthDressedWZQGLabelTool",
409 JetCollection = "AntiKt4TruthDressedWZJets")
411#==============================================================================
413#==============================================================================
415# Menu truth thinning: removes truth particles on the basis of a menu of
416# options (rather than a string)
417def MenuTruthThinningCfg(flags, name, **kwargs):
418 """Configure the menu truth thinning tool"""
419 acc = ComponentAccumulator()
420 MenuTruthThinning = CompFactory.DerivationFramework.MenuTruthThinning
421 acc.addPublicTool(MenuTruthThinning(name, **kwargs),
425#==============================================================================
427#==============================================================================
428# Truth links on some objects point to the main truth particle container.
429# This re-points the links from the old container to the new container
430def TruthLinkRepointToolCfg(flags, name, **kwargs):
431 """Configure the truth link repointing tool"""
432 acc = ComponentAccumulator()
433 TruthLinkRepointTool = CompFactory.DerivationFramework.TruthLinkRepointTool
434 acc.addPublicTool(TruthLinkRepointTool(name, **kwargs),
439# Makes a small collection of 'primary' vertices, one per event
440# A bit like a collection of 'reconstructable' vertices
441def TruthPVCollectionMakerCfg(flags, name, **kwargs):
442 """Configure the truth PV collection maker tool"""
443 acc = ComponentAccumulator()
444 TruthPVCollectionMaker = CompFactory.DerivationFramework.TruthPVCollectionMaker
445 acc.addPublicTool(TruthPVCollectionMaker(name, **kwargs),
450# Tool for thinning TruthParticles
451def GenericTruthThinningCfg(flags, name, **kwargs):
452 """Configure the GenericTruthThinning tool"""
453 acc = ComponentAccumulator()
454 GenericTruthThinning = CompFactory.DerivationFramework.GenericTruthThinning
455 acc.addPublicTool(GenericTruthThinning(name, **kwargs),