23 if (config.
exists(
"andOrL1")) {
62 if (config.
exists(
"andOr")) {
64 if (config.
exists(
"verbosityLevel"))
75 if (config.
exists(
"andOrDcs")) {
84 if (config.
exists(
"andOrGt")) {
90 if (config.
exists(
"gtEvmInputTag")) {
94 if (config.
exists(
"gtDBKey"))
99 if (config.
exists(
"andOrL1")) {
101 if (config.
exists(
"stage2"))
107 if (config.
exists(
"l1DBKey"))
109 if (config.
exists(
"l1BeforeMask"))
114 if (config.
exists(
"andOrHlt")) {
120 if (config.
exists(
"hltDBKey"))
128 if (config.
exists(
"dbLabel"))
130 watchDB_ = std::make_unique<edm::ESWatcher<AlCaRecoTriggerBitsRcd> >();
136 if (stage1Valid ==
false)
137 throw cms::Exception(
"ConfigError") <<
" Error when constructing GenericTriggerEventFlag, legacy/stage-1 is " 138 "requested but the constructor called is stage2 only";
171 <<
"HLT TriggerResults InputTag \"" <<
hltInputTag_.
encode() <<
"\" specifies no process";
173 bool hltChanged(
false);
177 <<
"HLT config initialization error with process name \"" <<
hltInputTag_.
process() <<
"\"";
180 edm::LogError(
"GenericTriggerEventFlag") <<
"HLT config size error";
191 std::vector<std::string> algoNames;
194 l1uGt_->retrieveL1Setup(setup);
196 const std::vector<std::pair<std::string, int> >
prescales =
l1uGt_->prescales();
197 for (
auto ip : prescales)
198 algoNames.push_back(ip.first);
205 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo) {
206 algoNames.push_back(iAlgo->second.algoName());
209 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo) {
210 algoNames.push_back(iAlgo->second.algoName());
218 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo) {
219 const std::string l1AlgoName(l1AlgoLogicParser.operandTokenVector().at(iAlgo).tokenName);
220 if (l1AlgoName.find(
'*') != std::string::npos) {
221 l1LogicalExpression.replace(
228 for (
unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr)
229 if (
std::find(algoNames.begin(), algoNames.end(), tmp[iExpr]) == algoNames.end()) {
233 <<
"L1 algorithm \"" << tmp[iExpr]
234 <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
243 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
244 const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
245 if (hltPathName.find(
'*') != std::string::npos) {
246 hltLogicalExpression.replace(hltLogicalExpression.find(hltPathName),
282 if ((*dcsStatus).empty()) {
292 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
300 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
310 int dcsPartition)
const {
312 switch (dcsPartition) {
341 <<
"DCS partition number \"" << dcsPartition <<
"\" does not exist ==> decision: " <<
errorReplyDcs_;
346 return dcsStatus->at(0).ready(dcsPartition);
359 ++gtLogicalExpression) {
367 ++gtLogicalExpression) {
377 if (gtLogicalExpression.empty()) {
384 bool negExpr(
negate(gtLogicalExpression));
385 if (negExpr && gtLogicalExpression.empty()) {
388 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyGt_;
395 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit) {
400 if (gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared") {
403 if (!gtReadoutRecord.
isValid()) {
406 <<
"L1GlobalTriggerReadoutRecord product with InputTag \"" <<
gtInputTag_.
encode()
412 }
else if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" ||
413 gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" || gtStatusBit ==
"7TeV" ||
414 gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV") {
417 if (!gtEvmReadoutRecord.
isValid()) {
425 if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam") {
427 }
else if (gtStatusBit ==
"Adjust") {
429 }
else if (gtStatusBit ==
"Sqeeze") {
431 }
else if (gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop") {
433 }
else if (gtStatusBit ==
"7TeV") {
435 }
else if (gtStatusBit ==
"8TeV") {
437 }
else if (gtStatusBit ==
"13TeV") {
439 }
else if (gtStatusBit ==
"2360GeV") {
441 }
else if (gtStatusBit ==
"900GeV") {
447 <<
"GT status bit \"" << gtStatusBit <<
"\" is not defined ==> decision: " <<
errorReplyGt_;
454 return negExpr ? (!gtDecision) : gtDecision;
467 ++l1LogicalExpression) {
475 ++l1LogicalExpression) {
488 l1uGt_->retrieveL1(event, setup);
494 if (l1LogicalExpression.empty()) {
501 bool negExpr(
negate(l1LogicalExpression));
502 if (negExpr && l1LogicalExpression.empty()) {
505 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyL1_;
512 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm) {
515 bool decision =
false;
519 :
l1uGt_->getFinalDecisionByName(l1AlgoName, decision));
525 :
l1Gt_->decisionAfterMask(event, l1AlgoName, errorINT));
526 error = (errorINT != 0);
530 <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error
531 <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
538 <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
548 return negExpr ? (!l1Decision) : l1Decision;
567 if (!hltTriggerResults.
isValid()) {
573 if ((*hltTriggerResults).size() == 0) {
584 ++hltLogicalExpression) {
592 ++hltLogicalExpression) {
603 if (hltLogicalExpression.empty()) {
610 bool negExpr(
negate(hltLogicalExpression));
611 if (negExpr && hltLogicalExpression.empty()) {
614 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyHlt_;
621 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
627 edm::LogWarning(
"GenericTriggerEventFlag") <<
"HLT path \"" << hltPathName <<
"\" is not found in process " 632 if (hltTriggerResults->
error(indexPath)) {
635 <<
"HLT path \"" << hltPathName <<
"\" in error ==> decision: " <<
errorReplyHlt_;
640 const bool decision(hltTriggerResults->
accept(indexPath));
646 return negExpr ? (!hltDecision) : hltDecision;
654 std::vector<std::string>
matched;
656 if (expr.substr(expr.size() - versionWildcard.size()) == versionWildcard) {
657 const std::string exprBase(expr.substr(0, expr.size() - versionWildcard.size()));
664 if (matched.empty()) {
666 edm::LogWarning(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
672 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers) {
674 expanded.append(useAnd ?
" AND " :
" OR ");
675 expanded.append(matched.at(iVers));
677 expanded.append(
")");
679 edm::LogInfo(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\"\n" 680 <<
" --> expanded to \"" << expanded <<
"\"";
688 if (word.at(0) ==
'~') {
701 std::vector<edm::eventsetup::DataKey>
labels;
703 std::vector<edm::eventsetup::DataKey>::const_iterator iKey = labels.begin();
704 while (iKey != labels.end() && iKey->name().value() !=
dbLabel_)
706 if (iKey == labels.end()) {
709 <<
"Label " <<
dbLabel_ <<
" not found in DB for 'AlCaRecoTriggerBitsRcd'";
713 const std::map<std::string, std::string>& expressionMap = logicalExpressions->
m_alcarecoToTrig;
714 std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(key);
715 if (listIter == expressionMap.end()) {
718 <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
721 return logicalExpressions->
decompose(listIter->second);
732 <<
"HLTConfigProvider is not initialized, method will return \"false\"";
747 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
755 <<
"HLT path \"" << hltPathName <<
"\" is not found in process " <<
hltInputTag_.
process();
unsigned int size() const
number of trigger paths in trigger table
bool negate(std::string &word) const
Checks for negated words.
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
T getParameter(std::string const &) const
HLTConfigProvider hltConfig_
edm::InputTag hltInputTag_
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
std::map< std::string, std::string > m_alcarecoToTrig
static const bool useL1GtTriggerMenuLite(false)
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< std::string > hltLogicalExpressions_
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
std::vector< std::string > gtLogicalExpressions_
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
edm::InputTag gtInputTag_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
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_
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)
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
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)
std::vector< std::string > l1LogicalExpressionsCache_
const std::string configError_
static const bool useL1EventSetup(true)
std::vector< DcsStatus > DcsStatusCollection
bool acceptDcs(const edm::Event &event)
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?
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
bool allHLTPathsAreValid() const
std::vector< std::string > hltLogicalExpressionsCache_
std::vector< int > dcsPartitions_
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.
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
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?
std::vector< std::string > l1LogicalExpressions_
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?