Skip to content
Snippets Groups Projects

Explicitly load overlay copy algorithms inputs

Merged Tadej Novak requested to merge tadej/athena:overlay/copysg into master
1 file
+ 119
200
Compare changes
  • Side-by-side
  • Inline
"""Define methods to construct configured overlay copy algorithms
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
"""
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
@@ -12,97 +12,105 @@ def CopyCaloCalibrationHitContainerAlgCfg(flags, collectionName, name="CopyCaloC
acc = ComponentAccumulator()
kwargs.setdefault("collectionName", collectionName)
kwargs.setdefault("SignalInputKey",
flags.Overlay.SigPrefix + collectionName)
kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + collectionName)
kwargs.setdefault("OutputKey", collectionName)
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'CaloCalibrationHitContainer#{kwargs["SignalInputKey"]}']))
# Copy CaloCalibrationHitContainer
CopyCaloCalibrationHitContainer = CompFactory.CopyCaloCalibrationHitContainer
alg = CopyCaloCalibrationHitContainer(name + collectionName, **kwargs)
acc.addEventAlgo(alg)
acc.addEventAlgo(CompFactory.CopyCaloCalibrationHitContainer(name + collectionName, **kwargs))
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
"CaloCalibrationHitContainer#"
+ collectionName + "->" + flags.Overlay.SigPrefix + collectionName
f"CaloCalibrationHitContainer#{collectionName}->{flags.Overlay.SigPrefix}{collectionName}"
]))
# Output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
f"CaloCalibrationHitContainer#{collectionName}"
]))
# Add signal output
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
f"CaloCalibrationHitContainer#{flags.Overlay.SigPrefix}{collectionName}"
]))
return acc
def CopyInTimeAntiKt4JetTruthInfoCfg(flags, name="CopyInTimeAntiKt4JetTruthInfo", **kwargs):
"""Return a ComponentAccumulator for the in-time pile-up jets copying"""
def CopyJetTruthInfoAlgCfg(flags, name, **kwargs):
"""Return a ComponentAccumulator for the pile-up jets copying"""
acc = ComponentAccumulator()
kwargs.setdefault("BkgInputKey",
flags.Overlay.BkgPrefix + "InTimeAntiKt4TruthJets")
kwargs.setdefault("OutputKey", "InTimeAntiKt4TruthJets")
if "OutputKey" not in kwargs or "BkgInputKey" not in kwargs:
raise RuntimeError("'OutputKey' and 'BkgInputKey' need to be defined")
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'xAOD::JetContainer#{kwargs["BkgInputKey"]}']))
# Copy jets
CopyJetTruthInfo = CompFactory.CopyJetTruthInfo
alg = CopyJetTruthInfo(name, **kwargs)
acc.addEventAlgo(alg)
acc.addEventAlgo(CompFactory.CopyJetTruthInfo(name, **kwargs))
# Output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
f'xAOD::JetContainer#{kwargs["OutputKey"]}',
f'xAOD::AuxContainerBase!#{kwargs["OutputKey"]}Aux.-constituentLinks.-constituentWeights',
]))
return acc
def CopyInTimeAntiKt4JetTruthInfoCfg(flags, name="CopyInTimeAntiKt4JetTruthInfo", **kwargs):
"""Return a ComponentAccumulator for the in-time pile-up jets copying"""
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}InTimeAntiKt4TruthJets")
kwargs.setdefault("OutputKey", "InTimeAntiKt4TruthJets")
return CopyJetTruthInfoAlgCfg(flags, name, **kwargs)
def CopyOutOfTimeAntiKt4JetTruthInfoCfg(flags, name="CopyOutOfTimeAntiKt4JetTruthInfo", **kwargs):
"""Return a ComponentAccumulator for the out-of-time pile-up jets copying"""
acc = ComponentAccumulator()
kwargs.setdefault("BkgInputKey",
flags.Overlay.BkgPrefix + "OutOfTimeAntiKt4TruthJets")
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}OutOfTimeAntiKt4TruthJets")
kwargs.setdefault("OutputKey", "OutOfTimeAntiKt4TruthJets")
# Copy jets
CopyJetTruthInfo = CompFactory.CopyJetTruthInfo
alg = CopyJetTruthInfo(name, **kwargs)
acc.addEventAlgo(alg)
return acc
return CopyJetTruthInfoAlgCfg(flags, name, **kwargs)
def CopyInTimeAntiKt6JetTruthInfoCfg(flags, name="CopyInTimeAntiKt6JetTruthInfo", **kwargs):
"""Return a ComponentAccumulator for the in-time pile-up jets copying"""
acc = ComponentAccumulator()
kwargs.setdefault("BkgInputKey",
flags.Overlay.BkgPrefix + "InTimeAntiKt6TruthJets")
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}InTimeAntiKt6TruthJets")
kwargs.setdefault("OutputKey", "InTimeAntiKt6TruthJets")
# Copy jets
CopyJetTruthInfo = CompFactory.CopyJetTruthInfo
alg = CopyJetTruthInfo(name, **kwargs)
acc.addEventAlgo(alg)
return acc
return CopyJetTruthInfoAlgCfg(flags, name, **kwargs)
def CopyOutOfTimeAntiKt6JetTruthInfoCfg(flags, name="CopyOutOfTimeAntiKt6JetTruthInfo", **kwargs):
"""Return a ComponentAccumulator for the out-of-time pile-up jets copying"""
acc = ComponentAccumulator()
kwargs.setdefault("BkgInputKey",
flags.Overlay.BkgPrefix + "OutOfTimeAntiKt6TruthJets")
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}OutOfTimeAntiKt6TruthJets")
kwargs.setdefault("OutputKey", "OutOfTimeAntiKt6TruthJets")
# Copy jets
CopyJetTruthInfo = CompFactory.CopyJetTruthInfo
alg = CopyJetTruthInfo(name, **kwargs)
acc.addEventAlgo(alg)
return acc
return CopyJetTruthInfoAlgCfg(flags, name, **kwargs)
def CopyJetTruthInfoAlgsCfg(flags, **kwargs):
def CopyJetTruthInfoCfg(flags, **kwargs):
"""Return a ComponentAccumulator for the CopyJetTruthInfo algorithms"""
acc = ComponentAccumulator()
if flags.Overlay.DataOverlay:
return acc
allowedContainers = [
flags.Overlay.BkgPrefix + "InTimeAntiKt4TruthJets",
flags.Overlay.BkgPrefix + "OutOfTimeAntiKt4TruthJets",
flags.Overlay.BkgPrefix + "InTimeAntiKt6TruthJets",
flags.Overlay.BkgPrefix + "OutOfTimeAntiKt6TruthJets"
f"{flags.Overlay.BkgPrefix}InTimeAntiKt4TruthJets",
f"{flags.Overlay.BkgPrefix}OutOfTimeAntiKt4TruthJets",
f"{flags.Overlay.BkgPrefix}InTimeAntiKt6TruthJets",
f"{flags.Overlay.BkgPrefix}OutOfTimeAntiKt6TruthJets"
]
availableContainers = []
@@ -125,17 +133,18 @@ def CopyPileupParticleTruthInfoCfg(flags, name="CopyPileupParticleTruthInfo", **
"""Return a ComponentAccumulator for the in-time pile-up jets copying"""
acc = ComponentAccumulator()
requiredContainer = flags.Overlay.BkgPrefix + "TruthPileupParticles"
requiredContainer = f"{flags.Overlay.BkgPrefix}TruthPileupParticles"
# Detect the list of track record collections
if not flags.Overlay.DataOverlay and requiredContainer in flags.Input.Collections: # SecondaryCollections
kwargs.setdefault("BkgInputKey", requiredContainer)
kwargs.setdefault("OutputKey", "TruthPileupParticles")
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'xAOD::TruthParticleContainer#{kwargs["BkgInputKey"]}']))
# Copy jets
CopyPileupParticleTruthInfo = CompFactory.CopyPileupParticleTruthInfo
alg = CopyPileupParticleTruthInfo(name, **kwargs)
acc.addEventAlgo(alg)
acc.addEventAlgo(CompFactory.CopyPileupParticleTruthInfo(name, **kwargs))
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
@@ -146,179 +155,125 @@ def CopyPileupParticleTruthInfoCfg(flags, name="CopyPileupParticleTruthInfo", **
return acc
def CopyMcEventCollectionAlgCfg(flags, name="CopyMcEventCollection", **kwargs):
def CopyMcEventCollectionCfg(flags, name="CopyMcEventCollection", **kwargs):
"""Return a ComponentAccumulator for the CopyMcEventCollection algorithm"""
acc = ComponentAccumulator()
kwargs.setdefault("RemoveBkgHardScatterTruth", True)
inputs = []
if flags.Overlay.DataOverlay:
# Disable background for data overlay
kwargs.setdefault("BkgInputKey", "")
else:
kwargs.setdefault("BkgInputKey",
flags.Overlay.BkgPrefix + "TruthEvent")
kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + "TruthEvent")
kwargs.setdefault("BkgInputKey", f"{flags.Overlay.BkgPrefix}TruthEvent")
inputs.append(f'McEventCollection#{kwargs["BkgInputKey"]}')
kwargs.setdefault("SignalInputKey", f"{flags.Overlay.SigPrefix}TruthEvent")
inputs.append(f'McEventCollection#{kwargs["SignalInputKey"]}')
kwargs.setdefault("OutputKey", "TruthEvent")
# Merge and copy McEventCollection
CopyMcEventCollection = CompFactory.CopyMcEventCollection
alg = CopyMcEventCollection(name, **kwargs)
acc.addEventAlgo(alg)
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
"McEventCollection#TruthEvent->" + flags.Overlay.SigPrefix + "TruthEvent"
]))
return acc
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, inputs))
def CopyTimingsAlgCfg(flags, name="CopyTimings", **kwargs):
"""Return a ComponentAccumulator for the CopyTimings algorithm"""
acc = ComponentAccumulator()
# Disable background copying
kwargs.setdefault("BkgInputKey", "")
kwargs.setdefault("SignalInputKey",
flags.Overlay.SigPrefix + "EVNTtoHITS_timings")
kwargs.setdefault("OutputKey", "EVNTtoHITS_timings")
# Copy RecoTimingObj
CopyTimings = CompFactory.CopyTimings
alg = CopyTimings(name, **kwargs)
acc.addEventAlgo(alg)
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
"RecoTimingObj#EVNTtoHITS_timings->"
+ flags.Overlay.SigPrefix + "EVNTtoHITS_timings"
]))
return acc
def CopyTrackRecordCollectionAlgCfg(flags, collectionName, name="CopyTrackRecordCollection", **kwargs):
"""Return a ComponentAccumulator for the TrackRecordCollection copying"""
acc = ComponentAccumulator()
kwargs.setdefault("collectionName", collectionName)
kwargs.setdefault("SignalInputKey",
flags.Overlay.SigPrefix + collectionName)
kwargs.setdefault("OutputKey", collectionName)
# Copy TrackRecordCollection
CopyTrackRecordCollection = CompFactory.CopyTrackRecordCollection
alg = CopyTrackRecordCollection(name + collectionName, **kwargs)
acc.addEventAlgo(alg)
# Merge and copy McEventCollection
acc.addEventAlgo(CompFactory.CopyMcEventCollection(name, **kwargs))
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
"TrackRecordCollection#"
+ collectionName + "->" + flags.Overlay.SigPrefix + collectionName
f"McEventCollection#TruthEvent->{flags.Overlay.SigPrefix}TruthEvent"
]))
return acc
def CopyCaloCalibrationHitContainerOutputCfg(flags, collectionName, **kwargs):
"""Return CopyCaloCalibrationHitContainer output configuration"""
acc = ComponentAccumulator()
# Output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"CaloCalibrationHitContainer#" + collectionName
"McEventCollection#TruthEvent"
]))
# Add signal output
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
"CaloCalibrationHitContainer#" + flags.Overlay.SigPrefix + collectionName
f"McEventCollection#{flags.Overlay.SigPrefix}TruthEvent"
]))
return acc
def CopyJetTruthInfoOutputCfg(flags, **kwargs):
"""Return CopyTimings output configuration"""
def CopyTimingsCfg(flags, name="CopyTimings", **kwargs):
"""Return a ComponentAccumulator for the CopyTimings algorithm"""
acc = ComponentAccumulator()
if "EVNTtoHITS_timings" not in flags.Input.SecondaryCollections:
return acc
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"xAOD::JetContainer#InTimeAntiKt4TruthJets",
"xAOD::AuxContainerBase!#InTimeAntiKt4TruthJetsAux.-constituentLinks.-constituentWeights",
"xAOD::JetContainer#OutOfTimeAntiKt4TruthJets",
"xAOD::AuxContainerBase!#OutOfTimeAntiKt4TruthJetsAux.-constituentLinks.-constituentWeights",
"xAOD::JetContainer#InTimeAntiKt6TruthJets",
"xAOD::AuxContainerBase!#InTimeAntiKt6TruthJetsAux.-constituentLinks.-constituentWeights",
"xAOD::JetContainer#OutOfTimeAntiKt6TruthJets",
"xAOD::AuxContainerBase!#OutOfTimeAntiKt6TruthJetsAux.-constituentLinks.-constituentWeights"
]))
return acc
# Disable background copying
kwargs.setdefault("BkgInputKey", "")
kwargs.setdefault("SignalInputKey", f"{flags.Overlay.SigPrefix}EVNTtoHITS_timings")
kwargs.setdefault("OutputKey", "EVNTtoHITS_timings")
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'RecoTimingObj#{kwargs["SignalInputKey"]}']))
def CopyMcEventCollectionOutputCfg(flags, **kwargs):
"""Return CopyMcEventCollection output configuration"""
acc = ComponentAccumulator()
# Copy RecoTimingObj
acc.addEventAlgo(CompFactory.CopyTimings(name, **kwargs))
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
f"RecoTimingObj#EVNTtoHITS_timings->{flags.Overlay.SigPrefix}EVNTtoHITS_timings"
]))
# Output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"McEventCollection#TruthEvent"
"RecoTimingObj#EVNTtoHITS_timings"
]))
# Add signal output
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
"McEventCollection#" + flags.Overlay.SigPrefix + "TruthEvent"
f"RecoTimingObj#{flags.Overlay.SigPrefix}EVNTtoHITS_timings"
]))
return acc
def CopyTimingsOutputCfg(flags, **kwargs):
"""Return CopyTimings output configuration"""
def CopyTrackRecordCollectionAlgCfg(flags, collectionName, name="CopyTrackRecordCollection", **kwargs):
"""Return a ComponentAccumulator for the TrackRecordCollection copying"""
acc = ComponentAccumulator()
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"RecoTimingObj#EVNTtoHITS_timings"
]))
# Add signal output
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
"RecoTimingObj#" + flags.Overlay.SigPrefix + "EVNTtoHITS_timings"
]))
kwargs.setdefault("collectionName", collectionName)
kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + collectionName)
kwargs.setdefault("OutputKey", collectionName)
return acc
from SGComps.SGInputLoaderConfig import SGInputLoaderCfg
acc.merge(SGInputLoaderCfg(flags, [f'TrackRecordCollection#{kwargs["SignalInputKey"]}']))
# Copy TrackRecordCollection
acc.addEventAlgo(CompFactory.CopyTrackRecordCollection(name + collectionName, **kwargs))
def CopyTrackRecordCollectionOutputCfg(flags, collectionName, **kwargs):
"""Return CopyTrackRecordCollection output configuration"""
acc = ComponentAccumulator()
# Re-map signal address
from SGComps.AddressRemappingConfig import AddressRemappingCfg
acc.merge(AddressRemappingCfg([
f"TrackRecordCollection#{collectionName}->{flags.Overlay.SigPrefix}{collectionName}"
]))
# Output
if flags.Output.doWriteRDO:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[
"TrackRecordCollection#" + collectionName
f"TrackRecordCollection#{collectionName}"
]))
# Add signal output
if flags.Output.doWriteRDO_SGNL:
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
acc.merge(OutputStreamCfg(flags, "RDO_SGNL", ItemList=[
"TrackRecordCollection#" + flags.Overlay.SigPrefix + collectionName
f"TrackRecordCollection#{flags.Overlay.SigPrefix}{collectionName}"
]))
return acc
@@ -343,41 +298,7 @@ def CopyCaloCalibrationHitContainersCfg(flags, **kwargs):
availableContainers.append(container)
for container in availableContainers:
acc.merge(CopyCaloCalibrationHitContainerAlgCfg(
flags, container, **kwargs))
acc.merge(CopyCaloCalibrationHitContainerOutputCfg(
flags, container, **kwargs))
return acc
def CopyJetTruthInfoCfg(flags, **kwargs):
"""Return overlay configuration for the CopyJetTruthInfo algorithms"""
acc = ComponentAccumulator()
if flags.Overlay.DataOverlay:
return acc
acc.merge(CopyJetTruthInfoAlgsCfg(flags, **kwargs))
acc.merge(CopyJetTruthInfoOutputCfg(flags, **kwargs))
return acc
def CopyMcEventCollectionCfg(flags, **kwargs):
"""Return overlay configuration for the CopyMcEventCollection algorithm"""
acc = CopyMcEventCollectionAlgCfg(flags, **kwargs)
acc.merge(CopyMcEventCollectionOutputCfg(flags, **kwargs))
return acc
def CopyTimingsCfg(flags, **kwargs):
"""Return overlay configuration for the CopyTimings algorithm"""
acc = CopyTimingsAlgCfg(flags, **kwargs)
acc.merge(CopyTimingsOutputCfg(flags, **kwargs))
acc.merge(CopyCaloCalibrationHitContainerAlgCfg(flags, container, **kwargs))
return acc
@@ -402,7 +323,5 @@ def CopyTrackRecordCollectionsCfg(flags, **kwargs):
for container in availableContainers:
acc.merge(CopyTrackRecordCollectionAlgCfg(flags, container, **kwargs))
acc.merge(CopyTrackRecordCollectionOutputCfg(
flags, container, **kwargs))
return acc
Loading