CMS 3D CMS Logo

GenericTriggerEventFlag.h
Go to the documentation of this file.
1 #ifndef GenericTriggerEventFlag_H
2 #define GenericTriggerEventFlag_H
3 
4 // -*- C++ -*-
5 //
6 // Package: CommonTools/TriggerUtils
7 // Class: GenericTriggerEventFlag
8 //
9 // $Id: GenericTriggerEventFlag.h,v 1.5 2012/01/19 20:17:34 vadler Exp $
10 //
34 
35 #include <memory>
36 #include <string>
37 
39  // Utility classes
40  std::unique_ptr<edm::ESWatcher<AlCaRecoTriggerBitsRcd> > watchDB_;
41  std::unique_ptr<L1GtUtils> l1Gt_;
42  std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
45  // Configuration parameters
46  bool andOr_;
48  unsigned verbose_;
49  bool andOrDcs_;
52  std::vector<int> dcsPartitions_;
54  bool andOrGt_;
60  std::vector<std::string> gtLogicalExpressions_;
62  bool andOrL1_;
63  bool stage2_;
66  std::vector<std::string> l1LogicalExpressionsCache_;
67  std::vector<std::string> l1LogicalExpressions_;
69  bool andOrHlt_;
73  std::vector<std::string> hltLogicalExpressionsCache_;
74  std::vector<std::string> hltLogicalExpressions_;
76  // Switches
77  bool on_;
78  bool onDcs_;
79  bool onGt_;
80  bool onL1_;
81  bool onHlt_;
82  // Member constants
85 
86 public:
87  //so passing in the owning EDProducer is a pain for me (S. Harper)
88  //and its only needed for legacy/stage1 L1 info which is mostly obsolete now
89  //defined a new constructor which doesnt allow for the use of legacy/stage 1 L1, only stage2
90  //so you no longer have to pass in the EDProducer
91  //however I set things up such that its an error to try and configure the stage-1 L1 here
92  //hence the extra private constructor
93  //tldr: use these constructors, not the other two if unsure, if you get it wrong, there'll be an error
95  : GenericTriggerEventFlag(config, iC) {}
97 
98  // Constructors must be called from the ED module's c'tor
99  template <typename T>
101 
102  template <typename T>
104 
105  // Public methods
106  bool on() { return on_; }
107  bool off() { return (!on_); }
108  void initRun(const edm::Run& run, const edm::EventSetup& setup); // To be called from beginRun() methods
109  bool accept(const edm::Event& event, const edm::EventSetup& setup); // To be called from analyze/filter() methods
110 
111  bool allHLTPathsAreValid() const;
112 
113 private:
114  GenericTriggerEventFlag(const edm::ParameterSet& config, edm::ConsumesCollector& iC, bool stage1Valid);
115  // Private methods
116 
117  // DCS
118  bool acceptDcs(const edm::Event& event);
119  bool acceptDcsPartition(const edm::Handle<DcsStatusCollection>& dcsStatus, int dcsPartition) const;
120 
121  // GT status bits
122  bool acceptGt(const edm::Event& event);
123  bool acceptGtLogicalExpression(const edm::Event& event, std::string gtLogicalExpression);
124 
125  // L1
126  bool acceptL1(const edm::Event& event, const edm::EventSetup& setup);
127  bool acceptL1LogicalExpression(const edm::Event& event,
128  const edm::EventSetup& setup,
129  std::string l1LogicalExpression);
130 
131  // HLT
132  bool acceptHlt(const edm::Event& event);
133  bool acceptHltLogicalExpression(const edm::Handle<edm::TriggerResults>& hltTriggerResults,
134  std::string hltLogicalExpression) const;
135 
136  // Algos
137  std::string expandLogicalExpression(const std::vector<std::string>& target,
138  const std::string& expr,
139  bool useAnd = false) const;
140  bool negate(std::string& word) const;
141 
142 public:
143  // Methods for expert analysis
144 
145  std::string gtDBKey() { return gtDBKey_; } // can be empty
146  std::string l1DBKey() { return l1DBKey_; } // can be empty
147  std::string hltDBKey() { return hltDBKey_; } // can be empty
148 
149  std::vector<std::string> expressionsFromDB(const std::string& key, const edm::EventSetup& setup);
150 };
151 
152 template <typename T>
155  T& module)
156  : GenericTriggerEventFlag(config, iC, module) {}
157 
158 template <typename T>
160  : GenericTriggerEventFlag(config, iC, true) {
161  if (config.exists("andOrL1")) {
162  if (stage2_) {
163  l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC);
164  } else {
165  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module);
166  }
167  }
168  //these pointers are already null so no need to reset them to a nullptr
169  //if andOrL1 doesnt exist
170 }
171 
172 #endif
bool negate(std::string &word) const
Checks for negated words.
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
std::vector< std::string > hltLogicalExpressions_
std::vector< std::string > gtLogicalExpressions_
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: config.py:1
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
config
Definition: looper.py:291
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
uint64_t word
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
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&#39; logical expression?
std::vector< std::string > l1LogicalExpressionsCache_
bool acceptDcs(const edm::Event &event)
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms&#39; logical expression?
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
std::vector< std::string > hltLogicalExpressionsCache_
std::vector< int > dcsPartitions_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
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_
long double T
Definition: vlib.h:198
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
Definition: event.py:1
Definition: Run.h:45
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; 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?