Skip to content
Snippets Groups Projects
Commit 2679f401 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'PHYSLITE_GRL_24014' into 'main'

Implementation of GRL decoration of events for PHYSLITE derivation

See merge request atlas/athena!67951
parents 54915b41 16879dbd
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include <AsgTools/ToolHandle.h> #include <AsgTools/ToolHandle.h>
#include <AsgAnalysisInterfaces/IGoodRunsListSelectionTool.h> #include <AsgAnalysisInterfaces/IGoodRunsListSelectionTool.h>
#include <EventBookkeeperTools/FilterReporterParams.h> #include <EventBookkeeperTools/FilterReporterParams.h>
#include "AsgDataHandles/WriteDecorHandleKey.h"
#include <AsgTools/PropertyWrapper.h>
///Author: will buttinger ///Author: will buttinger
///To use this alg in your joboptions: ///To use this alg in your joboptions:
///masterseq = CfgMgr.AthSequencer("AthMasterSeq") ///masterseq = CfgMgr.AthSequencer("AthMasterSeq")
...@@ -26,9 +27,11 @@ class GRLSelectorAlg: public EL::AnaAlgorithm { ...@@ -26,9 +27,11 @@ class GRLSelectorAlg: public EL::AnaAlgorithm {
virtual StatusCode execute(); virtual StatusCode execute();
virtual StatusCode finalize(); virtual StatusCode finalize();
private: private:
SG::WriteDecorHandleKey<xAOD::EventInfo> m_grlKey {this, "grlKey", "EventInfo.decoratorName", "Decoration for GRL"};
ToolHandle<IGoodRunsListSelectionTool> m_grlTool; ToolHandle<IGoodRunsListSelectionTool> m_grlTool;
FilterReporterParams m_filterParams {this, "GoodRunsList", "Good Runs Lists selection"}; FilterReporterParams m_filterParams {this, "GoodRunsList", "Good Runs Lists selection"};
Gaudi::Property<bool> m_noFilter {this, "noFilter", false, "whether to not apply a GRL decoration"};
}; };
#endif //> !GOODRUNSLISTS_GRLSELECTORALG_H #endif //> !GOODRUNSLISTS_GRLSELECTORALG_H
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
#include <EventBookkeeperTools/FilterReporter.h> #include <EventBookkeeperTools/FilterReporter.h>
#include <GoodRunsLists/GRLSelectorAlg.h> #include <GoodRunsLists/GRLSelectorAlg.h>
#include <xAODEventInfo/EventInfo.h> #include <xAODEventInfo/EventInfo.h>
#include "AsgDataHandles/WriteDecorHandle.h"
GRLSelectorAlg::GRLSelectorAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AnaAlgorithm( name, pSvcLocator ) GRLSelectorAlg::GRLSelectorAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AnaAlgorithm( name, pSvcLocator )
, m_grlTool("GoodRunsListSelectionTool", this) , m_grlTool("GoodRunsListSelectionTool", this)
{ {
declareProperty( "Tool", m_grlTool , "The GoodRunsListSelectionTool" ); declareProperty( "Tool", m_grlTool, "The GoodRunsListSelectionTool" );
} }
...@@ -24,24 +25,28 @@ StatusCode GRLSelectorAlg::initialize() { ...@@ -24,24 +25,28 @@ StatusCode GRLSelectorAlg::initialize() {
//ATH_MSG_INFO ("Initializing " << name() << "..."); //ATH_MSG_INFO ("Initializing " << name() << "...");
ANA_CHECK( m_grlTool.retrieve() ); ANA_CHECK( m_grlTool.retrieve() );
ANA_CHECK( m_filterParams.initialize() ); ANA_CHECK( m_filterParams.initialize() );
ANA_CHECK( m_grlKey.initialize() );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
StatusCode GRLSelectorAlg::finalize() { StatusCode GRLSelectorAlg::finalize() {
// ATH_MSG_INFO ("Finalizing " << name() << "..."); //ATH_MSG_INFO ("Finalizing " << name() << "...");
ANA_MSG_INFO (m_filterParams.summary()); ANA_MSG_INFO (m_filterParams.summary());
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
StatusCode GRLSelectorAlg::execute() { StatusCode GRLSelectorAlg::execute() {
FilterReporter filter (m_filterParams, false); FilterReporter filter (m_filterParams, m_noFilter.value());
const xAOD::EventInfo* evtInfo = 0; const xAOD::EventInfo* evtInfo = 0;
ANA_CHECK( evtStore()->retrieve( evtInfo, "EventInfo" ) ); ANA_CHECK( evtStore()->retrieve( evtInfo, "EventInfo" ) );
if(!m_grlTool->passRunLB(*evtInfo)) return StatusCode::SUCCESS;
SG::WriteDecorHandle<xAOD::EventInfo,char> dec_isGRLDecorator(m_grlKey);
const bool isSelected = m_grlTool->passRunLB(*evtInfo);
dec_isGRLDecorator(*evtInfo) = isSelected;
if(!isSelected) return StatusCode::SUCCESS;
filter.setPassed (true); filter.setPassed (true);
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
......
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
def getGoodRunsLists():
GRLDict={}
## RUN 3
# 2023
GRLDict['GRL2023']= ['GoodRunsLists/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns.xml']
GRLDict['GRL2023_ignoreTRIG']= ['GoodRunsLists/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns_ignoreTRIG_JETCTPIN.xml']
GRLDict['GRL2023_ignoreTRIG_HLTmisconf']= ['GoodRunsLists/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns_ignoreTRIG_HLTmisconf.xml']
GRLDict['GRL2023_ignoreTRIG_HLTmisconf_JETCTPIN']= ['GoodRunsLists/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns_ignoreTRIG_HLTmisconf_JETCTPIN.xml']
# 2022
GRLDict['GRL2022'] = ['GoodRunsLists/data22_13p6TeV/20230207/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns.xml']
GRLDict['GRL2022_ignore_TRIGLAR'] = ['GoodRunsLists/data22_13p6TeV/20230207/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns_ignore_TRIGLAR.xml']
GRLDict['GRL2022_ignore_TRIGMUO_TRIGLAR'] = ['GoodRunsLists/data22_13p6TeV/20230207/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns_ignore_TRIGMUO_TRIGLAR.xml']
## RUN 2
# 2018
GRLDict['GRL2018_Triggerno17e33prim'] = ['GoodRunsLists/data18_13TeV/20190318/data18_13TeV.periodAllYear_DetStatus-v102-pro22-04_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml']
GRLDict['GRL2018_BjetHLT'] = ['GoodRunsLists/data18_13TeV/20200426/data18_13TeV.periodAllYear_DetStatus-v102-pro22-04_PHYS_StandardGRL_All_Good_25ns_BjetHLT.xml']
# 2017
GRLDict['GRL2017_Triggerno17e33prim'] = ['GoodRunsLists/data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml']
GRLDict['GRL2017_BjetHLT_Normal2017'] = ['GoodRunsLists/data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_BjetHLT_Normal2017.xml']
GRLDict['GRL2017_JetHLT_Normal2017'] = ['GoodRunsLists/data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_JetHLT_Normal2017.xml']
# 2016
GRLDict['GRL2016'] = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml']
GRLDict['GRL2016_ignore_TOROID_STATUS'] = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns_ignore_TOROID_STATUS.xml']
GRLDict['GRL2016_BjetHLT'] = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns_BjetHLT.xml']
GRLDict['GRL2016_BjetHLT_Tight'] = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns_BjetHLT_Tight.xml']
# 2015
GRLDict['GRL2015'] = ['GoodRunsLists/data15_13TeV/20170619/data15_13TeV.periodAllYear_DetStatus-v89-pro21-02_Unknown_PHYS_StandardGRL_All_Good_25ns.xml']
return GRLDict
...@@ -28,6 +28,9 @@ class EventCleaningBlock (ConfigBlock): ...@@ -28,6 +28,9 @@ class EventCleaningBlock (ConfigBlock):
self.addOption ('invertFlags', [0], type=None, self.addOption ('invertFlags', [0], type=None,
info="list of booleans determining whether to invert the cut of the " info="list of booleans determining whether to invert the cut of the "
"above selectionFlags. The default is [0].") "above selectionFlags. The default is [0].")
self.addOption ('GRLDict', {}, type=None)
self.addOption ('noFilter', False, type=bool,
info="do apply event decoration, but do not filter. The default is False, i.e. 'We decorate events but do not filter' ")
def getDefaultGRLs (self, data_year) : def getDefaultGRLs (self, data_year) :
""" returns a reasonable set of GRLs that should be suited for most analyses """ """ returns a reasonable set of GRLs that should be suited for most analyses """
...@@ -50,13 +53,24 @@ class EventCleaningBlock (ConfigBlock): ...@@ -50,13 +53,24 @@ class EventCleaningBlock (ConfigBlock):
def makeAlgs (self, config) : def makeAlgs (self, config) :
if config.dataType() is DataType.Data: if config.dataType() is DataType.Data:
# Set up the GRL selection: if self.noFilter:
alg = config.createAlgorithm( 'GRLSelectorAlg', 'GRLSelectorAlg' ) """ here we only decorate the PHYSLITE events with a boolean and don't do any cleaning"""
config.addPrivateTool( 'Tool', 'GoodRunsListSelectionTool' )
if self.userGRLFiles: # Set up the GRL Decoration
alg.Tool.GoodRunsListVec = self.userGRLFiles for GRLDecoratorName,GRLFile in (self.GRLDict).items():
alg = config.createAlgorithm( 'GRLSelectorAlg', GRLDecoratorName )
config.addPrivateTool( 'Tool', 'GoodRunsListSelectionTool' )
alg.Tool.GoodRunsListVec = GRLFile
alg.grlKey = "EventInfo." + GRLDecoratorName
# Using WriteDecorHandle thus no need for addOutputVar
else: else:
alg.Tool.GoodRunsListVec = self.getDefaultGRLs( config.dataYear() ) # Set up the GRL selection:
alg = config.createAlgorithm( 'GRLSelectorAlg', 'GRLSelectorAlg' )
config.addPrivateTool( 'Tool', 'GoodRunsListSelectionTool' )
if self.userGRLFiles:
alg.Tool.GoodRunsListVec = self.userGRLFiles
else:
alg.Tool.GoodRunsListVec = self.getDefaultGRLs( config.dataYear() )
# Skip events with no primary vertex: # Skip events with no primary vertex:
if self.runPrimaryVertexSelection: if self.runPrimaryVertexSelection:
...@@ -85,17 +99,24 @@ class EventCleaningBlock (ConfigBlock): ...@@ -85,17 +99,24 @@ class EventCleaningBlock (ConfigBlock):
def makeEventCleaningConfig( seq, def makeEventCleaningConfig( seq,
runPrimaryVertexSelection = None, runPrimaryVertexSelection = None,
runEventCleaning = None, runEventCleaning = None,
userGRLFiles = None): userGRLFiles = None,
GRLDict = None,
noFilter = None,
):
"""Create a basic event cleaning analysis algorithm sequence """Create a basic event cleaning analysis algorithm sequence
Keyword arguments: Keyword arguments:
runPrimaryVertexSelection -- whether to run primary vertex selection runPrimaryVertexSelection -- whether to run primary vertex selection
runEventCleaning -- wether to run event cleaning runEventCleaning -- wether to run event cleaning
userGRLFiles -- a list of GRL files to select data from userGRLFiles -- a list of GRL files to select data from
GRLDict -- a dictionary of GRL files to determine decoration names
noFilter -- wether to apply event decoration or not
""" """
config = EventCleaningBlock () config = EventCleaningBlock ()
config.setOptionValue ('runPrimaryVertexSelection', runPrimaryVertexSelection) config.setOptionValue ('runPrimaryVertexSelection', runPrimaryVertexSelection)
config.setOptionValue ('runEventCleaning', runEventCleaning) config.setOptionValue ('runEventCleaning', runEventCleaning)
config.setOptionValue ('userGRLFiles', userGRLFiles) config.setOptionValue ('userGRLFiles', userGRLFiles)
config.setOptionValue ('GRLDict', GRLDict)
config.setOptionValue ('noFilter', noFilter)
seq.append (config) seq.append (config)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaConfiguration.Enums import MetadataCategory from AthenaConfiguration.Enums import MetadataCategory
from GoodRunsLists.GoodRunsListsDictionary import getGoodRunsLists
...@@ -43,6 +44,11 @@ def CPAlgorithmsCfg(flags): ...@@ -43,6 +44,11 @@ def CPAlgorithmsCfg(flags):
# setup config and lumicalc files for pile-up tool # setup config and lumicalc files for pile-up tool
configSeq += factory.makeConfig ('PileupReweighting') configSeq += factory.makeConfig ('PileupReweighting')
# Set up the GRL decoration analysis config
configSeq += factory.makeConfig ('EventCleaning')
configSeq.setOptionValue ('.noFilter', True)
configSeq.setOptionValue ('.GRLDict', getGoodRunsLists())
# set up the muon analysis algorithm config (must come before electrons and photons to allow FSR collection): # set up the muon analysis algorithm config (must come before electrons and photons to allow FSR collection):
logPLCPAlgCfg.info('Do Muons') logPLCPAlgCfg.info('Do Muons')
...@@ -429,7 +435,7 @@ def PHYSLITECfg(flags): ...@@ -429,7 +435,7 @@ def PHYSLITECfg(flags):
'MET_Core_AnalysisMET.name.mpx.mpy.sumet.source', 'MET_Core_AnalysisMET.name.mpx.mpy.sumet.source',
'METAssoc_AnalysisMET.', 'METAssoc_AnalysisMET.',
'InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights.numberOfTRTHits.numberOfTRTOutliers', 'InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights.numberOfTRTHits.numberOfTRTOutliers',
'EventInfo.RandomRunNumber.PileupWeight_NOSYS.GenFiltHT.GenFiltMET.GenFiltHTinclNu.GenFiltPTZ.GenFiltFatJ.HF_Classification.HF_SimpleClassification', 'EventInfo.RandomRunNumber.PileupWeight_NOSYS.GenFiltHT.GenFiltMET.GenFiltHTinclNu.GenFiltPTZ.GenFiltFatJ.HF_Classification.HF_SimpleClassification.{GRL_Deco_names}'.format(GRL_Deco_names='.'.join(str(key) for key in (getGoodRunsLists()).keys())),
'Kt4EMPFlowEventShape.Density', 'Kt4EMPFlowEventShape.Density',
'TauTracks.pt.eta.phi.flagSet.trackLinks', 'TauTracks.pt.eta.phi.flagSet.trackLinks',
'AnalysisLargeRJets.pt.eta.phi.m.JetConstitScaleMomentum_pt.JetConstitScaleMomentum_eta.JetConstitScaleMomentum_phi.JetConstitScaleMomentum_m.DetectorEta.TrackSumMass.TrackSumPt.constituentLinks.ECF1.ECF2.ECF3.Tau1_wta.Tau2_wta.Tau3_wta.Split12.Split23.Qw.D2.C2.R10TruthLabel_R22v1.R10TruthLabel_R21Precision_2022v1.R10TruthLabel_R21Precision.GhostBHadronsFinalCount.GhostCHadronsFinalCount.Parent.GN2Xv01_phbb.GN2Xv01_phcc.GN2Xv01_ptop.GN2Xv01_pqcd', 'AnalysisLargeRJets.pt.eta.phi.m.JetConstitScaleMomentum_pt.JetConstitScaleMomentum_eta.JetConstitScaleMomentum_phi.JetConstitScaleMomentum_m.DetectorEta.TrackSumMass.TrackSumPt.constituentLinks.ECF1.ECF2.ECF3.Tau1_wta.Tau2_wta.Tau3_wta.Split12.Split23.Qw.D2.C2.R10TruthLabel_R22v1.R10TruthLabel_R21Precision_2022v1.R10TruthLabel_R21Precision.GhostBHadronsFinalCount.GhostCHadronsFinalCount.Parent.GN2Xv01_phbb.GN2Xv01_phcc.GN2Xv01_ptop.GN2Xv01_pqcd',
......
...@@ -30,9 +30,9 @@ references_map = { ...@@ -30,9 +30,9 @@ references_map = {
"q454": "v19", "q454": "v19",
# Derivations # Derivations
"data_PHYS_Run2": "v23", "data_PHYS_Run2": "v23",
"data_PHYSLITE_Run2": "v4", "data_PHYSLITE_Run2": "v5",
"data_PHYS_Run3": "v22", "data_PHYS_Run3": "v22",
"data_PHYSLITE_Run3": "v4", "data_PHYSLITE_Run3": "v5",
"mc_PHYS_Run2": "v27", "mc_PHYS_Run2": "v27",
"mc_PHYSLITE_Run2": "v5", "mc_PHYSLITE_Run2": "v5",
"mc_PHYS_Run3": "v28", "mc_PHYS_Run3": "v28",
......
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