ATLAS Offline Software
TRUTH0.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #!/usr/bin/env python
3 # TRUTH0.py - direct and complete translation of HepMC in EVNT to xAOD truth
4 # No additional information is added
5 
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 from AthenaConfiguration.Enums import MetadataCategory
8 
9 def TRUTH0Cfg(flags):
10  """Main config for TRUTH0"""
11  acc = ComponentAccumulator()
12 
13  # Ensure EventInfoCnvAlg is scheduled
14  if "EventInfo#McEventInfo" in flags.Input.TypedCollections and "xAOD::EventInfo#EventInfo" not in flags.Input.TypedCollections:
15  from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
16  acc.merge(EventInfoCnvAlgCfg(flags, inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=True))
17 
18  # Decide what kind of input HepMC container we are dealing with
19  # and schedule the xAOD converter appropriately
20  from xAODTruthCnv.xAODTruthCnvConfig import GEN_EVNT2xAODCfg
21  if "McEventCollection#GEN_EVENT" in flags.Input.TypedCollections:
22  acc.merge(GEN_EVNT2xAODCfg(flags,name="GEN_EVNT2xAOD",AODContainerName="GEN_EVENT"))
23  elif "McEventCollection#TruthEvent" in flags.Input.TypedCollections:
24  acc.merge(GEN_EVNT2xAODCfg(name="GEN_EVNT2xAOD",AODContainerName="TruthEvent"))
25  else:
26  raise RuntimeError("No recognised HepMC truth information found in the input")
27 
28  # Contents
29  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
30  TRUTH0SlimmingHelper = SlimmingHelper("TRUTH0SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
31  TRUTH0SlimmingHelper.AppendToDictionary = {'EventInfo':'xAOD::EventInfo','EventInfoAux':'xAOD::EventAuxInfo',
32  'TruthEvents':'xAOD::TruthEventContainer','TruthEventsAux':'xAOD::TruthEventAuxContainer',
33  'TruthVertices':'xAOD::TruthVertexContainer','TruthVerticesAux':'xAOD::TruthVertexAuxContainer',
34  'TruthParticles':'xAOD::TruthParticleContainer','TruthParticlesAux':'xAOD::TruthParticleAuxContainer'}
35 
36  TRUTH0SlimmingHelper.AllVariables = [ 'EventInfo',
37  'TruthEvents',
38  'TruthVertices',
39  'TruthParticles']
40 
41  # Create output stream
42  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
43  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
44  TRUTH0ItemList = TRUTH0SlimmingHelper.GetItemList()
45  acc.merge(OutputStreamCfg(flags, "DAOD_TRUTH0", ItemList=TRUTH0ItemList))
46  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_TRUTH0", createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
47 
48  return acc
python.TRUTH0.TRUTH0Cfg
def TRUTH0Cfg(flags)
Definition: TRUTH0.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
xAODTruthCnvConfig.GEN_EVNT2xAODCfg
def GEN_EVNT2xAODCfg(flags, name="GEN_EVNT2xAOD", **kwargs)
Definition: xAODTruthCnvConfig.py:5
python.xAODEventInfoCnvConfig.EventInfoCnvAlgCfg
def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
Definition: xAODEventInfoCnvConfig.py:11
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:216
SlimmingHelper
Definition: SlimmingHelper.py:1