CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //
38 
39 #include <memory>
40 #include <string>
41 
43  // Utility classes
44  std::unique_ptr<edm::ESWatcher<AlCaRecoTriggerBitsRcd> > watchDB_;
45  std::unique_ptr<L1GtUtils> l1Gt_;
46  std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
51  // Configuration parameters
52  bool andOr_;
54  unsigned verbose_;
55  bool andOrDcs_;
58  std::vector<int> dcsPartitions_;
60  bool andOrGt_;
66  std::vector<std::string> gtLogicalExpressions_;
68  bool andOrL1_;
69  bool stage2_;
72  std::vector<std::string> l1LogicalExpressionsCache_;
73  std::vector<std::string> l1LogicalExpressions_;
75  bool andOrHlt_;
79  std::vector<std::string> hltLogicalExpressionsCache_;
80  std::vector<std::string> hltLogicalExpressions_;
82  // Switches
83  bool on_;
84  bool onDcs_;
85  bool onGt_;
86  bool onL1_;
87  bool onHlt_;
88  // Member constants
91 
92 public:
93  //so passing in the owning EDProducer is a pain for me (S. Harper)
94  //and its only needed for legacy/stage1 L1 info which is mostly obsolete now
95  //defined a new constructor which doesnt allow for the use of legacy/stage 1 L1, only stage2
96  //so you no longer have to pass in the EDProducer
97  //however I set things up such that its an error to try and configure the stage-1 L1 here
98  //hence the extra private constructor
99  //tldr: use these constructors, not the other two if unsure, if you get it wrong, there'll be an error
100  //
101  //The last constructor argument declares whether EventSetup
102  //information is retrieved during beginRun, during the Event,
103  //or during both. This is needed to declare which EventSetup
104  //products are consumed. In the future, this will affect
105  //when prefetching is done. Declare both and it will always
106  //work, but there is some performance advantage to only
107  //declaring the necessary one. With only a few exceptions,
108  //existing clients call both initRun and accept (the two main
109  //functions in this class getting EventSetup data), so EventSetup
110  //objects might be retrieved in both periods. The argument defaults
111  //to this. The function expressionsFromDB also gets data from
112  //the EventSetup and is called by a few clients.
116  : GenericTriggerEventFlag(config, iC, use) {}
120 
121  // Constructors must be called from the ED module's c'tor
122  template <typename T>
125  T& module,
127 
128  template <typename T>
131  T& module,
133 
134  // Public methods
135  bool on() { return on_; }
136  bool off() { return (!on_); }
137  void initRun(const edm::Run& run, const edm::EventSetup& setup); // To be called from beginRun() methods
138  bool accept(const edm::Event& event, const edm::EventSetup& setup); // To be called from analyze/filter() methods
139 
140  bool allHLTPathsAreValid() const;
141 
142 private:
144  // Private methods
145 
146  // DCS
147  bool acceptDcs(const edm::Event& event);
148  bool acceptDcsPartition(const edm::Handle<DcsStatusCollection>& dcsStatus, int dcsPartition) const;
149 
150  // GT status bits
151  bool acceptGt(const edm::Event& event);
152  bool acceptGtLogicalExpression(const edm::Event& event, std::string gtLogicalExpression);
153 
154  // L1
155  bool acceptL1(const edm::Event& event, const edm::EventSetup& setup);
157  const edm::EventSetup& setup,
158  std::string l1LogicalExpression);
159 
160  // HLT
161  bool acceptHlt(const edm::Event& event);
162  bool acceptHltLogicalExpression(const edm::Handle<edm::TriggerResults>& hltTriggerResults,
163  std::string hltLogicalExpression) const;
164 
165  // Algos
166  std::string expandLogicalExpression(const std::vector<std::string>& target,
167  const std::string& expr,
168  bool useAnd = false) const;
169  bool negate(std::string& word) const;
170 
171 public:
172  // Methods for expert analysis
173 
174  std::string gtDBKey() { return gtDBKey_; } // can be empty
175  std::string l1DBKey() { return l1DBKey_; } // can be empty
176  std::string hltDBKey() { return hltDBKey_; } // can be empty
177 
178  // Must be called only during beginRun
179  std::vector<std::string> expressionsFromDB(const std::string& key, const edm::EventSetup& setup);
180 };
181 
182 template <typename T>
185  T& module,
187  : GenericTriggerEventFlag(config, iC, module, use) {}
188 
189 template <typename T>
192  T& module,
194  : GenericTriggerEventFlag(config, iC, true) {
195  if (on_ && config.exists("andOrL1")) {
196  if (stage2_) {
197  l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC, use);
198  } else {
202  } else if (use == l1t::UseEventSetupIn::Event) {
203  useL1GtUtilsIn = L1GtUtils::UseEventSetupIn::Event;
204  }
205  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module, useL1GtUtilsIn);
206  }
207  }
208  //these pointers are already null so no need to reset them to a nullptr
209  //if andOrL1 doesnt exist
210 }
211 
212 #endif
bool negate(std::string &word) const
Checks for negated words.
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, l1t::UseEventSetupIn use=l1t::UseEventSetupIn::RunAndEvent)
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1GtTriggerMenuToken_
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...
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?
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
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?
tuple key
prepare the HTCondor submission files and eventually submit them
std::vector< std::string > l1LogicalExpressionsCache_
bool acceptDcs(const edm::Event &event)
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alCaRecoTriggerBitsToken_
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_
tuple config
parse the configuration file
std::vector< int > dcsPartitions_
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_
UseEventSetupIn
Definition: L1TGlobalUtil.h:42
long double T
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
Definition: Run.h:45
tuple module
Definition: callgraph.py:69
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?