From a139b650b0d514d17af9d7a1f0baa8c34f61fad9 Mon Sep 17 00:00:00 2001 From: Peter Sherwood <peter.sherwood@cern.ch> Date: Wed, 26 Oct 2022 15:56:15 +0200 Subject: [PATCH 1/2] JetMonitoring - for express stream jobs, check a trigger chain passes before monitoring it. JetMonitoringAlg.h add a flag to mark whether the code is being run as an express stream job JetMonitoringConfig.py set the expressStream job flag in JetMonitoringAlg JetMonitoringAlg.cxx declare the epressStream job flag property in initialize(), test whether the trigger chain name is set if the express stream job is set. in fillHistograms, return if the expressStream flag is set, but the trigger chain doe not pass python/TrigJetMonitorAlgorithm.py in l1JetMonitoringConfig(), test whether the jetcoll is a list of length one. If so set jetcoll to be the sole list entry. This was added after seeing that the jetcoll was being passed a list, rarther than a string in jetChainMonitoringConfig() add the transfer inputFlags.Common.doExpressProcessing to the JetMonAlgSpec dictionary --- .../JetMonitoring/JetMonitoringAlg.h | 1 + .../python/JetMonitoringConfig.py | 2 + .../JetMonitoring/src/JetMonitoringAlg.cxx | 19 ++++++++- .../python/TrigJetMonitorAlgorithm.py | 39 +++++++++++-------- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMonitoringAlg.h b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMonitoringAlg.h index 40f08ee25db4..5b4f8dbc91ca 100644 --- a/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMonitoringAlg.h +++ b/Reconstruction/Jet/JetMonitoring/JetMonitoring/JetMonitoringAlg.h @@ -41,6 +41,7 @@ private: bool m_failureOnMissingContainer; bool m_onlyPassingJets; bool m_eventFiresAnyJetChain; + bool m_isExpressStreamJob{false}; }; #endif diff --git a/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py b/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py index f892ef988b8e..4a9795854d86 100644 --- a/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py +++ b/Reconstruction/Jet/JetMonitoring/python/JetMonitoringConfig.py @@ -529,6 +529,7 @@ class JetMonAlgSpec(ConfigDict): args.setdefault('failureOnMissingContainer', True) args.setdefault('onlyPassingJets', True) args.setdefault('eventFiresAnyJetChain',False) + args.setdefault('isExpressStreamJob', False) ConfigDict.__init__(self, defaultPath=defaultPath, TriggerChain=TriggerChain, **args) tmpL = self.FillerTools self.FillerTools = [] @@ -546,6 +547,7 @@ class JetMonAlgSpec(ConfigDict): alg.FailureOnMissingContainer = self.failureOnMissingContainer alg.OnlyPassingJets = self.onlyPassingJets alg.EventFiresAnyJetChain = self.eventFiresAnyJetChain + alg.isExpressStreamJob = self.isExpressStreamJob path = self.defaultPath tools = [] diff --git a/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx b/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx index 4dbf3e80535a..8be0bbeee8c8 100644 --- a/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx +++ b/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx @@ -15,6 +15,7 @@ JetMonitoringAlg::JetMonitoringAlg( const std::string& name, ISvcLocator* pSvcLo declareProperty("FailureOnMissingContainer", m_failureOnMissingContainer); declareProperty("OnlyPassingJets", m_onlyPassingJets); declareProperty("EventFiresAnyJetChain", m_eventFiresAnyJetChain); + declareProperty("isExpressStreamJob", m_isExpressStreamJob); } @@ -32,7 +33,12 @@ StatusCode JetMonitoringAlg::initialize() { for(const auto& t: m_jetFillerTools){ ATH_MSG_INFO( "--> "<< t->name() ); } - + + if (m_triggerChainString.empty() and m_isExpressStreamJob) { + ATH_MSG_ERROR("Express stream job, but no trigger chain given"); + return StatusCode::FAILURE; + } + return AthMonitorAlgorithm::initialize(); } @@ -40,6 +46,17 @@ StatusCode JetMonitoringAlg::initialize() { StatusCode JetMonitoringAlg::fillHistograms( const EventContext& ctx ) const { + // if this code is being run in an express stream job, process only + // if the trigger chain paases the event. + // Note that, by the test in initialize(), the trigger chain name is + // provided for all express chain jobs. + + if (m_isExpressStreamJob) { + // bail out if the trigger chain does not pass in an express stream job + !(isPassedBits(m_triggerChainString) and TrigDefs::Express_passed); + return StatusCode::SUCCESS; + } + if (m_triggerChainString != "" && m_onlyPassingJets) { ATH_MSG_DEBUG("JetMonitoringAlg::fillHistograms(const EventContext&) -> enter triggerChainString = "<<m_triggerChainString); std::list<const xAOD::Jet*> tmpList; diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py index 404b515cca10..bb86d698f123 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py @@ -941,6 +941,9 @@ def jetMonitoringConfig(inputFlags,jetcoll,athenaMT): def l1JetMonitoringConfig(inputFlags,jetcoll,chain='',matched=False): from TrigJetMonitoring.L1JetMonitoringConfig import L1JetMonAlg + if isinstance(jetcoll, list): + assert len(jetcoll) == 1 + jetcoll = jetcoll[0] name = jetcoll if chain=='' else jetcoll+'_'+chain if not L1JetCollections[jetcoll]['MatchTo']: @@ -1001,25 +1004,27 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain,athenaMT,onlyUsePassingJet NjetHistName = 'njetsEt{}{}'.format(getThreshold(parts),getEtaRangeString(chain)) return NjetHistName - + trigConf = JetMonAlgSpec( # the usual JetMonAlgSpec - jetMonAlgSpecName, - JetContainerName = jetcoll, - TriggerChain = chain, - defaultPath = chainFolder, - topLevelDir="HLT/JetMon/Online/", - bottomLevelDir=jetcollFolder, - failureOnMissingContainer=True, - onlyPassingJets=onlyUsePassingJets, - ) + jetMonAlgSpecName, + JetContainerName = jetcoll, + TriggerChain = chain, + defaultPath = chainFolder, + topLevelDir="HLT/JetMon/Online/", + bottomLevelDir=jetcollFolder, + failureOnMissingContainer=True, + onlyPassingJets=onlyUsePassingJets, + isExpressStreamJob=inputFlags.Common.doExpressProcessing, + ) + trigConf.appendHistos( - "pt", - "m", - "eta", - "et", - "phi", - "phi_tight", - + "pt", + "m", + "eta", + "et", + "phi", + "phi_tight", + ) for hist in ExtraOnlineNJetHists: trigConf.appendHistos(EventHistoSpec(hist, (20,0,25), title=hist+';'+hist+';Entries')) # Add NjetEt and NjetPt histograms for simple scenarios -- GitLab From f53eeffc6869edc89e5e9461f31ffad6cd800484 Mon Sep 17 00:00:00 2001 From: Peter Sherwood <peter.sherwood@cern.ch> Date: Wed, 9 Nov 2022 11:17:01 +0100 Subject: [PATCH 2/2] More changes for chains monitoring in express stream jobs. This branch will be terminated as the C++ changes will go into the base class AthMonitorAlgorithm. JetMonitoringAlg.cxx add logic to check if the Algorithm is begin run as an express stream job. THIS CODE HAS A BUG - logical and, instead of bit test in fillHistograms() TrigJetMonitorAlgorithm.py configuration changes for express stream job test TrigL1FexJetMonitorAlgorithm start addition of express stream job tests in this class which derives from AthMonitorAlgorithm. --- .../Jet/JetMonitoring/src/JetMonitoringAlg.cxx | 3 ++- .../python/TrigJetMonitorAlgorithm.py | 18 +++++++++++++----- .../src/TrigL1FexJetMonitorAlgorithm.h | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx b/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx index 8be0bbeee8c8..5abf1dc4281d 100644 --- a/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx +++ b/Reconstruction/Jet/JetMonitoring/src/JetMonitoringAlg.cxx @@ -47,9 +47,10 @@ StatusCode JetMonitoringAlg::initialize() { StatusCode JetMonitoringAlg::fillHistograms( const EventContext& ctx ) const { // if this code is being run in an express stream job, process only - // if the trigger chain paases the event. + // if the trigger chain passes the event. // Note that, by the test in initialize(), the trigger chain name is // provided for all express chain jobs. + // if (m_isExpressStreamJob) { // bail out if the trigger chain does not pass in an express stream job diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py index bb86d698f123..7c8f8f39bb20 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitorAlgorithm.py @@ -721,7 +721,7 @@ def TrigJetMonConfig(inputFlags): # Basic selection of histograms common for online and offline jets -def basicJetMonAlgSpec(jetcoll,isOnline,athenaMT): +def basicJetMonAlgSpec(inputFlags, jetcoll,isOnline,athenaMT): # we use a specialized dictionnary (JetMonAlgSpec) which will be translated into the final C++ tool path = 'NoTriggerSelection' if isOnline else 'standardHistos/' minNjetBin = 1 if isOnline else 0 @@ -734,7 +734,14 @@ def basicJetMonAlgSpec(jetcoll,isOnline,athenaMT): jetcollFolder = jetcoll if jetcoll in JetCollRemapping.JetCollRun2ToRun3 and not athenaMT: jetcollFolder = JetCollRemapping.JetCollRun2ToRun3[jetcoll] - Conf = JetMonAlgSpec(jetcoll+"Mon",JetContainerName = jetcoll, defaultPath = path, topLevelDir=TopLevelDir, bottomLevelDir=jetcollFolder, failureOnMissingContainer=False) + Conf = JetMonAlgSpec(jetcoll+"Mon", + JetContainerName=jetcoll, + defaultPath=path, + topLevelDir=TopLevelDir, + bottomLevelDir=jetcollFolder, + failureOnMissingContainer=False, + isExpressStreamJob=inputFlags.Common.doExpressProcessing, + ) # Now start filling the histo spec list knownHistos['phi_tight'] = HistoSpec('phi_tight', @@ -813,7 +820,7 @@ def jetMonitoringConfig(inputFlags,jetcoll,athenaMT): isOnline = True if 'HLT' in jetcoll else False InputType = 'Legacy' if not athenaMT else 'MT' - conf = basicJetMonAlgSpec(jetcoll,isOnline,athenaMT) + conf = basicJetMonAlgSpec(inputFlags, jetcoll,isOnline,athenaMT) # Declare a configuration dictionnary for a JetContainer if isOnline: @@ -1014,7 +1021,8 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain,athenaMT,onlyUsePassingJet bottomLevelDir=jetcollFolder, failureOnMissingContainer=True, onlyPassingJets=onlyUsePassingJets, - isExpressStreamJob=inputFlags.Common.doExpressProcessing, + # isExpressStreamJob=inputFlags.Common.doExpressProcessing, + isExpressStreamJob=False ) trigConf.appendHistos( @@ -1057,7 +1065,7 @@ def jetChainMonitoringConfig(inputFlags,jetcoll,chain,athenaMT,onlyUsePassingJet return trigConf -def jetEfficiencyMonitoringConfig(inputFlags,onlinejetcoll,offlinejetcoll,chain,refChain,athenaMT): +def jetEfficiencyMonitoringConfig(inputFlags, onlinejetcoll, offlinejetcoll, chain, refChain,athenaMT): '''Function to configures some algorithms in the monitoring system.''' # Remap online Run 2 jet collections diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.h index 9945fb2f0c1f..3fdaa608d17d 100644 --- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.h +++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/TrigL1FexJetMonitorAlgorithm.h @@ -37,7 +37,8 @@ private: Gaudi::Property<std::string> m_groupName { this, "group_name", {}, "name of monitoring group"}; - + Gaudi::Property<bool> m_isExpressStreamJob { + this, "isExpressStreamJob", {false}, "true for express streamJobs"}; }; #endif -- GitLab