27 if ( config.
exists(
"andOrL1" ) ) {
66 if ( config.
exists(
"andOr" ) ) {
78 if ( config.
exists(
"andOrDcs" ) ) {
87 if ( config.
exists(
"andOrGt" ) ) {
93 if ( config.
exists(
"gtEvmInputTag" ) ) {
101 if ( config.
exists(
"andOrL1" ) ) {
103 if ( config.
exists(
"stage2" ) )
114 if ( config.
exists(
"andOrHlt" ) ) {
127 watchDB_ = std::make_unique<edm::ESWatcher< AlCaRecoTriggerBitsRcd > >();
133 if( stage1Valid==
false )
throw cms::Exception(
"ConfigError") <<
" Error when constructing GenericTriggerEventFlag, legacy/stage-1 is requested but the constructor called is stage2 only";
166 bool hltChanged(
false );
180 std::vector< std::string > algoNames;
183 l1uGt_->retrieveL1Setup(setup);
185 const std::vector<std::pair<std::string, int> > prescales =
l1uGt_->prescales();
186 for(
auto ip : prescales)
187 algoNames.push_back(ip.first);
194 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
195 algoNames.push_back( iAlgo->second.algoName() );
198 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
199 algoNames.push_back( iAlgo->second.algoName() );
208 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
209 const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
210 if ( l1AlgoName.find(
'*' ) != std::string::npos ) {
211 l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(),
expandLogicalExpression( algoNames, l1AlgoName ) );
217 for (
unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr )
218 if (
std::find(algoNames.begin(),algoNames.end(),tmp[ iExpr ]) == algoNames.end() ) {
221 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << tmp[ iExpr ] <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
230 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
231 const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
232 if ( hltPathName.find(
'*' ) != std::string::npos ) {
247 if ( !
on_ )
return true;
269 if ( ( *dcsStatus ).size() == 0 ) {
276 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
281 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
293 switch( dcsPartition ) {
325 return dcsStatus->at( 0 ).ready( dcsPartition );
357 if ( gtLogicalExpression.empty() ) {
363 bool negExpr(
negate( gtLogicalExpression ) );
364 if ( negExpr && gtLogicalExpression.empty() ) {
372 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit ) {
377 if ( gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared" ) {
380 if ( ! gtReadoutRecord.
isValid() ) {
386 }
else if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" || gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ||
387 gtStatusBit ==
"7TeV" || gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV" ) {
390 if ( ! gtEvmReadoutRecord.
isValid() ) {
395 if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" ) {
397 }
else if ( gtStatusBit ==
"Adjust" ) {
399 }
else if ( gtStatusBit ==
"Sqeeze" ) {
401 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
403 }
else if ( gtStatusBit ==
"7TeV" ) {
405 }
else if ( gtStatusBit ==
"8TeV" ) {
407 }
else if ( gtStatusBit ==
"13TeV" ) {
409 }
else if ( gtStatusBit ==
"2360GeV" ) {
411 }
else if ( gtStatusBit ==
"900GeV" ) {
422 return negExpr ? ( ! gtDecision ) : gtDecision;
455 l1uGt_->retrieveL1(event,setup);
461 if ( l1LogicalExpression.empty() ) {
467 bool negExpr(
negate( l1LogicalExpression ) );
468 if ( negExpr && l1LogicalExpression.empty() ) {
476 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm ) {
480 bool decision =
false;
483 bool errorBOOL = (
l1BeforeMask_ ?
l1uGt_->getInitialDecisionByName(l1AlgoName,decision) :
l1uGt_->getFinalDecisionByName(l1AlgoName,decision) );
488 decision = (
l1BeforeMask_ ?
l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) :
l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
489 error = ( errorINT != 0 );
492 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
498 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
508 return negExpr ? ( ! l1Decision ) : l1Decision;
529 if ( ! hltTriggerResults.
isValid() ) {
533 if ( ( *hltTriggerResults ).size() == 0 ) {
558 if ( hltLogicalExpression.empty() ) {
564 bool negExpr(
negate( hltLogicalExpression ) );
565 if ( negExpr && hltLogicalExpression.empty() ) {
573 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath ) {
582 if ( hltTriggerResults->
error( indexPath ) ) {
588 const bool decision( hltTriggerResults->
accept( indexPath ) );
594 return negExpr ? ( ! hltDecision ) : hltDecision;
605 std::vector< std::string >
matched;
607 if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
608 const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
615 if ( matched.empty() ) {
616 if (
verbose_ > 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
622 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
623 if ( iVers > 0 ) expanded.append( useAnd ?
" AND " :
" OR " );
624 expanded.append( matched.at( iVers ) );
626 expanded.append(
")" );
627 if (
verbose_ > 1 )
edm::LogInfo(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\"\n" 628 <<
" --> expanded to \"" << expanded <<
"\"";
641 if ( word.at( 0 ) ==
'~' ) {
654 if ( key.size() == 0 )
return std::vector< std::string >( 1,
emptyKeyError_ );
656 std::vector< edm::eventsetup::DataKey >
labels;
658 std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
659 while ( iKey != labels.end() && iKey->name().value() !=
dbLabel_ ) ++iKey;
660 if ( iKey == labels.end() ) {
665 const std::map< std::string, std::string > & expressionMap = logicalExpressions->
m_alcarecoToTrig;
666 std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
667 if ( listIter == expressionMap.end() ) {
668 if (
verbose_ > 0 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
671 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
std::map< std::string, std::string > m_alcarecoToTrig
HLTConfigProvider hltConfig_
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_
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
bool accept() const
Has at least one path accepted the event?
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
def setup(process, global_tag, zero_tesla=False)
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::unique_ptr< L1GtUtils > l1Gt_
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
const cms_uint16_t beamMomentum() 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::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
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 error() const
Has any path encountered an error (exception)
const std::string configError_
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
static const bool useL1EventSetup(true)
std::vector< DcsStatus > DcsStatusCollection
bool acceptDcs(const edm::Event &event)
std::vector< std::string > hltLogicalExpressionsCache_
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
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
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms' logical expression?
std::vector< std::string > l1LogicalExpressions_
std::vector< std::vector< double > > tmp
edm::InputTag gtEvmInputTag_
const std::string emptyKeyError_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
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.
const cms_uint16_t beamMode() const
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
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?