ATLAS Offline Software
xAODTruthCnvConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 
5 def GEN_EVNT2xAODCfg(flags, name="GEN_EVNT2xAOD", **kwargs):
6  """Configure the EVNT->xAOD converter alg"""
7  # Note that since this is usually used by the derivation framework
8  # which handles the output stream itself (to allow the expansion to AuxDyn and slimming)
9  # nothing is done with the stream here - this is done in the DF job options
10  acc = ComponentAccumulator()
11 
12  # In case we find the special configuration setting, add the LHE particles
13  if flags.Input.SpecialConfiguration.get("HasLHERecord", "False") == "True":
14  kwargs.setdefault('xAODTruthLHEParticleContainerName', 'TruthLHEParticles')
15 
16  xAODTruthCnvAlg = CompFactory.xAODMaker.xAODTruthCnvAlg
17  acc.addEventAlgo(xAODTruthCnvAlg(name,**kwargs))
18  return acc
19 
20 def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs):
21  acc = ComponentAccumulator()
22 
23  writeInTimePileUpTruth=False
24 
25  # Use digiSteeringConf from metadata to check whether full-PU
26  # truth should be written.
27  if flags.Digitization.PileUp and flags.Digitization.DigiSteeringConf in ['StandardPileUpToolsAlg', 'StandardInTimeOnlyTruthPileUpToolsAlg', 'StandardInTimeOnlyGeantinoTruthPileUpToolsAlg']:
28  writeInTimePileUpTruth = True
29 
30  kwargs.setdefault('WriteInTimePileUpTruth', writeInTimePileUpTruth)
31  kwargs.setdefault('AODContainerName', 'TruthEvent')
32 
33  algo = CompFactory.xAODMaker.xAODTruthCnvAlg(name, **kwargs)
34  acc.addEventAlgo(algo, primary = True)
35 
36  from OutputStreamAthenaPool.OutputStreamConfig import addToESD,addToAOD
37  toAOD = ["xAOD::TruthEventContainer#TruthEvents", "xAOD::TruthEventAuxContainer#TruthEventsAux.",
38  "xAOD::TruthVertexContainer#TruthVertices", "xAOD::TruthVertexAuxContainer#TruthVerticesAux.",
39  "xAOD::TruthParticleContainer#TruthParticles", "xAOD::TruthParticleAuxContainer#TruthParticlesAux.",
40  ]
41 
42  if "xAOD::TruthParticleContainer#TruthPileupParticles" in flags.Input.TypedCollections:
43  toAOD.append("xAOD::TruthParticleContainer#TruthPileupParticles")
44  toAOD.append("xAOD::TruthParticleAuxContainer#TruthPileupParticlesAux.")
45 
46  if writeInTimePileUpTruth:
47  toAOD.append("xAOD::TruthPileupEventContainer#TruthPileupEvents")
48  toAOD.append("xAOD::TruthPileupEventAuxContainer#TruthPileupEventsAux.")
49 
50  if flags.Input.SpecialConfiguration.get("HasLHERecord", "False") == "True":
51  kwargs.setdefault('xAODTruthLHEParticleContainerName', 'TruthLHEParticles')
52  toAOD.append("xAOD::TruthParticleContainer#TruthLHEParticles")
53  toAOD.append("xAOD::TruthParticleContainer#TruthLHEParticlesAux.")
54 
55  toESD = []
56 
57  if flags.Output.doWriteESD:
58  acc.merge(addToESD(flags, toAOD+toESD))
59  if flags.Output.doWriteAOD:
60  acc.merge(addToAOD(flags, toAOD))
61 
62  return acc
63 
64 def HepMCTruthReaderCfg(flags, name="HepMCTruthReader"):
65  acc = ComponentAccumulator()
66  HepMCTruthReader = CompFactory.HepMCTruthReader(
67  name = name,
68  HepMCContainerKey = flags.HepMCContainerKey,
69  Do4momPtEtaPhi = flags.Do4momPtEtaPhi
70  )
71  acc.addEventAlgo(HepMCTruthReader)
72  return acc
73 
74 def xAODTruthReaderCfg(flags, name="xAODTruthReader"):
75  acc = ComponentAccumulator()
76  xAODTruthReader = CompFactory.xAODReader.xAODTruthReader(
77  name = name,
78  xAODTruthEventContainerKey = flags.xAODTruthEventContainerKey,
79  # xAODTruthPileupEventContainerKey = flags.xAODTruthPileupEventContainerKey,
80  DoPUEventPrintout = flags.DoPUEventPrintout,
81  Do4momPtEtaPhi = flags.Do4momPtEtaPhi
82  )
83  acc.addEventAlgo(xAODTruthReader)
84  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
xAODTruthCnvConfig.GEN_AOD2xAODCfg
def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:20
xAODTruthCnvConfig.GEN_EVNT2xAODCfg
def GEN_EVNT2xAODCfg(flags, name="GEN_EVNT2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:5
xAODTruthCnvConfig.HepMCTruthReaderCfg
def HepMCTruthReaderCfg(flags, name="HepMCTruthReader")
Definition: xAODTruthCnvConfig.py:64
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
xAODTruthCnvConfig.xAODTruthReaderCfg
def xAODTruthReaderCfg(flags, name="xAODTruthReader")
Definition: xAODTruthCnvConfig.py:74