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);
188 const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
189 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
190 algoNames.push_back( iAlgo->second.algoName() );
192 const AlgorithmMap l1GtTech( handleL1GtTriggerMenu->gtTechnicalTriggerMap() );
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() ) {
380 decision = ( gtReadoutRecord->gtFdlWord().physicsDeclared() == 1 );
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" ) {
391 decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
392 }
else if ( gtStatusBit ==
"Adjust" ) {
393 decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
394 }
else if ( gtStatusBit ==
"Sqeeze" ) {
395 decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
396 }
else if ( gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" ) {
397 decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
398 }
else if ( gtStatusBit ==
"7TeV" ) {
399 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
400 }
else if ( gtStatusBit ==
"8TeV" ) {
401 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
402 }
else if ( gtStatusBit ==
"13TeV" ) {
403 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 6500 );
404 }
else if ( gtStatusBit ==
"2360GeV" ) {
405 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
406 }
else if ( gtStatusBit ==
"900GeV" ) {
407 decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450 );
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
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_
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
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
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?
~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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::vector< DcsStatus > DcsStatusCollection
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
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_
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.
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?