24 if (config.
exists(
"andOrL1")) {
26 l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(
config, iC, use);
36 hltConfigInit_(
false),
41 errorReplyDcs_(
false),
54 errorReplyHlt_(
false),
60 configError_(
"CONFIG_ERROR"),
61 emptyKeyError_(
"EMPTY_KEY_ERROR") {
63 if (config.
exists(
"andOr")) {
65 if (config.
exists(
"verbosityLevel"))
76 if (config.
exists(
"andOrDcs")) {
85 if (config.
exists(
"andOrGt")) {
91 if (config.
exists(
"gtEvmInputTag")) {
95 if (config.
exists(
"gtDBKey"))
100 if (config.
exists(
"andOrL1")) {
102 if (config.
exists(
"stage2"))
108 if (config.
exists(
"l1DBKey"))
110 if (config.
exists(
"l1BeforeMask"))
115 if (config.
exists(
"andOrHlt")) {
121 if (config.
exists(
"hltDBKey"))
129 if (config.
exists(
"dbLabel"))
131 watchDB_ = std::make_unique<edm::ESWatcher<AlCaRecoTriggerBitsRcd> >();
146 if (stage1Valid ==
false)
147 throw cms::Exception(
"ConfigError") <<
" Error when constructing GenericTriggerEventFlag, legacy/stage-1 is "
148 "requested but the constructor called is stage2 only";
181 <<
"HLT TriggerResults InputTag \"" <<
hltInputTag_.
encode() <<
"\" specifies no process";
183 bool hltChanged(
false);
187 <<
"HLT config initialization error with process name \"" <<
hltInputTag_.
process() <<
"\"";
190 edm::LogError(
"GenericTriggerEventFlag") <<
"HLT config size error";
201 std::vector<std::string> algoNames;
204 l1uGt_->retrieveL1Setup(setup);
206 const std::vector<std::pair<std::string, double> >
prescales =
l1uGt_->prescales();
207 for (
const auto& ip : prescales)
208 algoNames.push_back(ip.first);
214 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo) {
215 algoNames.push_back(iAlgo->second.algoName());
218 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo) {
219 algoNames.push_back(iAlgo->second.algoName());
227 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo) {
228 const std::string l1AlgoName(l1AlgoLogicParser.operandTokenVector().at(iAlgo).tokenName);
229 if (l1AlgoName.find(
'*') != std::string::npos) {
230 l1LogicalExpression.replace(
237 for (
unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr)
238 if (
std::find(algoNames.begin(), algoNames.end(), tmp[iExpr]) == algoNames.end()) {
242 <<
"L1 algorithm \"" << tmp[iExpr]
243 <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
252 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
253 const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
254 if (hltPathName.find(
'*') != std::string::npos) {
255 hltLogicalExpression.replace(hltLogicalExpression.find(hltPathName),
291 if ((*dcsStatus).empty()) {
301 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
309 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
319 int dcsPartition)
const {
321 switch (dcsPartition) {
350 <<
"DCS partition number \"" << dcsPartition <<
"\" does not exist ==> decision: " <<
errorReplyDcs_;
355 return dcsStatus->at(0).ready(dcsPartition);
368 ++gtLogicalExpression) {
376 ++gtLogicalExpression) {
386 if (gtLogicalExpression.empty()) {
393 bool negExpr(
negate(gtLogicalExpression));
394 if (negExpr && gtLogicalExpression.empty()) {
397 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyGt_;
404 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit) {
409 if (gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared") {
412 if (!gtReadoutRecord.
isValid()) {
415 <<
"L1GlobalTriggerReadoutRecord product with InputTag \"" <<
gtInputTag_.
encode()
420 decision = (gtReadoutRecord->gtFdlWord().physicsDeclared() == 1);
421 }
else if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" ||
422 gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" || gtStatusBit ==
"7TeV" ||
423 gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV") {
426 if (!gtEvmReadoutRecord.
isValid()) {
434 if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam") {
435 decision = (gtEvmReadoutRecord->gtfeWord().beamMode() == 11);
436 }
else if (gtStatusBit ==
"Adjust") {
437 decision = (10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11);
438 }
else if (gtStatusBit ==
"Sqeeze") {
439 decision = (9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11);
440 }
else if (gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop") {
441 decision = (8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11);
442 }
else if (gtStatusBit ==
"7TeV") {
443 decision = (gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500);
444 }
else if (gtStatusBit ==
"8TeV") {
445 decision = (gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000);
446 }
else if (gtStatusBit ==
"13TeV") {
447 decision = (gtEvmReadoutRecord->gtfeWord().beamMomentum() == 6500);
448 }
else if (gtStatusBit ==
"2360GeV") {
449 decision = (gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180);
450 }
else if (gtStatusBit ==
"900GeV") {
451 decision = (gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450);
456 <<
"GT status bit \"" << gtStatusBit <<
"\" is not defined ==> decision: " <<
errorReplyGt_;
463 return negExpr ? (!gtDecision) : gtDecision;
476 ++l1LogicalExpression) {
484 ++l1LogicalExpression) {
497 l1uGt_->retrieveL1(event, setup);
503 if (l1LogicalExpression.empty()) {
510 bool negExpr(
negate(l1LogicalExpression));
511 if (negExpr && l1LogicalExpression.empty()) {
514 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyL1_;
521 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm) {
524 bool decision =
false;
528 :
l1uGt_->getFinalDecisionByName(l1AlgoName, decision));
534 :
l1Gt_->decisionAfterMask(event, l1AlgoName, errorINT));
535 error = (errorINT != 0);
539 <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " << error
540 <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
547 <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
557 return negExpr ? (!l1Decision) : l1Decision;
576 if (!hltTriggerResults.
isValid()) {
582 if ((*hltTriggerResults).size() == 0) {
593 ++hltLogicalExpression) {
601 ++hltLogicalExpression) {
612 if (hltLogicalExpression.empty()) {
619 bool negExpr(
negate(hltLogicalExpression));
620 if (negExpr && hltLogicalExpression.empty()) {
623 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyHlt_;
630 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
636 edm::LogWarning(
"GenericTriggerEventFlag") <<
"HLT path \"" << hltPathName <<
"\" is not found in process "
641 if (hltTriggerResults->error(indexPath)) {
644 <<
"HLT path \"" << hltPathName <<
"\" in error ==> decision: " <<
errorReplyHlt_;
649 const bool decision(hltTriggerResults->accept(indexPath));
655 return negExpr ? (!hltDecision) : hltDecision;
663 std::vector<std::string> matched;
665 if (expr.substr(expr.size() - versionWildcard.size()) == versionWildcard) {
666 const std::string exprBase(expr.substr(0, expr.size() - versionWildcard.size()));
673 if (matched.empty()) {
675 edm::LogWarning(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
681 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers) {
683 expanded.append(useAnd ?
" AND " :
" OR ");
684 expanded.append(matched.at(iVers));
686 expanded.append(
")");
688 edm::LogInfo(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\"\n"
689 <<
" --> expanded to \"" << expanded <<
"\"";
697 if (word.at(0) ==
'~') {
709 std::vector<edm::eventsetup::DataKey>
labels;
711 std::vector<edm::eventsetup::DataKey>::const_iterator iKey = labels.begin();
712 while (iKey != labels.end() && iKey->name().value() !=
dbLabel_)
714 if (iKey == labels.end()) {
717 <<
"Label " <<
dbLabel_ <<
" not found in DB for 'AlCaRecoTriggerBitsRcd'";
721 const std::map<std::string, std::string>& expressionMap = alCaRecoTriggerBits.m_alcarecoToTrig;
722 std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(key);
723 if (listIter == expressionMap.end()) {
726 <<
"No logical expressions found under key " << key <<
" in 'AlCaRecoTriggerBitsRcd'";
729 return alCaRecoTriggerBits.decompose(listIter->second);
740 <<
"HLTConfigProvider is not initialized, method will return \"false\"";
755 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
763 <<
"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_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, l1t::UseEventSetupIn use=l1t::UseEventSetupIn::RunAndEvent)
HLTConfigProvider hltConfig_
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1GtTriggerMenuToken_
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)
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< std::string > hltLogicalExpressions_
std::vector< std::string > gtLogicalExpressions_
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
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Log< level::Error, false > LogError
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
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
bool getData(T &iHolder) const
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?
tuple key
prepare the HTCondor submission files and eventually submit them
std::vector< std::string > l1LogicalExpressionsCache_
const std::string configError_
static const bool useL1EventSetup(true)
std::vector< DcsStatus > DcsStatusCollection
Log< level::Info, false > LogInfo
bool acceptDcs(const edm::Event &event)
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alCaRecoTriggerBitsToken_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
T getParameter(std::string const &) const
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_
tuple config
parse the configuration file
std::vector< int > dcsPartitions_
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.
Log< level::Warning, false > LogWarning
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_
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?