Skip to content
Snippets Groups Projects
Commit 9dcfd732 authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'revert-11eb2884' into 'main'

Revert "Merge branch 'SelectionDecorationBlock' into 'main'"

See merge request !70168
parents d0dcf8f1 c7248280
No related branches found
No related tags found
No related merge requests found
......@@ -130,14 +130,6 @@ Trigger:
photons: 'AnaPhotons'
muons: 'AnaMuons'
SelectionDecoration:
containers:
- 'OutMuons'
- 'OutElectrons'
- 'OutPhotons'
- 'OutTauJets'
- 'OutJets'
# After configuring each container, many variables will be saved automatically.
Output:
treeName: 'analysis'
......
......@@ -102,14 +102,6 @@ Thinning:
outputName: 'OutTauJets'
selectionName: 'tight'
SelectionDecoration:
containers:
- 'OutMuons'
- 'OutElectrons'
- 'OutPhotons'
- 'OutTauJets'
- 'OutJets'
# After configuring each container, many variables will be saved automatically.
Output:
treeName: 'analysis'
......
......@@ -314,11 +314,6 @@ class ConfigFactory():
self.addAlgConfigBlock(algName="Thinning", alg=OutputThinningBlock,
defaults={'configName': 'Thinning'})
# selection decorations
from AsgAnalysisAlgorithms.AsgAnalysisConfig import SelectionDecorationBlock
self.addAlgConfigBlock(algName='SelectionDecoration',
alg=SelectionDecorationBlock)
# output
from AsgAnalysisAlgorithms.OutputAnalysisConfig import OutputAnalysisConfig
self.addAlgConfigBlock(algName="Output", alg=OutputAnalysisConfig,
......
......@@ -987,9 +987,6 @@ def makeSequenceBlocks (dataType, algSeq, forCompare, isPhyslite,
configSeq.setOptionValue ('.nReplicas', 2000 )
configSeq.setOptionValue ('.runOnMC', True )
configSeq += config.makeConfig ('SelectionDecoration', containers = [
'OutMuons', 'OutElectrons', 'OutPhotons', 'OutTauJets', 'OutJets'])
configSeq += config.makeConfig ('Output')
configSeq.setOptionValue ('.treeName', 'analysis')
configSeq.setOptionValue ('.vars', vars)
......
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# AnaAlgorithm import(s):
from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
......@@ -415,35 +415,6 @@ class PerEventSFBlock (ConfigBlock):
alg.scaleFactorOutputDecoration.split("_%SYS%")[0])
class SelectionDecorationBlock (ConfigBlock):
"""the ConfigBlock to add selection decoration to a container"""
def __init__ (self, containers) :
super (SelectionDecorationBlock, self).__init__ ()
self.containers = containers
self.addOption ('selectionFlagPrefix', 'select', type=str)
def makeAlgs(self, config):
for container in self.containers:
originContainerName = config.getOutputContainerOrigin(container)
selectionNames = config.getSelectionNames(originContainerName)
for selectionName in selectionNames:
# skip default selection
if selectionName == '':
continue
alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
f'SelectionDecoration_{originContainerName}_{selectionName}')
selectionDecoration = f'baselineSelection_{selectionName}_%SYS%'
alg.selectionDecoration = f'{selectionDecoration},as_char'
alg.particles = config.readName (originContainerName)
alg.preselection = config.getFullSelection (originContainerName,
selectionName)
config.addOutputVar(
originContainerName, selectionDecoration,
self.selectionFlagPrefix + '_' + selectionName)
def makeCommonServicesConfig( seq ):
"""Create the common services config"""
......
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# AnaAlgorithm import(s):
from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
......@@ -18,6 +18,8 @@ class OutputAnalysisConfig (ConfigBlock):
self.addOption ('containersOnlyForMC', [], type=None)
self.addOption ('treeName', 'analysis', type=str)
self.addOption ('metTermName', 'Final', type=str)
self.addOption ('storeSelectionFlags', True, type=bool)
self.addOption ('selectionFlagPrefix', 'select', type=str)
self.addOption ('commands', [], type=None,
info="a list of commands for branch selection/configuration")
......@@ -31,6 +33,9 @@ class OutputAnalysisConfig (ConfigBlock):
self.vars |= self.varsOnlyForMC
self.containers.update(self.containersOnlyForMC)
if self.storeSelectionFlags:
self.createSelectionFlagBranches(config)
outputConfigs = {}
for prefix in self.containers.keys() :
containerName = self.containers[prefix]
......@@ -111,3 +116,39 @@ class OutputAnalysisConfig (ConfigBlock):
treeFiller = config.createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' + postfix )
treeFiller.TreeName = self.treeName
def createSelectionFlagBranches(self, config):
"""
For each container and for each selection, create a single pass variable in output NTuple,
which aggregates all the selections flag of the given selection. For example, this can include
pT, eta selections, some object ID selection, overlap removal, etc.
The goal is to have only one flag per object and working point in the output NTuple.
"""
for prefix in self.containers.keys() :
outputContainerName = self.containers[prefix]
containerName = config.getOutputContainerOrigin(outputContainerName)
# EventInfo is one obvious example of a container that has no object selections
if containerName == 'EventInfo':
continue
selectionNames = config.getSelectionNames(containerName)
for selectionName in selectionNames:
# skip default selection
if selectionName == '':
continue
self.makeSelectionSummaryAlg(config, containerName, selectionName)
def makeSelectionSummaryAlg(self, config, containerName, selectionName):
"""
Schedule an algorithm to pick up all cut flags for a given selectionName.
The summary selection flag is written to output as selectionFlagPrefix_selectionName.
"""
alg = config.createAlgorithm( 'CP::AsgSelectionAlg',
f'ObjectSelectionSummary_{containerName}_{selectionName}')
selectionDecoration = f'baselineSelection_{selectionName}_%SYS%'
alg.selectionDecoration = f'{selectionDecoration},as_char'
alg.particles = config.readName (containerName)
alg.preselection = config.getFullSelection (containerName, selectionName)
config.addOutputVar (containerName, selectionDecoration, self.selectionFlagPrefix + '_' + selectionName)
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