29 , hltConfigInit_(
false )
34 , errorReplyDcs_(
false )
37 , gtEvmInputTag_(
"" )
39 , errorReplyGt_(
false )
41 , l1BeforeMask_(
true )
43 , errorReplyL1_(
false )
46 , errorReplyHlt_(
false )
52 , configError_(
"CONFIG_ERROR" )
53 , emptyKeyError_(
"EMPTY_KEY_ERROR" )
57 if ( config.
exists(
"andOr" ) ) {
69 if ( config.
exists(
"andOrDcs" ) ) {
77 if ( config.
exists(
"andOrGt" ) ) {
87 if ( config.
exists(
"andOrL1" ) ) {
96 if ( config.
exists(
"andOrHlt" ) ) {
152 bool hltChanged(
false );
169 std::vector< std::string > algoNames;
171 const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
172 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
173 algoNames.push_back( iAlgo->second.algoName() );
176 const AlgorithmMap l1GtTech( handleL1GtTriggerMenu->gtTechnicalTriggerMap() );
177 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
178 algoNames.push_back( iAlgo->second.algoName() );
184 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
185 const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
186 if ( l1AlgoName.find(
'*' ) != std::string::npos ) {
187 l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(),
expandLogicalExpression( algoNames, l1AlgoName ) );
199 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
200 const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
201 if ( hltPathName.find(
'*' ) != std::string::npos ) {
216 if ( !
on_ )
return true;
238 if ( ( *dcsStatus ).size() == 0 ) {
245 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
250 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
262 switch( dcsPartition ) {
294 return dcsStatus->at( 0 ).ready( dcsPartition );
326 if ( gtLogicalExpression.empty() ) {
332 bool negExpr(
negate( gtLogicalExpression ) );
333 if ( negExpr && gtLogicalExpression.empty() ) {
341 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit ) {
342 const std::string gtStatusBit( gtAlgoLogicParser.
operandTokenVector().at( iStatusBit ).tokenName );
346 if ( gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared" ) {
349 if ( ! gtReadoutRecord.
isValid() ) {
351 event.getByType( gtReadoutRecord );
352 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 ==
"900GeV" ) {
363 if ( ! gtEvmReadoutRecord.
isValid() ) {
365 event.getByType( gtEvmReadoutRecord );
366 if ( ! gtEvmReadoutRecord.
isValid() ) {
372 if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" ) {
373 decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
374 }
else if ( gtStatusBit ==
"Adjust" ) {
375 decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
376 }
else if ( gtStatusBit ==
"Sqeeze" ) {
377 decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
378 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
379 decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
380 }
else if ( gtStatusBit ==
"7TeV" ) {
381 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
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 ) {
444 const std::string l1AlgoName( l1AlgoLogicParser.
operandTokenVector().at( iAlgorithm ).tokenName );
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 ) {
528 const std::string hltPathName( hltAlgoLogicParser.
operandTokenVector().at( iPath ).tokenName );
536 if ( hltTriggerResults->error( indexPath ) ) {
542 const bool decision( hltTriggerResults->accept( indexPath ) );
548 return negExpr ? ( ! hltDecision ) : hltDecision;
559 std::vector< std::string > matched;
560 const std::string versionWildcard(
"_v*" );
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";
575 std::string expanded(
"(" );
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)
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
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)
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(const edm::ParameterSet &config)
To be called from the ED module's c'tor.
~GenericTriggerEventFlag()
To be called from d'tors by 'delete'.
const std::string configError_
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
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_
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?