27 , hltConfigInit_(
false )
32 , errorReplyDcs_(
false )
35 , gtEvmInputTag_(
"" )
37 , errorReplyGt_(
false )
39 , l1BeforeMask_(
true )
41 , errorReplyL1_(
false )
44 , errorReplyHlt_(
false )
50 , configError_(
"CONFIG_ERROR" )
51 , emptyKeyError_(
"EMPTY_KEY_ERROR" )
55 if ( config.
exists(
"andOr" ) ) {
67 if ( config.
exists(
"andOrDcs" ) ) {
76 if ( config.
exists(
"andOrGt" ) ) {
82 if ( config.
exists(
"gtEvmInputTag" ) ) {
90 if ( config.
exists(
"andOrL1" ) ) {
99 if ( config.
exists(
"andOrHlt" ) ) {
156 bool hltChanged(
false );
173 std::vector< std::string > algoNames;
175 const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
176 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
177 algoNames.push_back( iAlgo->second.algoName() );
180 const AlgorithmMap l1GtTech( handleL1GtTriggerMenu->gtTechnicalTriggerMap() );
181 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
182 algoNames.push_back( iAlgo->second.algoName() );
188 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
189 const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
190 if ( l1AlgoName.find(
'*' ) != std::string::npos ) {
191 l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(),
expandLogicalExpression( algoNames, l1AlgoName ) );
203 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
204 const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
205 if ( hltPathName.find(
'*' ) != std::string::npos ) {
220 if ( !
on_ )
return true;
242 if ( ( *dcsStatus ).size() == 0 ) {
249 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
254 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
266 switch( dcsPartition ) {
298 return dcsStatus->at( 0 ).ready( dcsPartition );
330 if ( gtLogicalExpression.empty() ) {
336 bool negExpr(
negate( gtLogicalExpression ) );
337 if ( negExpr && gtLogicalExpression.empty() ) {
345 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit ) {
350 if ( gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared" ) {
353 if ( ! gtReadoutRecord.
isValid() ) {
358 decision = ( gtReadoutRecord->gtFdlWord().physicsDeclared() == 1 );
359 }
else if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" || gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ||
360 gtStatusBit ==
"7TeV" || gtStatusBit ==
"8TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV" ) {
363 if ( ! gtEvmReadoutRecord.
isValid() ) {
368 if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" ) {
369 decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
370 }
else if ( gtStatusBit ==
"Adjust" ) {
371 decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
372 }
else if ( gtStatusBit ==
"Sqeeze" ) {
373 decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
374 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
375 decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
376 }
else if ( gtStatusBit ==
"7TeV" ) {
377 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
378 }
else if ( gtStatusBit ==
"8TeV" ) {
379 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
380 }
else if ( gtStatusBit ==
"2360GeV" ) {
381 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
382 }
else if ( gtStatusBit ==
"900GeV" ) {
383 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450 );
393 return negExpr ? ( ! gtDecision ) : gtDecision;
428 if ( l1LogicalExpression.empty() ) {
434 bool negExpr(
negate( l1LogicalExpression ) );
435 if ( negExpr && l1LogicalExpression.empty() ) {
443 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm ) {
450 if ( error == 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
451 else edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
462 return negExpr ? ( ! l1Decision ) : l1Decision;
483 if ( ! hltTriggerResults.
isValid() ) {
487 if ( ( *hltTriggerResults ).size() == 0 ) {
512 if ( hltLogicalExpression.empty() ) {
518 bool negExpr(
negate( hltLogicalExpression ) );
519 if ( negExpr && hltLogicalExpression.empty() ) {
527 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath ) {
536 if ( hltTriggerResults->error( indexPath ) ) {
542 const bool decision( hltTriggerResults->accept( indexPath ) );
548 return negExpr ? ( ! hltDecision ) : hltDecision;
559 std::vector< std::string > matched;
561 if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
562 const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
569 if ( matched.empty() ) {
570 if (
verbose_ > 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
576 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
577 if ( iVers > 0 ) expanded.append( useAnd ?
" AND " :
" OR " );
578 expanded.append( matched.at( iVers ) );
580 expanded.append(
")" );
581 if (
verbose_ > 1 )
edm::LogInfo(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\"\n"
582 <<
" --> expanded to \"" << expanded <<
"\"";
595 if ( word.at( 0 ) ==
'~' ) {
609 if ( key.size() == 0 )
return std::vector< std::string >( 1,
emptyKeyError_ );
611 std::vector< edm::eventsetup::DataKey >
labels;
613 std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
614 while ( iKey != labels.end() && iKey->name().value() !=
dbLabel_ ) ++iKey;
615 if ( iKey == labels.end() ) {
620 const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
621 std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
622 if ( listIter == expressionMap.end() ) {
623 if (
verbose_ > 0 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
626 return logicalExpressions->decompose( listIter->second );
unsigned int size() const
number of trigger paths in trigger table
bool negate(std::string &word) const
Checks for negated words.
T getParameter(std::string const &) const
HLTConfigProvider hltConfig_
const bool decisionAfterMask(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision after trigger mask for a given algorithm or technical trigger
std::vector< int > dcsPartitions_
edm::InputTag hltInputTag_
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
static const bool useL1GtTriggerMenuLite(false)
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< std::string > gtLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::InputTag gtInputTag_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
const bool decisionBeforeMask(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision before trigger mask for a given algorithm or technical trigger
std::vector< std::string > l1LogicalExpressionsCache_
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
std::vector< OperandToken > & operandTokenVector()
return the vector of operand tokens
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
bool acceptGtLogicalExpression(const edm::Event &event, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits' logical expression?
bool acceptL1LogicalExpression(const edm::Event &event, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms' logical expression?
~GenericTriggerEventFlag()
To be called from d'tors by 'delete'.
const std::string configError_
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
static const bool useL1EventSetup(true)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< DcsStatus > DcsStatusCollection
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool, const edm::InputTag &)
get all the run-constant quantities for L1 trigger and cache them
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
bool acceptDcs(const edm::Event &event)
std::vector< std::string > hltLogicalExpressionsCache_
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
std::vector< std::string > l1LogicalExpressions_
bool check(const edm::EventSetup &iSetup)
edm::InputTag gtEvmInputTag_
const std::string emptyKeyError_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
volatile std::atomic< bool > shutdown_flag false
edm::InputTag dcsInputTag_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
std::string expandLogicalExpression(const std::vector< std::string > &target, const std::string &expr, bool useAnd=false) const
Expand wild-carded logical expressions, giving version postfixes priority.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths' logical expression?
bool acceptL1(const edm::Event &event, const edm::EventSetup &setup)
Was this event accepted by the configured L1 logical expression combination?
virtual const bool expressionResult() const
bool acceptGt(const edm::Event &event)
Does this event fulfill the configured GT status logical expression combination?