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 //
40 
41 #include <memory>
42 #include <string>
43 
45  // Utility classes
46  std::unique_ptr<edm::ESWatcher<AlCaRecoTriggerBitsRcd> > watchDB_;
47  std::unique_ptr<L1GtUtils> l1Gt_;
48  std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
53  // Configuration parameters
54  bool andOr_;
56  unsigned verbose_;
57  bool andOrDcs_;
62  std::vector<int> dcsPartitions_;
64  bool andOrGt_;
70  std::vector<std::string> gtLogicalExpressions_;
72  bool andOrL1_;
73  bool stage2_;
76  std::vector<std::string> l1LogicalExpressionsCache_;
77  std::vector<std::string> l1LogicalExpressions_;
79  bool andOrHlt_;
83  std::vector<std::string> hltLogicalExpressionsCache_;
84  std::vector<std::string> hltLogicalExpressions_;
86  // Switches
87  bool on_;
88  bool onDcs_;
89  bool onGt_;
90  bool onL1_;
91  bool onHlt_;
92  // Member constants
95 
96 public:
97  //so passing in the owning EDProducer is a pain for me (S. Harper)
98  //and its only needed for legacy/stage1 L1 info which is mostly obsolete now
99  //defined a new constructor which doesnt allow for the use of legacy/stage 1 L1, only stage2
100  //so you no longer have to pass in the EDProducer
101  //however I set things up such that its an error to try and configure the stage-1 L1 here
102  //hence the extra private constructor
103  //tldr: use these constructors, not the other two if unsure, if you get it wrong, there'll be an error
104  //
105  //The last constructor argument declares whether EventSetup
106  //information is retrieved during beginRun, during the Event,
107  //or during both. This is needed to declare which EventSetup
108  //products are consumed. In the future, this will affect
109  //when prefetching is done. Declare both and it will always
110  //work, but there is some performance advantage to only
111  //declaring the necessary one. With only a few exceptions,
112  //existing clients call both initRun and accept (the two main
113  //functions in this class getting EventSetup data), so EventSetup
114  //objects might be retrieved in both periods. The argument defaults
115  //to this. The function expressionsFromDB also gets data from
116  //the EventSetup and is called by a few clients.
120  : GenericTriggerEventFlag(config, iC, use) {}
124 
125  // Constructors must be called from the ED module's c'tor
126  template <typename T>
129  T& module,
131 
132  template <typename T>
135  T& module,
137 
138  // Public methods
139  bool on() { return on_; }
140  bool off() { return (!on_); }
141  void initRun(const edm::Run& run, const edm::EventSetup& setup); // To be called from beginRun() methods
142  bool accept(const edm::Event& event, const edm::EventSetup& setup); // To be called from analyze/filter() methods
143 
144  bool allHLTPathsAreValid() const;
145 
147 
148 private:
150  // Private methods
151 
152  // DCS
153  bool acceptDcs(const edm::Event& event);
156  bool useDCSRecord,
157  int dcsPartition) const;
158 
159  // GT status bits
160  bool acceptGt(const edm::Event& event);
161  bool acceptGtLogicalExpression(const edm::Event& event, std::string gtLogicalExpression);
162 
163  // L1
164  bool acceptL1(const edm::Event& event, const edm::EventSetup& setup);
166  const edm::EventSetup& setup,
167  std::string l1LogicalExpression);
168 
169  // HLT
170  bool acceptHlt(const edm::Event& event);
171  bool acceptHltLogicalExpression(const edm::Handle<edm::TriggerResults>& hltTriggerResults,
172  std::string hltLogicalExpression) const;
173 
174  // Algos
175  std::string expandLogicalExpression(const std::vector<std::string>& target,
176  const std::string& expr,
177  bool useAnd = false) const;
178  bool negate(std::string& word) const;
179 
180 public:
181  // Methods for expert analysis
182 
183  std::string gtDBKey() { return gtDBKey_; } // can be empty
184  std::string l1DBKey() { return l1DBKey_; } // can be empty
185  std::string hltDBKey() { return hltDBKey_; } // can be empty
186 
187  // Must be called only during beginRun
188  std::vector<std::string> expressionsFromDB(const std::string& key, const edm::EventSetup& setup);
189 };
190 
191 template <typename T>
194  T& module,
196  : GenericTriggerEventFlag(config, iC, module, use) {}
197 
198 template <typename T>
201  T& module,
204  if (on_ && config.exists("andOrL1")) {
205  if (stage2_) {
206  l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC, use);
207  } else {
211  } else if (use == l1t::UseEventSetupIn::Event) {
212  useL1GtUtilsIn = L1GtUtils::UseEventSetupIn::Event;
213  }
214  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module, useL1GtUtilsIn);
215  }
216  }
217  //these pointers are already null so no need to reset them to a nullptr
218  //if andOrL1 doesnt exist
219 }
220 
221 #endif
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, l1t::UseEventSetupIn use=l1t::UseEventSetupIn::RunAndEvent)
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1GtTriggerMenuToken_
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, const edm::Handle< DCSRecord > &dcsRecord, bool useDCSRecord, int dcsPartition) 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_
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: config.py:1
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.
UseEventSetupIn
Definition: L1GtUtils.h:76
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.
uint64_t word
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
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&#39; logical expression?
std::vector< std::string > l1LogicalExpressionsCache_
bool acceptDcs(const edm::Event &event)
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alCaRecoTriggerBitsToken_
config
parse the configuration file
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_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
UseEventSetupIn
Definition: L1TGlobalUtil.h:42
long double T
static void fillPSetDescription(edm::ParameterSetDescription &desc)
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&#39; logical expression?
Definition: event.py:1
Definition: Run.h:45
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?