From e355f21d36c73b01e3e1a286c7da202048600602 Mon Sep 17 00:00:00 2001 From: Marino Missiroli Date: Fri, 12 Aug 2022 11:00:20 +0200 Subject: [PATCH] allow TriggerResultsFilter to throw for invalid HLTPathStatus patterns --- .../HLTcore/src/TriggerExpressionData.cc | 5 + .../plugins/TriggerResultsFilter.cc | 69 ++++--- .../HLTfilters/plugins/TriggerResultsFilter.h | 14 +- .../triggerResultsFilter_by_PathStatus.py | 170 +++++++---------- .../triggerResultsFilter_by_TriggerResults.py | 177 +++++++----------- .../test/triggerResultsFilter_producer.py | 24 ++- 6 files changed, 216 insertions(+), 243 deletions(-) diff --git a/HLTrigger/HLTcore/src/TriggerExpressionData.cc b/HLTrigger/HLTcore/src/TriggerExpressionData.cc index 7311b22408a24..5eb5255cd1649 100644 --- a/HLTrigger/HLTcore/src/TriggerExpressionData.cc +++ b/HLTrigger/HLTcore/src/TriggerExpressionData.cc @@ -48,11 +48,16 @@ namespace triggerExpression { if (usePathStatus()) { m_pathStatus.clear(); std::vector triggerNames; + m_pathStatus.reserve(m_pathStatusTokens.size()); + triggerNames.reserve(m_pathStatusTokens.size()); for (auto const& p : m_pathStatusTokens) { auto const& handle = event.getHandle(p.second); if (handle.isValid()) { m_pathStatus.push_back(handle->accept()); triggerNames.push_back(p.first); + } else { + edm::LogError("MissingHLTPathStatus") + << "invalid handle for requested edm::HLTPathStatus with label \"" << p.first << "\""; } } m_hltUpdated = m_triggerNames != triggerNames; diff --git a/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.cc b/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.cc index 67bb975adc593..a87bc56c4e0a1 100644 --- a/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.cc +++ b/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.cc @@ -10,17 +10,15 @@ #include #include #include -#include -#include -#include +#include -#include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/TriggerResults.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/RegexMatch.h" +#include "FWCore/Utilities/interface/transform.h" #include "HLTrigger/HLTcore/interface/TriggerExpressionEvaluator.h" #include "HLTrigger/HLTcore/interface/TriggerExpressionParser.h" @@ -34,30 +32,52 @@ TriggerResultsFilter::TriggerResultsFilter(const edm::ParameterSet& config) std::vector const& expressions = config.getParameter>("triggerConditions"); parse(expressions); if (m_expression and m_eventCache.usePathStatus()) { - // if the expression was succesfully parsed, join all the patterns corresponding - // to the CMSSW paths in the logical expression into a single regex - std::vector patterns = m_expression->patterns(); - if (patterns.empty()) { + // if the expression was successfully parsed, store the list of patterns, + // each in both std::string and std::regex format + // and with a flag for having valid matches + hltPathStatusPatterns_ = edm::vector_transform(m_expression->patterns(), [](std::string const& pattern) { + return PatternData(pattern, std::regex(edm::glob2reg(pattern), std::regex::extended)); + }); + + if (hltPathStatusPatterns_.empty()) { return; } - std::string str; - for (auto const& pattern : patterns) { - str += edm::glob2reg(pattern); - str += '|'; - } - str.pop_back(); - std::regex regex(str, std::regex::extended); // consume all matching paths - callWhenNewProductsRegistered([this, regex](edm::BranchDescription const& branch) { - if (branch.branchType() == edm::InEvent and branch.className() == "edm::HLTPathStatus" and - std::regex_match(branch.moduleLabel(), regex)) { - m_eventCache.setPathStatusToken(branch, consumesCollector()); + callWhenNewProductsRegistered([this](edm::BranchDescription const& branch) { + if (branch.branchType() == edm::InEvent and branch.className() == "edm::HLTPathStatus") { + bool consumeBranch = true; + for (auto& pattern : hltPathStatusPatterns_) { + if (std::regex_match(branch.moduleLabel(), pattern.regex)) { + pattern.matched = true; + if (consumeBranch) { + consumeBranch = false; + m_eventCache.setPathStatusToken(branch, consumesCollector()); + } + } + } } }); } } +void TriggerResultsFilter::beginStream(edm::StreamID) { + // if throw=True, check if any of the input patterns had zero matches (and if so, throw an exception) + if (not hltPathStatusPatterns_.empty() and m_eventCache.shouldThrow()) { + auto unmatchedPatternsExist = std::any_of( + hltPathStatusPatterns_.cbegin(), hltPathStatusPatterns_.cend(), [](auto foo) { return (not foo.matched); }); + if (unmatchedPatternsExist) { + cms::Exception excpt("UnmatchedPatterns"); + excpt << "the parameter \"triggerConditions\" contains patterns with zero matches" + << " for the available edm::HLTPathStatus collections - invalid patterns are:"; + for (auto const& pattern : hltPathStatusPatterns_) + if (not pattern.matched) + excpt << "\n\t" << pattern.str; + throw excpt; + } + } +} + void TriggerResultsFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; // # use HLTPathStatus results @@ -107,8 +127,13 @@ void TriggerResultsFilter::parse(const std::string& expression) { m_expression.reset(triggerExpression::parse(expression)); // check if the expressions were parsed correctly - if (not m_expression) - edm::LogWarning("Configuration") << "Couldn't parse trigger results expression \"" << expression << "\""; + if (not m_expression) { + if (m_eventCache.shouldThrow()) { + throw cms::Exception("Configuration") << "Couldn't parse trigger-results expression \"" << expression << "\""; + } else { + edm::LogWarning("Configuration") << "Couldn't parse trigger-results expression \"" << expression << "\""; + } + } } bool TriggerResultsFilter::filter(edm::Event& event, const edm::EventSetup& setup) { diff --git a/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.h b/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.h index 2275ca79a3530..0a78f60824653 100644 --- a/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.h +++ b/HLTrigger/HLTfilters/plugins/TriggerResultsFilter.h @@ -17,12 +17,12 @@ #include #include #include +#include #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h" // forward declaration @@ -45,6 +45,8 @@ class TriggerResultsFilter : public edm::stream::EDFilter<> { bool filter(edm::Event &, const edm::EventSetup &) override; private: + void beginStream(edm::StreamID) override; + /// parse the logical expression into functionals void parse(const std::string &expression); void parse(const std::vector &expressions); @@ -54,6 +56,16 @@ class TriggerResultsFilter : public edm::stream::EDFilter<> { /// cache some data from the Event for faster access by the m_expression triggerExpression::Data m_eventCache; + + struct PatternData { + PatternData(std::string const &aStr, std::regex const &aRegex, bool const hasMatch = false) + : str(aStr), regex(aRegex), matched(hasMatch) {} + std::string str; + std::regex regex; + bool matched; + }; + + std::vector hltPathStatusPatterns_; }; #endif //TriggerResultsFilter_h diff --git a/HLTrigger/HLTfilters/test/triggerResultsFilter_by_PathStatus.py b/HLTrigger/HLTfilters/test/triggerResultsFilter_by_PathStatus.py index 30c2b14397153..2085db39d2bc9 100644 --- a/HLTrigger/HLTfilters/test/triggerResultsFilter_by_PathStatus.py +++ b/HLTrigger/HLTfilters/test/triggerResultsFilter_by_PathStatus.py @@ -5,6 +5,14 @@ process.options.wantSummary = True process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.FwkReport.reportEvery = 100 # only report every 100th event start +process.MessageLogger.cerr.enableStatistics = False # enable "MessageLogger Summary" message +process.MessageLogger.cerr.threshold = 'INFO' # change to 'WARNING' not to show INFO-level messages +## enable reporting of INFO-level messages (default is limit=0, i.e. no messages reported) +#process.MessageLogger.cerr.INFO = cms.untracked.PSet( +# reportEvery = cms.untracked.int32(1), # every event! +# limit = cms.untracked.int32(-1) # no limit! +#) # define the Prescaler service, and set the scale factors process.PrescaleService = cms.Service('PrescaleService', @@ -26,17 +34,9 @@ lvl1DefaultLabel = cms.string('any') ) -# load conditions from the global tag -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - -# define an empty source, and ask for 100 events +# define an empty source, and ask for 1000 events process.source = cms.Source('EmptySource') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000) -) +process.maxEvents.input = 1000 # define 3 prescalers, one per path process.scale_1 = cms.EDFilter('HLTPrescaler') @@ -54,168 +54,132 @@ process.AlwaysFALSE = cms.Path(process.fail) # define the TriggerResultsFilters based on the status of the previous paths -from HLTrigger.HLTfilters.triggerResultsFilter_cfi import triggerResultsFilter as _triggerResultsFilter -triggerResultsFilter = _triggerResultsFilter.clone( usePathStatus = True ) +from HLTrigger.HLTfilters.triggerResultsFilter_cfi import triggerResultsFilter as _trigResFilter +_triggerResultsFilter = _trigResFilter.clone( + usePathStatus = True, + hltResults = '', + l1tResults = '' +) # accept if 'Path_1' succeeds -process.filter_1 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1', ), - l1tResults = '', - throw = False +process.filter_1 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1', ) ) # accept if 'Path_2' succeeds -process.filter_2 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_2', ), - l1tResults = '', - throw = False +process.filter_2 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_2', ) ) # accept if 'Path_3' succeeds -process.filter_3 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_3', ), - l1tResults = '', - throw = False +process.filter_3 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_3', ) ) # accept if any path succeeds (explicit OR) -process.filter_any_or = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1', 'Path_2', 'Path_3' ), - l1tResults = '', - throw = False +process.filter_any_or = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1', 'Path_2', 'Path_3' ) ) # accept if 'Path_1' succeeds, prescaled by 15 -process.filter_1_pre = triggerResultsFilter.clone( - triggerConditions = ( '(Path_1) / 15', ), - l1tResults = '', - throw = False +process.filter_1_pre = _triggerResultsFilter.clone( + triggerConditions = ( '(Path_1) / 15', ) ) # accept if 'Path_1' prescaled by 15 does not succeed -process.filter_not_1_pre = triggerResultsFilter.clone( - triggerConditions = ( 'NOT (Path_1 / 15)', ), - l1tResults = '', - throw = False +process.filter_not_1_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT (Path_1 / 15)', ) ) # accept if 'Path_2' succeeds, prescaled by 10 -process.filter_2_pre = triggerResultsFilter.clone( - triggerConditions = ( '(Path_2 / 10)', ), - l1tResults = '', - throw = False +process.filter_2_pre = _triggerResultsFilter.clone( + triggerConditions = ( '(Path_2 / 10)', ) ) # accept if any path succeeds, with different prescales (explicit OR, prescaled) -process.filter_any_pre = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1 / 15', 'Path_2 / 10', 'Path_3 / 6', ), - l1tResults = '', - throw = False +process.filter_any_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1 / 15', 'Path_2 / 10', 'Path_3 / 6', ) ) # equivalent of filter_any_pre using NOT operator twice -process.filter_any_pre_doubleNOT = triggerResultsFilter.clone( - triggerConditions = ( 'NOT NOT (Path_1 / 15 OR Path_2 / 10 OR Path_3 / 6)', ), - l1tResults = '', - throw = False +process.filter_any_pre_doubleNOT = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT NOT (Path_1 / 15 OR Path_2 / 10 OR Path_3 / 6)', ) ) # opposite of filter_any_pre without whitespaces where possible -process.filter_not_any_pre = triggerResultsFilter.clone( - triggerConditions = ( 'NOT(Path_1/15)AND(NOT Path_2/10)AND(NOT Path_3/6)', ), - l1tResults = '', - throw = False +process.filter_not_any_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT(Path_1/15)AND(NOT Path_2/10)AND(NOT Path_3/6)', ) ) # accept if any path succeeds (wildcard, '*') -process.filter_any_star = triggerResultsFilter.clone( - triggerConditions = ( 'Path_*', ), - l1tResults = '', - throw = False +process.filter_any_star = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_*', ) ) # accept if any path succeeds (wildcard, '?') -process.filter_any_question = triggerResultsFilter.clone( - triggerConditions = ( 'Path_?', ), - l1tResults = '', - throw = False +process.filter_any_question = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_?', ) ) # accept if any path succeeds (double wildcard, '*_?') -process.filter_any_starquestion = triggerResultsFilter.clone( - triggerConditions = ( '*_?', ), - l1tResults = '', - throw = False +process.filter_any_starquestion = _triggerResultsFilter.clone( + triggerConditions = ( '*_?', ) ) # accept if all path succeed (explicit AND) -process.filter_all_explicit = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1 AND Path_2 AND Path_3', ), - l1tResults = '', - throw = False +process.filter_all_explicit = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1 AND Path_2 AND Path_3', ) ) # wrong path name (explicit) -process.filter_wrong_name = triggerResultsFilter.clone( +process.filter_wrong_name = _triggerResultsFilter.clone( triggerConditions = ( 'Wrong', ), - l1tResults = '', - throw = False + throw = False # do not throw, and return False for every event ) # wrong path name (wildcard) -process.filter_wrong_pattern = triggerResultsFilter.clone( +process.filter_wrong_pattern = _triggerResultsFilter.clone( triggerConditions = ( '*_Wrong', ), - l1tResults = '', - throw = False + throw = False # do not throw, and return False for every event ) # empty path list -process.filter_empty_pattern = triggerResultsFilter.clone( - triggerConditions = ( ), - l1tResults = '', - throw = False +process.filter_empty_pattern = _triggerResultsFilter.clone( + triggerConditions = ( ) ) # L1-like path name -process.filter_l1path_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'L1_Path', ), - l1tResults = '', - throw = False +process.filter_l1path_pattern = _triggerResultsFilter.clone( + # if usePathStatus=True, this returns False for every event without throwing exceptions, + # because patterns starting with "L1_" are used exclusively to check the L1-Trigger decisions + triggerConditions = ( 'L1_Path', ) ) # real L1 trigger -process.filter_l1singlemuopen_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'L1_SingleMuOpen', ), - l1tResults = '', - throw = False +process.filter_l1singlemuopen_pattern = _triggerResultsFilter.clone( + # if usePathStatus=True, this returns False for every event without throwing exceptions, + # because patterns starting with "L1_" are used exclusively to check the L1-Trigger decisions + triggerConditions = ( 'L1_SingleMuOpen', ) ) # TRUE -process.filter_true_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'TRUE', ), - l1tResults = '', - throw = False +process.filter_true_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'TRUE', ) ) # FALSE -process.filter_false_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'FALSE', ), - l1tResults = '', - throw = False +process.filter_false_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'FALSE', ) ) # Path name containing special keyword NOT -process.filter_AlwaysNOTFalse_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'AlwaysNOTFalse', ), - l1tResults = '', - throw = False +process.filter_AlwaysNOTFalse_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'AlwaysNOTFalse', ) ) # Path name containing special keyword FALSE -process.filter_NOTAlwaysFALSE_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'NOT AlwaysFALSE', ), - l1tResults = '', - throw = False +process.filter_NOTAlwaysFALSE_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT AlwaysFALSE', ) ) @@ -250,6 +214,6 @@ # define an EndPath to analyze all other path results process.hltTrigReport = cms.EDAnalyzer( 'HLTrigReport', - HLTriggerResults = cms.InputTag( 'TriggerResults', '', 'HLT' ) + HLTriggerResults = cms.InputTag( 'TriggerResults', '', '@currentProcess' ) ) process.HLTAnalyzerEndpath = cms.EndPath( process.hltTrigReport ) diff --git a/HLTrigger/HLTfilters/test/triggerResultsFilter_by_TriggerResults.py b/HLTrigger/HLTfilters/test/triggerResultsFilter_by_TriggerResults.py index fb1019764582a..de019f1825cac 100644 --- a/HLTrigger/HLTfilters/test/triggerResultsFilter_by_TriggerResults.py +++ b/HLTrigger/HLTfilters/test/triggerResultsFilter_by_TriggerResults.py @@ -2,174 +2,137 @@ process = cms.Process('TEST') -process.options = cms.untracked.PSet( - wantSummary = cms.untracked.bool(True) -) +process.options.wantSummary = True + process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.FwkReport.reportEvery = 100 # only report every 100th event start +process.MessageLogger.cerr.enableStatistics = False # enable "MessageLogger Summary" message +process.MessageLogger.cerr.threshold = 'INFO' # change to 'WARNING' not to show INFO-level messages +## enable reporting of INFO-level messages (default is limit=0, i.e. no messages reported) #process.MessageLogger.cerr.INFO = cms.untracked.PSet( -# reportEvery = cms.untracked.int32(1), # every! +# reportEvery = cms.untracked.int32(1), # every event! # limit = cms.untracked.int32(-1) # no limit! -# ) -#process.MessageLogger.cerr.FwkReport.reportEvery = 10 # only report every 10th event start -#process.MessageLogger.cerr_stats.threshold = 'INFO' # also info in statistics - -# load conditions from the global tag -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') +#) # read back the trigger decisions process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring('file:trigger.root') ) -from HLTrigger.HLTfilters.triggerResultsFilter_cfi import triggerResultsFilter +from HLTrigger.HLTfilters.triggerResultsFilter_cfi import triggerResultsFilter as _trigResFilter +_triggerResultsFilter = _trigResFilter.clone( l1tResults = '' ) # accept if 'Path_1' succeeds -process.filter_1 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1', ), - l1tResults = '', - throw = False - ) +process.filter_1 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1', ) +) # accept if 'Path_2' succeeds -process.filter_2 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_2', ), - l1tResults = '', - throw = False - ) +process.filter_2 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_2', ) +) # accept if 'Path_3' succeeds -process.filter_3 = triggerResultsFilter.clone( - triggerConditions = ( 'Path_3', ), - l1tResults = '', - throw = False - ) +process.filter_3 = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_3', ) +) # accept if any path succeeds (explicit OR) -process.filter_any_or = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1', 'Path_2', 'Path_3' ), - l1tResults = '', - throw = False - ) +process.filter_any_or = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1', 'Path_2', 'Path_3' ) +) # accept if 'Path_1' succeeds, prescaled by 15 -process.filter_1_pre = triggerResultsFilter.clone( - triggerConditions = ( '(Path_1) / 15', ), - l1tResults = '', - throw = False - ) +process.filter_1_pre = _triggerResultsFilter.clone( + triggerConditions = ( '(Path_1) / 15', ) +) # accept if 'Path_1' prescaled by 15 does not succeed -process.filter_not_1_pre = triggerResultsFilter.clone( - triggerConditions = ( 'NOT (Path_1 / 15)', ), - l1tResults = '', - throw = False - ) +process.filter_not_1_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT (Path_1 / 15)', ) +) # accept if 'Path_2' succeeds, prescaled by 10 -process.filter_2_pre = triggerResultsFilter.clone( - triggerConditions = ( '(Path_2 / 10)', ), - l1tResults = '', - throw = False - ) +process.filter_2_pre = _triggerResultsFilter.clone( + triggerConditions = ( '(Path_2 / 10)', ) +) # accept if any path succeeds, with different prescales (explicit OR, prescaled) -process.filter_any_pre = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1 / 15', 'Path_2 / 10', 'Path_3 / 6', ), - l1tResults = '', - throw = False - ) +process.filter_any_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1 / 15', 'Path_2 / 10', 'Path_3 / 6', ) +) # equivalent of filter_any_pre using NOT operator twice -process.filter_any_pre_doubleNOT = triggerResultsFilter.clone( - triggerConditions = ( 'NOT NOT (Path_1 / 15 OR Path_2 / 10 OR Path_3 / 6)', ), - l1tResults = '', - throw = False - ) +process.filter_any_pre_doubleNOT = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT NOT (Path_1 / 15 OR Path_2 / 10 OR Path_3 / 6)', ) +) # opposite of filter_any_pre without whitespaces where possible -process.filter_not_any_pre = triggerResultsFilter.clone( - triggerConditions = ( 'NOT(Path_1/15)AND(NOT Path_2/10)AND(NOT Path_3/6)', ), - l1tResults = '', - throw = False - ) +process.filter_not_any_pre = _triggerResultsFilter.clone( + triggerConditions = ( 'NOT(Path_1/15)AND(NOT Path_2/10)AND(NOT Path_3/6)', ) +) # accept if any path succeeds (wildcard, '*') -process.filter_any_star = triggerResultsFilter.clone( - triggerConditions = ( '*', ), - l1tResults = '', - throw = False - ) +process.filter_any_star = _triggerResultsFilter.clone( + triggerConditions = ( '*', ) +) # accept if any path succeeds (wildcard, twice '*') -process.filter_any_doublestar = triggerResultsFilter.clone( - triggerConditions = ( '*_*', ), - l1tResults = '', - throw = False - ) +process.filter_any_doublestar = _triggerResultsFilter.clone( + triggerConditions = ( '*_*', ) +) # accept if any path succeeds (wildcard, '?') -process.filter_any_question = triggerResultsFilter.clone( - triggerConditions = ( 'Path_?', ), - l1tResults = '', - throw = False - ) +process.filter_any_question = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_?', ) +) # accept if all path succeed (explicit AND) -process.filter_all_explicit = triggerResultsFilter.clone( - triggerConditions = ( 'Path_1 AND Path_2 AND Path_3', ), - l1tResults = '', - throw = False +process.filter_all_explicit = _triggerResultsFilter.clone( + triggerConditions = ( 'Path_1 AND Path_2 AND Path_3', ) ) # wrong path name (explicit) -process.filter_wrong_name = triggerResultsFilter.clone( +process.filter_wrong_name = _triggerResultsFilter.clone( triggerConditions = ( 'Wrong', ), - l1tResults = '', throw = False ) # wrong path name (wildcard) -process.filter_wrong_pattern = triggerResultsFilter.clone( +process.filter_wrong_pattern = _triggerResultsFilter.clone( triggerConditions = ( '*_Wrong', ), - l1tResults = '', throw = False ) # empty path list -process.filter_empty_pattern = triggerResultsFilter.clone( - triggerConditions = ( ), - l1tResults = '', - throw = False +process.filter_empty_pattern = _triggerResultsFilter.clone( + triggerConditions = ( ) ) # L1-like path name -process.filter_l1path_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'L1_Path', ), - l1tResults = '', - throw = False +process.filter_l1path_pattern = _triggerResultsFilter.clone( + # this returns False for every event without throwing exceptions, + # because here l1tResults is an empty InputTag + # (patterns starting with "L1_" are used exclusively to check the L1-Trigger decisions) + triggerConditions = ( 'L1_Path', ) ) # real L1 trigger -process.filter_l1singlemuopen_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'L1_SingleMuOpen', ), - l1tResults = '', - throw = False +process.filter_l1singlemuopen_pattern = _triggerResultsFilter.clone( + # this returns False for every event without throwing exceptions, + # because here l1tResults is an empty InputTag + # (patterns starting with "L1_" are used exclusively to check the L1-Trigger decisions) + triggerConditions = ( 'L1_SingleMuOpen', ) ) # TRUE -process.filter_true_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'TRUE', ), - l1tResults = '', - throw = False +process.filter_true_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'TRUE', ) ) # FALSE -process.filter_false_pattern = triggerResultsFilter.clone( - triggerConditions = ( 'FALSE', ), - l1tResults = '', - throw = False +process.filter_false_pattern = _triggerResultsFilter.clone( + triggerConditions = ( 'FALSE', ) ) @@ -202,6 +165,6 @@ # define an EndPath to analyze all other path results process.hltTrigReport = cms.EDAnalyzer( 'HLTrigReport', - HLTriggerResults = cms.InputTag( 'TriggerResults', '', 'TEST' ) + HLTriggerResults = cms.InputTag( 'TriggerResults', '', '@currentProcess' ) ) process.HLTAnalyzerEndpath = cms.EndPath( process.hltTrigReport ) diff --git a/HLTrigger/HLTfilters/test/triggerResultsFilter_producer.py b/HLTrigger/HLTfilters/test/triggerResultsFilter_producer.py index 3d72515f89796..4bf4890b7dcaf 100644 --- a/HLTrigger/HLTfilters/test/triggerResultsFilter_producer.py +++ b/HLTrigger/HLTfilters/test/triggerResultsFilter_producer.py @@ -2,6 +2,18 @@ process = cms.Process('HLT') +process.options.wantSummary = True + +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.FwkReport.reportEvery = 100 # only report every 100th event start +process.MessageLogger.cerr.enableStatistics = False # enable "MessageLogger Summary" message +process.MessageLogger.cerr.threshold = 'INFO' # change to 'WARNING' not to show INFO-level messages +## enable reporting of INFO-level messages (default is limit=0, i.e. no messages reported) +#process.MessageLogger.cerr.INFO = cms.untracked.PSet( +# reportEvery = cms.untracked.int32(1), # every event! +# limit = cms.untracked.int32(-1) # no limit! +#) + # define the Prescaler service, and set the scale factors process.PrescaleService = cms.Service('PrescaleService', prescaleTable = cms.VPSet( @@ -22,17 +34,9 @@ lvl1DefaultLabel = cms.string('any') ) -# load conditions from the global tag -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - -# define an empty source, and ask for 100 events +# define an empty source, and ask for 1000 events process.source = cms.Source('EmptySource') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000) -) +process.maxEvents.input = 1000 # define 3 prescalers, one per path process.scale_1 = cms.EDFilter('HLTPrescaler')