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 ) {
346 if ( gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared" ) {
349 if ( ! gtReadoutRecord.
isValid() ) {
354 decision = ( gtReadoutRecord->gtFdlWord().physicsDeclared() == 1 );
355 }
else if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" || gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ||
356 gtStatusBit ==
"7TeV" || gtStatusBit ==
"8TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV" ) {
359 if ( ! gtEvmReadoutRecord.
isValid() ) {
364 if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" ) {
365 decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
366 }
else if ( gtStatusBit ==
"Adjust" ) {
367 decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
368 }
else if ( gtStatusBit ==
"Sqeeze" ) {
369 decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
370 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
371 decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
372 }
else if ( gtStatusBit ==
"7TeV" ) {
373 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
374 }
else if ( gtStatusBit ==
"8TeV" ) {
375 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
376 }
else if ( gtStatusBit ==
"2360GeV" ) {
377 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
378 }
else if ( gtStatusBit ==
"900GeV" ) {
379 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450 );
389 return negExpr ? ( ! gtDecision ) : gtDecision;
424 if ( l1LogicalExpression.empty() ) {
430 bool negExpr(
negate( l1LogicalExpression ) );
431 if ( negExpr && l1LogicalExpression.empty() ) {
439 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm ) {
446 if ( error == 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
447 else edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
458 return negExpr ? ( ! l1Decision ) : l1Decision;
479 if ( ! hltTriggerResults.
isValid() ) {
483 if ( ( *hltTriggerResults ).size() == 0 ) {
508 if ( hltLogicalExpression.empty() ) {
514 bool negExpr(
negate( hltLogicalExpression ) );
515 if ( negExpr && hltLogicalExpression.empty() ) {
523 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath ) {
532 if ( hltTriggerResults->error( indexPath ) ) {
538 const bool decision( hltTriggerResults->accept( indexPath ) );
544 return negExpr ? ( ! hltDecision ) : hltDecision;
555 std::vector< std::string > matched;
557 if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
558 const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
565 if ( matched.empty() ) {
566 if (
verbose_ > 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
572 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
573 if ( iVers > 0 ) expanded.append( useAnd ?
" AND " :
" OR " );
574 expanded.append( matched.at( iVers ) );
576 expanded.append(
")" );
577 if (
verbose_ > 1 )
edm::LogInfo(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\"\n"
578 <<
" --> expanded to \"" << expanded <<
"\"";
591 if ( word.at( 0 ) ==
'~' ) {
605 if ( key.size() == 0 )
return std::vector< std::string >( 1,
emptyKeyError_ );
607 std::vector< edm::eventsetup::DataKey >
labels;
609 std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
610 while ( iKey != labels.end() && iKey->name().value() !=
dbLabel_ ) ++iKey;
611 if ( iKey == labels.end() ) {
616 const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
617 std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
618 if ( listIter == expressionMap.end() ) {
619 if (
verbose_ > 0 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
622 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?