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 const AlgorithmMap& l1GtPhys(l1GtTriggerMenu.gtAlgorithmMap());
217 for (
CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo) {
218 algoNames.push_back(iAlgo->second.algoName());
220 const AlgorithmMap& l1GtTech(l1GtTriggerMenu.gtTechnicalTriggerMap());
221 for (
CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo) {
222 algoNames.push_back(iAlgo->second.algoName());
230 for (
size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo) {
231 const std::string l1AlgoName(l1AlgoLogicParser.operandTokenVector().at(iAlgo).tokenName);
232 if (l1AlgoName.find(
'*') != std::string::npos) {
233 l1LogicalExpression.replace(
240 for (
unsigned iExpr = 0; iExpr <
tmp.size(); ++iExpr)
241 if (
std::find(algoNames.begin(), algoNames.end(),
tmp[iExpr]) == algoNames.end()) {
245 <<
"L1 algorithm \"" <<
tmp[iExpr]
246 <<
"\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
255 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
256 const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
257 if (hltPathName.find(
'*') != std::string::npos) {
258 hltLogicalExpression.replace(hltLogicalExpression.find(hltPathName),
284 bool useDCSRecord(
false);
297 <<
"DcsStatusCollection product with InputTag \"" <<
dcsInputTag_.
encode() <<
"\" not in event \n" 302 if (dcsStatus.
isValid() && (*dcsStatus).empty()) {
303 if (
event.eventAuxiliary().isRealData()) {
327 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
335 for (std::vector<int>::const_iterator partitionNumber =
dcsPartitions_.begin();
347 int dcsPartition)
const {
348 int theDCSRecordPartition;
350 switch (dcsPartition) {
426 <<
"DCS partition number \"" << dcsPartition <<
"\" does not exist ==> decision: " <<
errorReplyDcs_;
432 return dcsStatus->at(0).ready(dcsPartition);
436 <<
"using dcs record, dcsPartition:" << dcsPartition <<
" " << theDCSRecordPartition <<
" " 437 << (*dcsRecord).partitionName(theDCSRecordPartition) <<
" " 438 << (*dcsRecord).highVoltageReady(theDCSRecordPartition) << std::endl;
440 return (*dcsRecord).highVoltageReady(theDCSRecordPartition);
454 ++gtLogicalExpression) {
462 ++gtLogicalExpression) {
472 if (gtLogicalExpression.empty()) {
479 bool negExpr(
negate(gtLogicalExpression));
480 if (negExpr && gtLogicalExpression.empty()) {
483 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyGt_;
490 for (
size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.
operandTokenVector().size(); ++iStatusBit) {
495 if (gtStatusBit ==
"PhysDecl" || gtStatusBit ==
"PhysicsDeclared") {
498 if (!gtReadoutRecord.
isValid()) {
501 <<
"L1GlobalTriggerReadoutRecord product with InputTag \"" <<
gtInputTag_.
encode()
507 }
else if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam" || gtStatusBit ==
"Adjust" ||
508 gtStatusBit ==
"Sqeeze" || gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop" || gtStatusBit ==
"7TeV" ||
509 gtStatusBit ==
"8TeV" || gtStatusBit ==
"13TeV" || gtStatusBit ==
"2360GeV" || gtStatusBit ==
"900GeV") {
512 if (!gtEvmReadoutRecord.
isValid()) {
520 if (gtStatusBit ==
"Stable" || gtStatusBit ==
"StableBeam") {
522 }
else if (gtStatusBit ==
"Adjust") {
524 }
else if (gtStatusBit ==
"Sqeeze") {
526 }
else if (gtStatusBit ==
"Flat" || gtStatusBit ==
"FlatTop") {
528 }
else if (gtStatusBit ==
"7TeV") {
530 }
else if (gtStatusBit ==
"8TeV") {
532 }
else if (gtStatusBit ==
"13TeV") {
534 }
else if (gtStatusBit ==
"2360GeV") {
536 }
else if (gtStatusBit ==
"900GeV") {
542 <<
"GT status bit \"" << gtStatusBit <<
"\" is not defined ==> decision: " <<
errorReplyGt_;
549 return negExpr ? (!gtDecision) : gtDecision;
562 ++l1LogicalExpression) {
570 ++l1LogicalExpression) {
589 if (l1LogicalExpression.empty()) {
596 bool negExpr(
negate(l1LogicalExpression));
597 if (negExpr && l1LogicalExpression.empty()) {
600 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyL1_;
607 for (
size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.
operandTokenVector().size(); ++iAlgorithm) {
610 bool decision =
false;
614 :
l1uGt_->getFinalDecisionByName(l1AlgoName, decision));
620 :
l1Gt_->decisionAfterMask(
event, l1AlgoName, errorINT));
621 error = (errorINT != 0);
625 <<
"L1 algorithm \"" << l1AlgoName <<
"\" received error code " <<
error 626 <<
" from L1GtUtils::decisionBeforeMask ==> decision: " <<
errorReplyL1_;
633 <<
"L1 algorithm \"" << l1AlgoName <<
"\" does not exist in the L1 menu ==> decision: " <<
errorReplyL1_;
643 return negExpr ? (!l1Decision) : l1Decision;
662 if (!hltTriggerResults.
isValid()) {
668 if ((*hltTriggerResults).size() == 0) {
679 ++hltLogicalExpression) {
687 ++hltLogicalExpression) {
698 if (hltLogicalExpression.empty()) {
705 bool negExpr(
negate(hltLogicalExpression));
706 if (negExpr && hltLogicalExpression.empty()) {
709 <<
"Empty (negated) logical expression ==> decision: " <<
errorReplyHlt_;
716 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
722 edm::LogWarning(
"GenericTriggerEventFlag") <<
"HLT path \"" << hltPathName <<
"\" is not found in process " 727 if (hltTriggerResults->
error(indexPath)) {
730 <<
"HLT path \"" << hltPathName <<
"\" in error ==> decision: " <<
errorReplyHlt_;
735 const bool decision(hltTriggerResults->
accept(indexPath));
741 return negExpr ? (!hltDecision) : hltDecision;
749 std::vector<std::string>
matched;
751 if (
expr.substr(
expr.size() - versionWildcard.size()) == versionWildcard) {
761 edm::LogWarning(
"GenericTriggerEventFlag") <<
"Logical expression: \"" <<
expr <<
"\" could not be resolved";
767 for (
unsigned iVers = 0; iVers <
matched.size(); ++iVers) {
769 expanded.append(useAnd ?
" AND " :
" OR ");
770 expanded.append(
matched.at(iVers));
772 expanded.append(
")");
774 edm::LogInfo(
"GenericTriggerEventFlag") <<
"Logical expression: \"" <<
expr <<
"\"\n" 775 <<
" --> expanded to \"" << expanded <<
"\"";
783 if (
word.at(0) ==
'~') {
795 std::vector<edm::eventsetup::DataKey>
labels;
797 std::vector<edm::eventsetup::DataKey>::const_iterator iKey =
labels.begin();
800 if (iKey ==
labels.end()) {
803 <<
"Label " <<
dbLabel_ <<
" not found in DB for 'AlCaRecoTriggerBitsRcd'";
807 const std::map<std::string, std::string>& expressionMap = alCaRecoTriggerBits.m_alcarecoToTrig;
808 std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(
key);
809 if (listIter == expressionMap.end()) {
812 <<
"No logical expressions found under key " <<
key <<
" in 'AlCaRecoTriggerBitsRcd'";
815 return alCaRecoTriggerBits.decompose(listIter->second);
826 <<
"HLTConfigProvider is not initialized, method will return \"false\"";
841 for (
size_t iPath = 0; iPath < hltAlgoLogicParser.
operandTokenVector().size(); ++iPath) {
849 <<
"HLT path \"" << hltPathName <<
"\" is not found in process " <<
hltInputTag_.
process();
861 desc.add<
bool>(
"ReadPrescalesFromFile",
false);
862 desc.add<
bool>(
"andOr",
false);
863 desc.add<
bool>(
"andOrDcs",
false);
864 desc.add<
bool>(
"andOrHlt",
false);
865 desc.add<
bool>(
"andOrL1",
false);
866 desc.add<
bool>(
"errorReplyDcs",
false);
867 desc.add<
bool>(
"errorReplyHlt",
false);
868 desc.add<
bool>(
"errorReplyL1",
false);
869 desc.add<
bool>(
"l1BeforeMask",
false);
870 desc.add<
bool>(
"stage2",
false);
878 desc.add<std::vector<int>>(
"dcsPartitions", {});
879 desc.add<std::vector<std::string>>(
"hltPaths", {});
880 desc.add<std::vector<std::string>>(
"l1Algorithms", {});
881 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_
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?
key
prepare the HTCondor submission files and eventually submit them
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_
dictionary config
Read in AllInOne config in JSON format.
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?