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")) {
87 if (
config.exists(
"andOrGt")) {
93 if (
config.exists(
"gtEvmInputTag")) {
97 if (
config.exists(
"gtDBKey"))
102 if (
config.exists(
"andOrL1")) {
104 if (
config.exists(
"stage2"))
110 if (
config.exists(
"l1DBKey"))
112 if (
config.exists(
"l1BeforeMask"))
117 if (
config.exists(
"andOrHlt")) {
123 if (
config.exists(
"hltDBKey"))
131 if (
config.exists(
"dbLabel"))
133 watchDB_ = std::make_unique<edm::ESWatcher<AlCaRecoTriggerBitsRcd>>();
148 if (stage1Valid ==
false)
149 throw cms::Exception(
"ConfigError") <<
" Error when constructing GenericTriggerEventFlag, legacy/stage-1 is " 150 "requested but the constructor called is stage2 only";
183 <<
"HLT TriggerResults InputTag \"" <<
hltInputTag_.
encode() <<
"\" specifies no process";
185 bool hltChanged(
false);
189 <<
"HLT config initialization error with process name \"" <<
hltInputTag_.
process() <<
"\"";
192 edm::LogError(
"GenericTriggerEventFlag") <<
"HLT config size error";
203 std::vector<std::string> algoNames;
208 const std::vector<std::pair<std::string, double>>
prescales =
l1uGt_->prescales();
210 algoNames.push_back(ip.first);
216 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo) {
217 algoNames.push_back(iAlgo->second.algoName());
220 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo) {
221 algoNames.push_back(iAlgo->second.algoName());
229 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo) {
230 const std::string l1AlgoName(l1AlgoLogicParser.operandTokenVector().at(iAlgo).tokenName);
231 if (l1AlgoName.find(
'*') != std::string::npos) {
232 l1LogicalExpression.replace(
239 for (
unsigned iExpr = 0; iExpr <
tmp.size(); ++iExpr)
240 if (
std::find(algoNames.begin(), algoNames.end(),
tmp[iExpr]) == algoNames.end()) {
244 <<
"L1 algorithm \"" <<
tmp[iExpr]
245 <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
254 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
255 const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
256 if (hltPathName.find(
'*') != std::string::npos) {
257 hltLogicalExpression.replace(hltLogicalExpression.find(hltPathName),
283 bool useDCSRecord(
false);
296 <<
"DcsStatusCollection product with InputTag \"" <<
dcsInputTag_.
encode() <<
"\" not in event \n" 301 if (dcsStatus.
isValid() && (*dcsStatus).empty()) {
302 if (
event.eventAuxiliary().isRealData()) {
326 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
334 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
346 int dcsPartition)
const {
347 int theDCSRecordPartition;
349 switch (dcsPartition) {
425 <<
"DCS partition number \"" << dcsPartition <<
"\" does not exist ==> decision: " <<
errorReplyDcs_;
431 return dcsStatus->at(0).ready(dcsPartition);
435 <<
"using dcs record, dcsPartition:" << dcsPartition <<
" " << theDCSRecordPartition <<
" " 436 << (*dcsRecord).partitionName(theDCSRecordPartition) <<
" " 437 << (*dcsRecord).highVoltageReady(theDCSRecordPartition) << std::endl;
439 return (*dcsRecord).highVoltageReady(theDCSRecordPartition);
453 ++gtLogicalExpression) {
461 ++gtLogicalExpression) {
471 if (gtLogicalExpression.empty()) {
478 bool negExpr(
negate(gtLogicalExpression));
479 if (negExpr && gtLogicalExpression.empty()) {
482 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyGt_;
489 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit) {
494 if (gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared") {
497 if (!gtReadoutRecord.
isValid()) {
500 <<
"L1GlobalTriggerReadoutRecord product with InputTag \"" <<
gtInputTag_.
encode()
506 }
else if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" ||
507 gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" || gtStatusBit ==
"7TeV" ||
508 gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV") {
511 if (!gtEvmReadoutRecord.
isValid()) {
519 if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam") {
521 }
else if (gtStatusBit ==
"Adjust") {
523 }
else if (gtStatusBit ==
"Sqeeze") {
525 }
else if (gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop") {
527 }
else if (gtStatusBit ==
"7TeV") {
529 }
else if (gtStatusBit ==
"8TeV") {
531 }
else if (gtStatusBit ==
"13TeV") {
533 }
else if (gtStatusBit ==
"2360GeV") {
535 }
else if (gtStatusBit ==
"900GeV") {
541 <<
"GT status bit \"" << gtStatusBit <<
"\" is not defined ==> decision: " <<
errorReplyGt_;
548 return negExpr ? (!gtDecision) : gtDecision;
561 ++l1LogicalExpression) {
569 ++l1LogicalExpression) {
588 if (l1LogicalExpression.empty()) {
595 bool negExpr(
negate(l1LogicalExpression));
596 if (negExpr && l1LogicalExpression.empty()) {
599 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyL1_;
606 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm) {
609 bool decision =
false;
613 :
l1uGt_->getFinalDecisionByName(l1AlgoName, decision));
619 :
l1Gt_->decisionAfterMask(
event, l1AlgoName, errorINT));
620 error = (errorINT != 0);
624 <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " <<
error 625 <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
632 <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
642 return negExpr ? (!l1Decision) : l1Decision;
661 if (!hltTriggerResults.
isValid()) {
667 if ((*hltTriggerResults).size() == 0) {
678 ++hltLogicalExpression) {
686 ++hltLogicalExpression) {
697 if (hltLogicalExpression.empty()) {
704 bool negExpr(
negate(hltLogicalExpression));
705 if (negExpr && hltLogicalExpression.empty()) {
708 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyHlt_;
715 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
721 edm::LogWarning(
"GenericTriggerEventFlag") <<
"HLT path \"" << hltPathName <<
"\" is not found in process " 726 if (hltTriggerResults->
error(indexPath)) {
729 <<
"HLT path \"" << hltPathName <<
"\" in error ==> decision: " <<
errorReplyHlt_;
734 const bool decision(hltTriggerResults->
accept(indexPath));
740 return negExpr ? (!hltDecision) : hltDecision;
748 std::vector<std::string>
matched;
750 if (expr.substr(expr.size() - versionWildcard.size()) == versionWildcard) {
751 const std::string exprBase(expr.substr(0, expr.size() - versionWildcard.size()));
760 edm::LogWarning(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\" could not be resolved";
766 for (
unsigned iVers = 0; iVers <
matched.size(); ++iVers) {
768 expanded.append(useAnd ?
" AND " :
" OR ");
769 expanded.append(
matched.at(iVers));
771 expanded.append(
")");
773 edm::LogInfo(
"GenericTriggerEventFlag") <<
"Logical expression: \"" << expr <<
"\"\n" 774 <<
" --> expanded to \"" << expanded <<
"\"";
782 if (
word.at(0) ==
'~') {
794 std::vector<edm::eventsetup::DataKey>
labels;
796 std::vector<edm::eventsetup::DataKey>::const_iterator iKey =
labels.begin();
799 if (iKey ==
labels.end()) {
802 <<
"Label " <<
dbLabel_ <<
" not found in DB for 'AlCaRecoTriggerBitsRcd'";
806 const std::map<std::string, std::string>& expressionMap = alCaRecoTriggerBits.m_alcarecoToTrig;
807 std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(
key);
808 if (listIter == expressionMap.end()) {
811 <<
"No logical expressions found under key " <<
key <<
" in 'AlCaRecoTriggerBitsRcd'";
814 return alCaRecoTriggerBits.decompose(listIter->second);
825 <<
"HLTConfigProvider is not initialized, method will return \"false\"";
840 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
848 <<
"HLT path \"" << hltPathName <<
"\" is not found in process " <<
hltInputTag_.
process();
860 desc.add<
bool>(
"ReadPrescalesFromFile",
false);
861 desc.add<
bool>(
"andOr",
false);
862 desc.add<
bool>(
"andOrDcs",
false);
863 desc.add<
bool>(
"andOrHlt",
false);
864 desc.add<
bool>(
"andOrL1",
false);
865 desc.add<
bool>(
"errorReplyDcs",
false);
866 desc.add<
bool>(
"errorReplyHlt",
false);
867 desc.add<
bool>(
"errorReplyL1",
false);
868 desc.add<
bool>(
"l1BeforeMask",
false);
869 desc.add<
bool>(
"stage2",
false);
877 desc.add<std::vector<int>>(
"dcsPartitions", {});
878 desc.add<std::vector<std::string>>(
"hltPaths", {});
879 desc.add<std::vector<std::string>>(
"l1Algorithms", {});
880 desc.add<
unsigned int>(
"verbosityLevel", 0);
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
bool accept() const
Has at least one path accepted the event?
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, l1t::UseEventSetupIn use=l1t::UseEventSetupIn::RunAndEvent)
HLTConfigProvider hltConfig_
edm::InputTag dcsRecordInputTag_
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1GtTriggerMenuToken_
edm::InputTag hltInputTag_
const cms_uint16_t beamMode() const
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, const edm::Handle< DCSRecord > &dcsRecord, bool useDCSRecord, int dcsPartition) const
static const bool useL1GtTriggerMenuLite(false)
bool error() const
Has any path encountered an error (exception)
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
bool allHLTPathsAreValid() const
bool negate(std::string &word) const
Checks for negated words.
std::vector< std::string > hltLogicalExpressions_
std::vector< std::string > gtLogicalExpressions_
dictionary config
Read in AllInOne config in JSON format.
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
edm::InputTag gtInputTag_
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Class to contain DCS information from soft FED 1022.
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.
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
std::unique_ptr< L1GtUtils > l1Gt_
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
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
unsigned int size() const
number of trigger paths in trigger table
edm::EDGetTokenT< DCSRecord > dcsRecordToken_
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?
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
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
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms' logical expression?
const cms_uint16_t beamMomentum() const
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
std::vector< std::string > hltLogicalExpressionsCache_
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::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
virtual const bool expressionResult() 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?
bool acceptGt(const edm::Event &event)
Does this event fulfill the configured GT status logical expression combination?