From 60ab9617e8f883736c0bc1dc4aee8b7d8a661e66 Mon Sep 17 00:00:00 2001 From: R D Schaffer <r.d.schaffer@cern.ch> Date: Wed, 26 Apr 2023 15:20:46 +0200 Subject: [PATCH] setting up flag to avoid d0 and z0 cut for PhysLite, default remains apply cut setting up flag to avoid d0 and z0 cut for PhysLite, default remains apply cut --- .../python/ElectronAnalysisConfig.py | 19 +++++++----- .../python/ElectronAnalysisSequence.py | 27 ++++++++++------- .../python/MuonAnalysisConfig.py | 20 +++++++------ .../python/MuonAnalysisSequence.py | 30 +++++++++++-------- .../python/PHYSLITE.py | 4 +-- 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py index 18ac43455246..30688d6a12a4 100644 --- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisConfig.py @@ -19,6 +19,8 @@ class ElectronCalibrationConfig (ConfigBlock) : self.addOption ('crackVeto', False, type=bool) self.addOption ('ptSelectionOutput', False, type=bool) self.addOption ('isolationCorrection', False, type=bool) + self.addOption ('trackSelection', True, type=bool) + def makeAlgs (self, config) : @@ -50,14 +52,15 @@ class ElectronCalibrationConfig (ConfigBlock) : bits=(5 if self.crackVeto else 4)) # Set up the track selection algorithm: - alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', - 'ElectronTrackSelectionAlg' + self.postfix ) - alg.selectionDecoration = 'trackSelection' + self.postfix + ',as_bits' - alg.maxD0Significance = 5 - alg.maxDeltaZ0SinTheta = 0.5 - alg.particles = config.readName (self.containerName) - alg.preselection = config.getPreselection (self.containerName, '') - config.addSelection (self.containerName, '', alg.selectionDecoration, + if self.trackSelection : + alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', + 'ElectronTrackSelectionAlg' + self.postfix ) + alg.selectionDecoration = 'trackSelection' + self.postfix + ',as_bits' + alg.maxD0Significance = 5 + alg.maxDeltaZ0SinTheta = 0.5 + alg.particles = config.readName (self.containerName) + alg.preselection = config.getPreselection (self.containerName, '') + config.addSelection (self.containerName, '', alg.selectionDecoration, bits=3) # Select electrons only with good object quality. diff --git a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py index 7058102a1a74..a25a71051bca 100644 --- a/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py +++ b/PhysicsAnalysis/Algorithms/EgammaAnalysisAlgorithms/python/ElectronAnalysisSequence.py @@ -19,6 +19,7 @@ def makeElectronAnalysisSequence( dataType, workingPoint, isolationCorrection = False, crackVeto = False, ptSelectionOutput = False, + trackSelection = True, enableCutflow = False, enableKinematicHistograms = False ): """Create an electron analysis algorithm sequence @@ -40,6 +41,7 @@ def makeElectronAnalysisSequence( dataType, workingPoint, crackVeto -- Whether or not to perform eta crack veto ptSelectionOutput -- Whether or not to apply pt selection when creating output containers. + trackSelection -- apply selection on tracks (d0, z0, siHits, etc.) enableCutflow -- Whether or not to dump the cutflow enableKinematicHistograms -- Whether or not to dump the kinematic histograms """ @@ -63,6 +65,7 @@ def makeElectronAnalysisSequence( dataType, workingPoint, makeElectronCalibrationSequence (seq, dataType, postfix=postfix, crackVeto = crackVeto, ptSelectionOutput = ptSelectionOutput, + trackSelection = trackSelection, isolationCorrection = isolationCorrection) makeElectronWorkingPointSequence (seq, dataType, workingPoint, postfix=postfix, recomputeLikelihood = recomputeLikelihood, @@ -83,6 +86,7 @@ def makeElectronAnalysisSequence( dataType, workingPoint, def makeElectronCalibrationSequence( seq, dataType, postfix = '', crackVeto = False, ptSelectionOutput = False, + trackSelection = False, isolationCorrection = False): """Create electron calibration analysis algorithms @@ -129,17 +133,18 @@ def makeElectronCalibrationSequence( seq, dataType, postfix = '', dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])} ) # Set up the track selection algorithm: - alg = createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', - 'ElectronTrackSelectionAlg' + postfix ) - alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits' - alg.maxD0Significance = 5 - alg.maxDeltaZ0SinTheta = 0.5 - seq.append( alg, inputPropName = 'particles', - stageName = 'selection', - metaConfig = {'selectionDecorNames' : [alg.selectionDecoration], - 'selectionDecorNamesOutput' : [alg.selectionDecoration], - 'selectionDecorCount' : [3]}, - dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])} ) + if trackSelection: + alg = createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', + 'ElectronTrackSelectionAlg' + postfix ) + alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits' + alg.maxD0Significance = 5 + alg.maxDeltaZ0SinTheta = 0.5 + seq.append( alg, inputPropName = 'particles', + stageName = 'selection', + metaConfig = {'selectionDecorNames' : [alg.selectionDecoration], + 'selectionDecorNamesOutput' : [alg.selectionDecoration], + 'selectionDecorCount' : [3]}, + dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])} ) # Select electrons only with good object quality. alg = createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronObjectQualityAlg' + postfix ) diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisConfig.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisConfig.py index f311ebbdef4a..b35a254a66aa 100644 --- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisConfig.py @@ -13,6 +13,7 @@ class MuonCalibrationConfig (ConfigBlock): self.containerName = containerName self.addOption ('postfix', "", type=str) self.addOption ('ptSelectionOutput', False, type=bool) + self.addOption ('trackSelection', True, type=bool) def makeAlgs (self, config) : @@ -39,15 +40,16 @@ class MuonCalibrationConfig (ConfigBlock): bits=2) # Set up the track selection algorithm: - alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', - 'MuonTrackSelectionAlg' + self.postfix ) - alg.selectionDecoration = 'trackSelection' + self.postfix + ',as_bits' - alg.maxD0Significance = 3 - alg.maxDeltaZ0SinTheta = 0.5 - alg.particles = config.readName (self.containerName) - alg.preselection = config.getPreselection (self.containerName, '') - config.addSelection (self.containerName, '', alg.selectionDecoration, - bits=3) + if self.trackSelection : + alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', + 'MuonTrackSelectionAlg' + self.postfix ) + alg.selectionDecoration = 'trackSelection' + self.postfix + ',as_bits' + alg.maxD0Significance = 3 + alg.maxDeltaZ0SinTheta = 0.5 + alg.particles = config.readName (self.containerName) + alg.preselection = config.getPreselection (self.containerName, '') + config.addSelection (self.containerName, '', alg.selectionDecoration, + bits=3) # Set up the muon calibration and smearing algorithm: alg = config.createAlgorithm( 'CP::MuonCalibrationAndSmearingAlg', diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py index 285710517128..b1421cddc989 100644 --- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py +++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisSequence.py @@ -11,6 +11,7 @@ def makeMuonAnalysisSequence( dataType, workingPoint, shallowViewOutput = True, postfix = '', ptSelectionOutput = False, + trackSelection = True, qualitySelectionOutput = True, enableCutflow = False, enableKinematicHistograms = False, @@ -30,6 +31,7 @@ def makeMuonAnalysisSequence( dataType, workingPoint, names are unique. ptSelectionOutput -- Whether or not to apply pt selection when creating output containers. + trackSelection -- apply selection on tracks (d0, z0, siHits, etc.) qualitySelectionOutput -- Whether or not to apply muon quality selection when creating output containers. enableCutflow -- Whether or not to dump the cutflow @@ -51,7 +53,8 @@ def makeMuonAnalysisSequence( dataType, workingPoint, seq.addMetaConfigDefault ("selectionDecorCount", []) makeMuonCalibrationSequence (seq, dataType, postfix=postfix, - ptSelectionOutput = ptSelectionOutput) + ptSelectionOutput = ptSelectionOutput, + trackSelection = trackSelection) makeMuonWorkingPointSequence (seq, dataType, workingPoint, postfix=postfix, qualitySelectionOutput = qualitySelectionOutput, isRun3Geo = isRun3Geo) makeSharedObjectSequence (seq, deepCopyOutput = deepCopyOutput, @@ -68,7 +71,7 @@ def makeMuonAnalysisSequence( dataType, workingPoint, def makeMuonCalibrationSequence( seq, dataType, - postfix = '', ptSelectionOutput = False): + postfix = '', ptSelectionOutput = False, trackSelection = False): """Create muon calibration analysis algorithms This makes all the algorithms that need to be run first befor @@ -108,17 +111,18 @@ def makeMuonCalibrationSequence( seq, dataType, dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])}) # Set up the track selection algorithm: - alg = createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', - 'MuonTrackSelectionAlg' + postfix ) - alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits' - alg.maxD0Significance = 3 - alg.maxDeltaZ0SinTheta = 0.5 - seq.append( alg, inputPropName = 'particles', - stageName = 'selection', - metaConfig = {'selectionDecorNames' : [alg.selectionDecoration], - 'selectionDecorNamesOutput' : [alg.selectionDecoration], - 'selectionDecorCount' : [3]}, - dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])}) + if trackSelection: + alg = createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg', + 'MuonTrackSelectionAlg' + postfix ) + alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits' + alg.maxD0Significance = 3 + alg.maxDeltaZ0SinTheta = 0.5 + seq.append( alg, inputPropName = 'particles', + stageName = 'selection', + metaConfig = {'selectionDecorNames' : [alg.selectionDecoration], + 'selectionDecorNamesOutput' : [alg.selectionDecoration], + 'selectionDecorCount' : [3]}, + dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNamesOutput"])}) # Set up the muon calibration and smearing algorithm: alg = createAlgorithm( 'CP::MuonCalibrationAndSmearingAlg', diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py index 4a8741e95c5e..bac75afc5d3c 100755 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PHYSLITE.py @@ -81,7 +81,7 @@ def PHYSLITEKernelCfg(ConfigFlags, name='PHYSLITEKernel', **kwargs): # Include, and then set up the electron analysis sequence: from EgammaAnalysisAlgorithms.ElectronAnalysisSequence import makeElectronAnalysisSequence - electronSequence = makeElectronAnalysisSequence( dataType, 'LooseLHElectron.NonIso', shallowViewOutput = False, deepCopyOutput = True ) + electronSequence = makeElectronAnalysisSequence( dataType, 'LooseLHElectron.NonIso', shallowViewOutput = False, deepCopyOutput = True, trackSelection = False ) electronSequence.configure( inputName = 'Electrons', outputName = 'AnalysisElectrons' ) for element in electronSequence.getGaudiConfig2Components(): @@ -100,7 +100,7 @@ def PHYSLITEKernelCfg(ConfigFlags, name='PHYSLITEKernel', **kwargs): isRun3Geo = False from AthenaConfiguration.Enums import LHCPeriod if ConfigFlags.GeoModel.Run >= LHCPeriod.Run3: isRun3Geo = True - muonSequence = makeMuonAnalysisSequence( dataType, shallowViewOutput = False, deepCopyOutput = True, workingPoint = 'Loose.NonIso', isRun3Geo = isRun3Geo) + muonSequence = makeMuonAnalysisSequence( dataType, shallowViewOutput = False, deepCopyOutput = True, workingPoint = 'Loose.NonIso', isRun3Geo = isRun3Geo, trackSelection = False) muonSequence.configure( inputName = 'Muons', outputName = 'AnalysisMuons' ) for element in muonSequence.getGaudiConfig2Components(): -- GitLab