Skip to content
Snippets Groups Projects
Commit e803e3dd authored by James Catmore's avatar James Catmore Committed by Tadej Novak
Browse files

Combining the thinning tools for PHYS and PHYSLITE into a single config

Draft: Combining the thinning tools for PHYS and PHYSLITE into a single config

ATLASG-2390

This MR combines the (currently separate) thinning requirements for PHYS and PHYSLITE into a common config script. This will help to keep them in synch, and simplifies the requirement that the config supports both AOD->PHYSLITE and PHYS->PHYSLITE workflows. It also reduces duplicated config code.
parent 115629ba
No related branches found
No related tags found
No related merge requests found
......@@ -20,89 +20,27 @@ def PHYSKernelCfg(ConfigFlags, name='PHYSKernel', **kwargs):
from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
acc.merge(PhysCommonAugmentationsCfg(ConfigFlags, TriggerListsHelper = kwargs['TriggerListsHelper']))
# Thinning tools...
from DerivationFrameworkInDet.InDetToolsConfig import TrackParticleThinningCfg, MuonTrackParticleThinningCfg, TauTrackParticleThinningCfg, DiTauTrackParticleThinningCfg, TauJetLepRMParticleThinningCfg
from DerivationFrameworkTools.DerivationFrameworkToolsConfig import GenericObjectThinningCfg
# Inner detector group recommendations for indet tracks in analysis
# https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations
PHYS_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV"
PHYSTrackParticleThinningTool = acc.getPrimaryAndMerge(TrackParticleThinningCfg(
ConfigFlags,
name = "PHYSTrackParticleThinningTool",
StreamName = kwargs['StreamName'],
SelectionString = PHYS_thinning_expression,
InDetTrackParticlesKey = "InDetTrackParticles"))
# Include inner detector tracks associated with muons
PHYSMuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSMuonTPThinningTool",
StreamName = kwargs['StreamName'],
MuonKey = "Muons",
InDetTrackParticlesKey = "InDetTrackParticles"))
# disable tau thinning for now
tau_thinning_expression = "(TauJets.ptFinalCalib >= 0)"
PHYSTauJetsThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(ConfigFlags,
name = "PHYSTauJetThinningTool",
StreamName = kwargs['StreamName'],
ContainerName = "TauJets",
SelectionString = tau_thinning_expression))
# Only keep tau tracks (and associated ID tracks) classified as charged tracks
PHYSTauTPThinningTool = acc.getPrimaryAndMerge(TauTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSTauTPThinningTool",
StreamName = kwargs['StreamName'],
TauKey = "TauJets",
InDetTrackParticlesKey = "InDetTrackParticles",
DoTauTracksThinning = True,
TauTracksKey = "TauTracks"))
tau_murm_thinning_expression = tau_thinning_expression.replace('TauJets', 'TauJets_MuonRM')
PHYSTauJetMuonRMParticleThinningTool = acc.getPrimaryAndMerge(TauJetLepRMParticleThinningCfg(
ConfigFlags,
name = "PHYSTauJets_MuonRMThinningTool",
StreamName = kwargs['StreamName'],
originalTauKey = "TauJets",
LepRMTauKey = "TauJets_MuonRM",
InDetTrackParticlesKey = "InDetTrackParticles",
TauTracksKey = "TauTracks_MuonRM",
SelectionString = tau_murm_thinning_expression))
# ID tracks associated with high-pt di-tau
PHYSDiTauTPThinningTool = acc.getPrimaryAndMerge(DiTauTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSDiTauTPThinningTool",
StreamName = kwargs['StreamName'],
DiTauKey = "DiTauJets",
InDetTrackParticlesKey = "InDetTrackParticles"))
## Low-pt di-tau thinning
PHYSDiTauLowPtThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(ConfigFlags,
name = "PHYSDiTauLowPtThinningTool",
StreamName = kwargs['StreamName'],
ContainerName = "DiTauJetsLowPt",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# ID tracks associated with low-pt ditau
PHYSDiTauLowPtTPThinningTool = acc.getPrimaryAndMerge(DiTauTrackParticleThinningCfg(ConfigFlags,
name = "PHYSDiTauLowPtTPThinningTool",
StreamName = kwargs['StreamName'],
DiTauKey = "DiTauJetsLowPt",
InDetTrackParticlesKey = "InDetTrackParticles",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# Finally the kernel itself
thinningTools = [PHYSTrackParticleThinningTool,
PHYSMuonTPThinningTool,
PHYSTauJetsThinningTool,
PHYSTauTPThinningTool,
PHYSTauJetMuonRMParticleThinningTool,
PHYSDiTauTPThinningTool,
PHYSDiTauLowPtThinningTool,
PHYSDiTauLowPtTPThinningTool ]
# Thinning tools
# These are set up in PhysCommonThinningConfig. Only thing needed here the list of tools to schedule
thinningToolsArgs = {
'TrackParticleThinningToolName' : "PHYSTrackParticleThinningTool",
'MuonTPThinningToolName' : "PHYSMuonTPThinningTool",
'TauJetThinningToolName' : "PHYSTauJetThinningTool",
'TauTPThinningToolName' : "PHYSTauTPThinningTool",
'TauJets_MuonRMThinningToolName' : "PHYSTauJets_MuonRMThinningTool",
'DiTauTPThinningToolName' : "PHYSDiTauTPThinningTool",
'DiTauLowPtThinningToolName' : "PHYSDiTauLowPtThinningTool",
'DiTauLowPtTPThinningToolName' : "PHYSDiTauLowPtTPThinningTool",
}
# Configure the thinning tools
from DerivationFrameworkPhys.PhysCommonThinningConfig import PhysCommonThinningCfg
acc.merge(PhysCommonThinningCfg(ConfigFlags, StreamName = kwargs['StreamName'], **thinningToolsArgs))
# Get them from the CA so they can be added to the kernel
thinningTools = []
for key in thinningToolsArgs:
thinningTools.append(acc.getPublicTool(thinningToolsArgs[key]))
# The kernel algorithm itself
DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
acc.addEventAlgo(DerivationKernel(name, ThinningTools = thinningTools))
return acc
......
......@@ -16,143 +16,43 @@ def PHYSLITEKernelCfg(ConfigFlags, name='PHYSLITEKernel', **kwargs):
"""Configure the derivation framework driving algorithm (kernel) for PHYSLITE"""
acc = ComponentAccumulator()
# This block does the common physics augmentation and thinning, which isn't needed (or possible) for PHYS->PHYSLITE
# This block does the common physics augmentation which isn't needed (or possible) for PHYS->PHYSLITE
# Ensure block only runs for AOD input
thinningTools = []
if 'StreamAOD' in ConfigFlags.Input.ProcessingTags:
# Common augmentations
from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
acc.merge(PhysCommonAugmentationsCfg(ConfigFlags, TriggerListsHelper = kwargs['TriggerListsHelper']))
# Thinning tools...
from DerivationFrameworkInDet.InDetToolsConfig import TrackParticleThinningCfg, MuonTrackParticleThinningCfg, TauTrackParticleThinningCfg, DiTauTrackParticleThinningCfg, TauJetLepRMParticleThinningCfg
from DerivationFrameworkTools.DerivationFrameworkToolsConfig import GenericObjectThinningCfg
from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import CaloClusterThinningCfg
# Inner detector group recommendations for indet tracks in analysis
# https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations
PHYSLITE_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV"
PHYSLITETrackParticleThinningTool = acc.getPrimaryAndMerge(TrackParticleThinningCfg(
ConfigFlags,
name = "PHYSLITETrackParticleThinningTool",
StreamName = kwargs['StreamName'],
SelectionString = PHYSLITE_thinning_expression,
InDetTrackParticlesKey = "InDetTrackParticles"))
# Include inner detector tracks associated with muons
PHYSLITEMuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSLITEMuonTPThinningTool",
StreamName = kwargs['StreamName'],
MuonKey = "Muons",
InDetTrackParticlesKey = "InDetTrackParticles"))
# disable tau thinning for now
tau_thinning_expression = "(TauJets.ptFinalCalib >= 0)"
PHYSLITETauJetsThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(ConfigFlags,
name = "PHYSLITETauJetThinningTool",
StreamName = kwargs['StreamName'],
ContainerName = "TauJets",
SelectionString = tau_thinning_expression))
# Only keep tau tracks (and associated ID tracks) classified as charged tracks
PHYSLITETauTPThinningTool = acc.getPrimaryAndMerge(TauTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSLITETauTPThinningTool",
StreamName = kwargs['StreamName'],
TauKey = "TauJets",
InDetTrackParticlesKey = "InDetTrackParticles",
DoTauTracksThinning = True,
TauTracksKey = "TauTracks"))
tau_murm_thinning_expression = tau_thinning_expression.replace('TauJets', 'TauJets_MuonRM')
PHYSLITETauJetMuonRMParticleThinningTool = acc.getPrimaryAndMerge(TauJetLepRMParticleThinningCfg(
ConfigFlags,
name = "PHYSLITETauJets_MuonRMThinningTool",
StreamName = kwargs['StreamName'],
originalTauKey = "TauJets",
LepRMTauKey = "TauJets_MuonRM",
InDetTrackParticlesKey = "InDetTrackParticles",
TauTracksKey = "TauTracks_MuonRM",
SelectionString = tau_murm_thinning_expression))
# ID tracks associated with high-pt di-tau
PHYSLITEDiTauTPThinningTool = acc.getPrimaryAndMerge(DiTauTrackParticleThinningCfg(
ConfigFlags,
name = "PHYSLITEDiTauTPThinningTool",
StreamName = kwargs['StreamName'],
DiTauKey = "DiTauJets",
InDetTrackParticlesKey = "InDetTrackParticles"))
## Low-pt di-tau thinning
PHYSLITEDiTauLowPtThinningTool = acc.getPrimaryAndMerge(GenericObjectThinningCfg(ConfigFlags,
name = "PHYSLITEDiTauLowPtThinningTool",
StreamName = kwargs['StreamName'],
ContainerName = "DiTauJetsLowPt",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# ID tracks associated with low-pt ditau
PHYSLITEDiTauLowPtTPThinningTool = acc.getPrimaryAndMerge(DiTauTrackParticleThinningCfg(ConfigFlags,
name = "PHYSLITEDiTauLowPtTPThinningTool",
StreamName = kwargs['StreamName'],
DiTauKey = "DiTauJetsLowPt",
InDetTrackParticlesKey = "InDetTrackParticles",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# keep calo clusters around electrons
PHYSLITEElectronCaloClusterThinningTool = acc.getPrimaryAndMerge(CaloClusterThinningCfg(
ConfigFlags,
name="PHYSLITEElectronCaloClusterThinningTool",
StreamName=kwargs['StreamName'],
SGKey="AnalysisElectrons",
CaloClCollectionSGKey="egammaClusters",
ConeSize=-1.0))
# keep calo clusters around photons
PHYSLITEPhotonCaloClusterThinningTool = acc.getPrimaryAndMerge(CaloClusterThinningCfg(
ConfigFlags,
name="PHYSLITEPhotonCaloClusterThinningTool",
StreamName=kwargs['StreamName'],
SGKey="AnalysisPhotons",
CaloClCollectionSGKey="egammaClusters",
ConeSize=-1.0))
# GSF tracks associated to electrons
PHYSLITEElectronGSFTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
name = 'PHYSLITEElectronGSFTPThinningTool',
StreamName = kwargs['StreamName'],
SGKey = 'AnalysisElectrons',
GSFTrackParticlesKey = 'GSFTrackParticles',
InDetTrackParticlesKey = '',
BestMatchOnly = True)
acc.addPublicTool(PHYSLITEElectronGSFTPThinningTool)
# GSF tracks associated to photons
PHYSLITEPhotonGSFTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
name = 'PHYSLITEPhotonGSFTPThinningTool',
StreamName = kwargs['StreamName'],
SGKey = 'AnalysisPhotons',
GSFTrackParticlesKey = 'GSFTrackParticles',
InDetTrackParticlesKey = '',
BestMatchOnly = True)
acc.addPublicTool(PHYSLITEPhotonGSFTPThinningTool)
# Collect the thinning tools
thinningTools = [PHYSLITETrackParticleThinningTool,
PHYSLITEMuonTPThinningTool,
PHYSLITETauJetsThinningTool,
PHYSLITETauTPThinningTool,
PHYSLITETauJetMuonRMParticleThinningTool,
PHYSLITEDiTauTPThinningTool,
PHYSLITEDiTauLowPtThinningTool,
PHYSLITEDiTauLowPtTPThinningTool,
PHYSLITEElectronCaloClusterThinningTool,
PHYSLITEPhotonCaloClusterThinningTool,
PHYSLITEElectronGSFTPThinningTool,
PHYSLITEPhotonGSFTPThinningTool ]
# Thinning tools
# These are set up in PhysCommonThinningConfig. Only thing needed here the list of tools to schedule
# This differs depending on whether the input is AOD or PHYS
# These are needed whatever the input since they are not applied in PHYS
thinningToolsArgs = {
'ElectronCaloClusterThinningToolName' : "PHYSLITEElectronCaloClusterThinningTool",
'PhotonCaloClusterThinningToolName' : "PHYSLITEPhotonCaloClusterThinningTool",
'ElectronGSFTPThinningToolName' : "PHYSLITEElectronGSFTPThinningTool",
'PhotonGSFTPThinningToolName' : "PHYSLITEPhotonGSFTPThinningTool"
}
# whereas these are only needed if the input is AOD since they are applied already in PHYS
if 'StreamAOD' in ConfigFlags.Input.ProcessingTags:
thinningToolsArgs.update({
'TrackParticleThinningToolName' : "PHYSLITETrackParticleThinningTool",
'MuonTPThinningToolName' : "PHYSLITEMuonTPThinningTool",
'TauJetThinningToolName' : "PHYSLITETauJetThinningTool",
'TauTPThinningToolName' : "PHYSLITETauTPThinningTool",
'TauJets_MuonRMThinningToolName' : "PHYSLITETauJets_MuonRMThinningTool",
'DiTauTPThinningToolName' : "PHYSLITEDiTauTPThinningTool",
'DiTauLowPtThinningToolName' : "PHYSLITEDiTauLowPtThinningTool",
'DiTauLowPtTPThinningToolName' : "PHYSLITEDiTauLowPtTPThinningTool",
})
# Configure the thinning tools
from DerivationFrameworkPhys.PhysCommonThinningConfig import PhysCommonThinningCfg
acc.merge(PhysCommonThinningCfg(ConfigFlags, StreamName = kwargs['StreamName'], **thinningToolsArgs))
# Get them from the CA so they can be added to the kernel
thinningTools = []
for key in thinningToolsArgs:
thinningTools.append(acc.getPublicTool(thinningToolsArgs[key]))
# End of block that should only be executed for AOD input
#==============================================================================
# Analysis-level variables
......@@ -268,8 +168,11 @@ def PHYSLITECfg(ConfigFlags):
from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
PHYSLITETriggerListsHelper = TriggerListsHelper()
# Set the stream name - varies depending on whether the input is AOD or DAOD_PHYS
streamName = 'StreamDAOD_PHYSLITE' if 'StreamAOD' in ConfigFlags.Input.ProcessingTags else 'StreamD2AOD_PHYSLITE'
# Common augmentations
acc.merge(PHYSLITEKernelCfg(ConfigFlags, name="PHYSLITEKernel", StreamName = 'StreamDAOD_PHYSLITE', TriggerListsHelper = PHYSLITETriggerListsHelper))
acc.merge(PHYSLITEKernelCfg(ConfigFlags, name="PHYSLITEKernel", StreamName = streamName, TriggerListsHelper = PHYSLITETriggerListsHelper))
# ============================
# Define contents of the format
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# PhysCommonThinningConfig
# Contains the configuration for the thinning for PHYS(LITE)
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
def PhysCommonThinningCfg(ConfigFlags, StreamName = "StreamDAOD_PHYS", **kwargs):
"""Configure the common augmentation"""
acc = ComponentAccumulator()
# Thinning tools...
from DerivationFrameworkInDet.InDetToolsConfig import TrackParticleThinningCfg, MuonTrackParticleThinningCfg, TauTrackParticleThinningCfg, DiTauTrackParticleThinningCfg, TauJetLepRMParticleThinningCfg
from DerivationFrameworkTools.DerivationFrameworkToolsConfig import GenericObjectThinningCfg
from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import CaloClusterThinningCfg
# Inner detector group recommendations for indet tracks in analysis
# https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations
if "TrackParticleThinningToolName" in kwargs:
tp_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV"
acc.merge(TrackParticleThinningCfg(
ConfigFlags,
name = kwargs['TrackParticleThinningToolName'],
StreamName = StreamName,
SelectionString = tp_thinning_expression,
InDetTrackParticlesKey = "InDetTrackParticles"))
# Include inner detector tracks associated with muons
if "MuonTPThinningToolName" in kwargs:
acc.merge(MuonTrackParticleThinningCfg(
ConfigFlags,
name = kwargs['MuonTPThinningToolName'],
StreamName = StreamName,
MuonKey = "Muons",
InDetTrackParticlesKey = "InDetTrackParticles"))
# disable tau thinning for now
if "TauJetThinningToolName" in kwargs:
tau_thinning_expression = "(TauJets.ptFinalCalib >= 0)"
acc.merge(GenericObjectThinningCfg(ConfigFlags,
name = kwargs['TauJetThinningToolName'],
StreamName = StreamName,
ContainerName = "TauJets",
SelectionString = tau_thinning_expression))
# Only keep tau tracks (and associated ID tracks) classified as charged tracks
if "TauTPThinningToolName" in kwargs:
acc.merge(TauTrackParticleThinningCfg(
ConfigFlags,
name = kwargs['TauTPThinningToolName'],
StreamName = StreamName,
TauKey = "TauJets",
InDetTrackParticlesKey = "InDetTrackParticles",
DoTauTracksThinning = True,
TauTracksKey = "TauTracks"))
if "TauJets_MuonRMThinningToolName" in kwargs:
tau_murm_thinning_expression = tau_thinning_expression.replace('TauJets', 'TauJets_MuonRM')
acc.merge(TauJetLepRMParticleThinningCfg(
ConfigFlags,
name = kwargs["TauJets_MuonRMThinningToolName"],
StreamName = StreamName,
originalTauKey = "TauJets",
LepRMTauKey = "TauJets_MuonRM",
InDetTrackParticlesKey = "InDetTrackParticles",
TauTracksKey = "TauTracks_MuonRM",
SelectionString = tau_murm_thinning_expression))
# ID tracks associated with high-pt di-tau
if "DiTauTPThinningToolName" in kwargs:
acc.merge(DiTauTrackParticleThinningCfg(
ConfigFlags,
name = kwargs['DiTauTPThinningToolName'],
StreamName = StreamName,
DiTauKey = "DiTauJets",
InDetTrackParticlesKey = "InDetTrackParticles"))
## Low-pt di-tau thinning
if "DiTauLowPtThinningToolName" in kwargs:
acc.merge(GenericObjectThinningCfg(
ConfigFlags,
name = kwargs['DiTauLowPtThinningToolName'],
StreamName = StreamName,
ContainerName = "DiTauJetsLowPt",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# ID tracks associated with low-pt ditau
if "DiTauLowPtTPThinningToolName" in kwargs:
acc.merge(DiTauTrackParticleThinningCfg(
ConfigFlags,
name = kwargs['DiTauLowPtTPThinningToolName'],
StreamName = StreamName,
DiTauKey = "DiTauJetsLowPt",
InDetTrackParticlesKey = "InDetTrackParticles",
SelectionString = "DiTauJetsLowPt.nSubjets > 1"))
# keep calo clusters around electrons
if "ElectronCaloClusterThinningToolName" in kwargs:
acc.merge(CaloClusterThinningCfg(
ConfigFlags,
name = kwargs['ElectronCaloClusterThinningToolName'],
StreamName = StreamName,
SGKey = "AnalysisElectrons",
CaloClCollectionSGKey = "egammaClusters",
ConeSize = -1.0))
# keep calo clusters around photons
if "PhotonCaloClusterThinningToolName" in kwargs:
acc.merge(CaloClusterThinningCfg(
ConfigFlags,
name = kwargs['PhotonCaloClusterThinningToolName'],
StreamName = StreamName,
SGKey = "AnalysisPhotons",
CaloClCollectionSGKey = "egammaClusters",
ConeSize=-1.0))
# GSF tracks associated to electrons
if "ElectronGSFTPThinningToolName" in kwargs:
ElectronGSFTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
name = kwargs['ElectronGSFTPThinningToolName'],
StreamName = StreamName,
SGKey = "AnalysisElectrons",
GSFTrackParticlesKey = "GSFTrackParticles",
InDetTrackParticlesKey = "",
BestMatchOnly = True)
acc.addPublicTool(ElectronGSFTPThinningTool)
# GSF tracks associated to photons
if "PhotonGSFTPThinningToolName" in kwargs:
PhotonGSFTPThinningTool = CompFactory.DerivationFramework.EgammaTrackParticleThinning(
name = kwargs['PhotonGSFTPThinningToolName'],
StreamName = StreamName,
SGKey = "AnalysisPhotons",
GSFTrackParticlesKey = "GSFTrackParticles",
InDetTrackParticlesKey = "",
BestMatchOnly = True)
acc.addPublicTool(PhotonGSFTPThinningTool)
return acc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment