27 , hltConfigInit_(
false )
32 , errorReplyDcs_(
false )
35 , gtEvmInputTag_(
"" )
37 , errorReplyGt_(
false )
40 , l1BeforeMask_(
true )
42 , errorReplyL1_(
false )
45 , errorReplyHlt_(
false )
51 , configError_(
"CONFIG_ERROR" )
52 , emptyKeyError_(
"EMPTY_KEY_ERROR" )
56 if ( config.
exists(
"andOr" ) ) {
68 if ( config.
exists(
"andOrDcs" ) ) {
77 if ( config.
exists(
"andOrGt" ) ) {
83 if ( config.
exists(
"gtEvmInputTag" ) ) {
91 if ( config.
exists(
"andOrL1" ) ) {
93 if ( config.
exists(
"stage2" ) )
104 if ( config.
exists(
"andOrHlt" ) ) {
161 bool hltChanged(
false );
175 std::vector< std::string > algoNames;
178 l1uGt_->retrieveL1Setup(setup);
180 const std::vector<std::pair<std::string, int> > prescales =
l1uGt_->prescales();
181 for(
auto ip : prescales)
182 algoNames.push_back(ip.first);
189 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
190 algoNames.push_back( iAlgo->second.algoName() );
193 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
194 algoNames.push_back( iAlgo->second.algoName() );
203 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
204 const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
205 if ( l1AlgoName.find(
'*' ) != std::string::npos ) {
206 l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(),
expandLogicalExpression( algoNames, l1AlgoName ) );
212 for (
unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr )
213 if (
std::find(algoNames.begin(),algoNames.end(),tmp[ iExpr ]) == algoNames.end() ) {
216 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << tmp[ iExpr ] <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
225 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
226 const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
227 if ( hltPathName.find(
'*' ) != std::string::npos ) {
242 if ( !
on_ )
return true;
264 if ( ( *dcsStatus ).size() == 0 ) {
271 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
276 for ( std::vector< int >::const_iterator partitionNumber =
dcsPartitions_.begin(); partitionNumber !=
dcsPartitions_.end(); ++partitionNumber ) {
288 switch( dcsPartition ) {
320 return dcsStatus->at( 0 ).ready( dcsPartition );
352 if ( gtLogicalExpression.empty() ) {
358 bool negExpr(
negate( gtLogicalExpression ) );
359 if ( negExpr && gtLogicalExpression.empty() ) {
367 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit ) {
372 if ( gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared" ) {
375 if ( ! gtReadoutRecord.
isValid() ) {
381 }
else if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" || gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ||
382 gtStatusBit ==
"7TeV" || gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV" ) {
385 if ( ! gtEvmReadoutRecord.
isValid() ) {
390 if ( gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" ) {
392 }
else if ( gtStatusBit ==
"Adjust" ) {
394 }
else if ( gtStatusBit ==
"Sqeeze" ) {
396 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
398 }
else if ( gtStatusBit ==
"7TeV" ) {
400 }
else if ( gtStatusBit ==
"8TeV" ) {
402 }
else if ( gtStatusBit ==
"13TeV" ) {
404 }
else if ( gtStatusBit ==
"2360GeV" ) {
406 }
else if ( gtStatusBit ==
"900GeV" ) {
417 return negExpr ? ( ! gtDecision ) : gtDecision;
450 l1uGt_->retrieveL1(event,setup);
456 if ( l1LogicalExpression.empty() ) {
462 bool negExpr(
negate( l1LogicalExpression ) );
463 if ( negExpr && l1LogicalExpression.empty() ) {
471 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm ) {
475 bool decision =
false;
478 bool errorBOOL = (
l1BeforeMask_ ?
l1uGt_->getInitialDecisionByName(l1AlgoName,decision) :
l1uGt_->getFinalDecisionByName(l1AlgoName,decision) );
483 decision = (
l1BeforeMask_ ?
l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) :
l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
484 error = ( errorINT != 0 );
487 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
493 edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
503 return negExpr ? ( ! l1Decision ) : l1Decision;
524 if ( ! hltTriggerResults.
isValid() ) {
528 if ( ( *hltTriggerResults ).size() == 0 ) {
553 if ( hltLogicalExpression.empty() ) {
559 bool negExpr(
negate( hltLogicalExpression ) );
560 if ( negExpr && hltLogicalExpression.empty() ) {
568 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath ) {
577 if ( hltTriggerResults->
error( indexPath ) ) {
583 const bool decision( hltTriggerResults->
accept( indexPath ) );
589 return negExpr ? ( ! hltDecision ) : hltDecision;
600 std::vector< std::string >
matched;
602 if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
603 const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
610 if ( matched.empty() ) {
611 if (
verbose_ > 1 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
617 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
618 if ( iVers > 0 ) expanded.append( useAnd ?
" AND " :
" OR " );
619 expanded.append( matched.at( iVers ) );
621 expanded.append(
")" );
622 if (
verbose_ > 1 )
edm::LogInfo(
"GenericTriggerEventFlag" ) <<
"Logical expression: \"" << expr <<
"\"\n" 623 <<
" --> expanded to \"" << expanded <<
"\"";
636 if ( word.at( 0 ) ==
'~' ) {
649 if ( key.size() == 0 )
return std::vector< std::string >( 1,
emptyKeyError_ );
651 std::vector< edm::eventsetup::DataKey >
labels;
653 std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
654 while ( iKey != labels.end() && iKey->name().value() !=
dbLabel_ ) ++iKey;
655 if ( iKey == labels.end() ) {
660 const std::map< std::string, std::string > & expressionMap = logicalExpressions->
m_alcarecoToTrig;
661 std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
662 if ( listIter == expressionMap.end() ) {
663 if (
verbose_ > 0 )
edm::LogWarning(
"GenericTriggerEventFlag" ) <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
666 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_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
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_
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::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)
~GenericTriggerEventFlag()
To be called from d'tors by 'delete'.
const std::string configError_
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
static const bool useL1EventSetup(true)
std::vector< DcsStatus > DcsStatusCollection
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
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_
bool check(const edm::EventSetup &iSetup)
std::vector< std::vector< double > > tmp
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.
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?