File indexing completed on 2024-04-06 12:01:14
0001 #ifndef GenericTriggerEventFlag_H
0002 #define GenericTriggerEventFlag_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "FWCore/Framework/interface/Run.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/Framework/interface/ESWatcher.h"
0025 #include "FWCore/Framework/interface/ConsumesCollector.h"
0026 #include "FWCore/Utilities/interface/ESGetToken.h"
0027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0028 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
0029 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
0030 #include "CondFormats/HLTObjects/interface/AlCaRecoTriggerBits.h"
0031 #include "CondFormats/DataRecord/interface/AlCaRecoTriggerBitsRcd.h"
0032 #include "DataFormats/Common/interface/TriggerResults.h"
0033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0034 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0035 #include "DataFormats/Scalers/interface/DcsStatus.h"
0036 #include "DataFormats/OnlineMetaData/interface/DCSRecord.h"
0037 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
0038 #include "L1Trigger/L1TGlobal/interface/L1TGlobalUtil.h"
0039 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0040
0041 #include <memory>
0042 #include <string>
0043
0044 class GenericTriggerEventFlag {
0045
0046 std::unique_ptr<edm::ESWatcher<AlCaRecoTriggerBitsRcd> > watchDB_;
0047 std::unique_ptr<L1GtUtils> l1Gt_;
0048 std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
0049 HLTConfigProvider hltConfig_;
0050 bool hltConfigInit_;
0051 edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> l1GtTriggerMenuToken_;
0052 edm::ESGetToken<AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd> alCaRecoTriggerBitsToken_;
0053
0054 bool andOr_;
0055 std::string dbLabel_;
0056 unsigned verbose_;
0057 bool andOrDcs_;
0058 edm::InputTag dcsInputTag_;
0059 edm::InputTag dcsRecordInputTag_;
0060 edm::EDGetTokenT<DcsStatusCollection> dcsInputToken_;
0061 edm::EDGetTokenT<DCSRecord> dcsRecordToken_;
0062 std::vector<int> dcsPartitions_;
0063 bool errorReplyDcs_;
0064 bool andOrGt_;
0065 edm::InputTag gtInputTag_;
0066 edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtInputToken_;
0067 edm::InputTag gtEvmInputTag_;
0068 edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> gtEvmInputToken_;
0069 std::string gtDBKey_;
0070 std::vector<std::string> gtLogicalExpressions_;
0071 bool errorReplyGt_;
0072 bool andOrL1_;
0073 bool stage2_;
0074 bool l1BeforeMask_;
0075 std::string l1DBKey_;
0076 std::vector<std::string> l1LogicalExpressionsCache_;
0077 std::vector<std::string> l1LogicalExpressions_;
0078 bool errorReplyL1_;
0079 bool andOrHlt_;
0080 edm::InputTag hltInputTag_;
0081 edm::EDGetTokenT<edm::TriggerResults> hltInputToken_;
0082 std::string hltDBKey_;
0083 std::vector<std::string> hltLogicalExpressionsCache_;
0084 std::vector<std::string> hltLogicalExpressions_;
0085 bool errorReplyHlt_;
0086
0087 bool on_;
0088 bool onDcs_;
0089 bool onGt_;
0090 bool onL1_;
0091 bool onHlt_;
0092
0093 const std::string configError_;
0094 const std::string emptyKeyError_;
0095
0096 public:
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 GenericTriggerEventFlag(const edm::ParameterSet& config,
0118 edm::ConsumesCollector&& iC,
0119 l1t::UseEventSetupIn use = l1t::UseEventSetupIn::RunAndEvent)
0120 : GenericTriggerEventFlag(config, iC, use) {}
0121 GenericTriggerEventFlag(const edm::ParameterSet& config,
0122 edm::ConsumesCollector& iC,
0123 l1t::UseEventSetupIn use = l1t::UseEventSetupIn::RunAndEvent);
0124
0125
0126 template <typename T>
0127 GenericTriggerEventFlag(const edm::ParameterSet& config,
0128 edm::ConsumesCollector&& iC,
0129 T& module,
0130 l1t::UseEventSetupIn use = l1t::UseEventSetupIn::RunAndEvent);
0131
0132 template <typename T>
0133 GenericTriggerEventFlag(const edm::ParameterSet& config,
0134 edm::ConsumesCollector& iC,
0135 T& module,
0136 l1t::UseEventSetupIn use = l1t::UseEventSetupIn::RunAndEvent);
0137
0138
0139 bool on() { return on_; }
0140 bool off() { return (!on_); }
0141 void initRun(const edm::Run& run, const edm::EventSetup& setup);
0142 bool accept(const edm::Event& event, const edm::EventSetup& setup);
0143
0144 bool allHLTPathsAreValid() const;
0145
0146 static void fillPSetDescription(edm::ParameterSetDescription& desc);
0147
0148 private:
0149 GenericTriggerEventFlag(const edm::ParameterSet& config, edm::ConsumesCollector& iC, bool stage1Valid);
0150
0151
0152
0153 bool acceptDcs(const edm::Event& event);
0154 bool acceptDcsPartition(const edm::Handle<DcsStatusCollection>& dcsStatus,
0155 const edm::Handle<DCSRecord>& dcsRecord,
0156 bool useDCSRecord,
0157 int dcsPartition) const;
0158
0159
0160 bool acceptGt(const edm::Event& event);
0161 bool acceptGtLogicalExpression(const edm::Event& event, std::string gtLogicalExpression);
0162
0163
0164 bool acceptL1(const edm::Event& event, const edm::EventSetup& setup);
0165 bool acceptL1LogicalExpression(const edm::Event& event,
0166 const edm::EventSetup& setup,
0167 std::string l1LogicalExpression);
0168
0169
0170 bool acceptHlt(const edm::Event& event);
0171 bool acceptHltLogicalExpression(const edm::Handle<edm::TriggerResults>& hltTriggerResults,
0172 std::string hltLogicalExpression) const;
0173
0174
0175 std::string expandLogicalExpression(const std::vector<std::string>& target,
0176 const std::string& expr,
0177 bool useAnd = false) const;
0178 bool negate(std::string& word) const;
0179
0180 public:
0181
0182
0183 std::string gtDBKey() { return gtDBKey_; }
0184 std::string l1DBKey() { return l1DBKey_; }
0185 std::string hltDBKey() { return hltDBKey_; }
0186
0187
0188 std::vector<std::string> expressionsFromDB(const std::string& key, const edm::EventSetup& setup);
0189 };
0190
0191 template <typename T>
0192 GenericTriggerEventFlag::GenericTriggerEventFlag(const edm::ParameterSet& config,
0193 edm::ConsumesCollector&& iC,
0194 T& module,
0195 l1t::UseEventSetupIn use)
0196 : GenericTriggerEventFlag(config, iC, module, use) {}
0197
0198 template <typename T>
0199 GenericTriggerEventFlag::GenericTriggerEventFlag(const edm::ParameterSet& config,
0200 edm::ConsumesCollector& iC,
0201 T& module,
0202 l1t::UseEventSetupIn use)
0203 : GenericTriggerEventFlag(config, iC, true) {
0204 if (on_ && config.exists("andOrL1")) {
0205 if (stage2_) {
0206 l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC, use);
0207 } else {
0208 L1GtUtils::UseEventSetupIn useL1GtUtilsIn = L1GtUtils::UseEventSetupIn::Run;
0209 if (use == l1t::UseEventSetupIn::RunAndEvent) {
0210 useL1GtUtilsIn = L1GtUtils::UseEventSetupIn::RunAndEvent;
0211 } else if (use == l1t::UseEventSetupIn::Event) {
0212 useL1GtUtilsIn = L1GtUtils::UseEventSetupIn::Event;
0213 }
0214 l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module, useL1GtUtilsIn);
0215 }
0216 }
0217
0218
0219 }
0220
0221 #endif