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 //
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,
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
GenericTriggerEventFlag::errorReplyDcs_
bool errorReplyDcs_
Definition: GenericTriggerEventFlag.h:59
GenericTriggerEventFlag::negate
bool negate(std::string &word) const
Checks for negated words.
Definition: GenericTriggerEventFlag.cc:695
GenericTriggerEventFlag::andOrGt_
bool andOrGt_
Definition: GenericTriggerEventFlag.h:60
GenericTriggerEventFlag::allHLTPathsAreValid
bool allHLTPathsAreValid() const
Definition: GenericTriggerEventFlag.cc:732
GenericTriggerEventFlag::hltInputTag_
edm::InputTag hltInputTag_
Definition: GenericTriggerEventFlag.h:76
GenericTriggerEventFlag::acceptHltLogicalExpression
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths' logical expression?
Definition: GenericTriggerEventFlag.cc:609
L1GtTriggerMenu.h
GenericTriggerEventFlag::errorReplyL1_
bool errorReplyL1_
Definition: GenericTriggerEventFlag.h:74
GenericTriggerEventFlag::acceptL1
bool acceptL1(const edm::Event &event, const edm::EventSetup &setup)
Was this event accepted by the configured L1 logical expression combination?
Definition: GenericTriggerEventFlag.cc:467
GenericTriggerEventFlag::hltDBKey_
std::string hltDBKey_
Definition: GenericTriggerEventFlag.h:78
L1GtUtils::UseEventSetupIn
UseEventSetupIn
Definition: L1GtUtils.h:76
GenericTriggerEventFlag::gtLogicalExpressions_
std::vector< std::string > gtLogicalExpressions_
Definition: GenericTriggerEventFlag.h:66
L1GtUtils::UseEventSetupIn::RunAndEvent
DcsStatus.h
TriggerResults.h
L1GtUtils::UseEventSetupIn::Event
GenericTriggerEventFlag::l1DBKey
std::string l1DBKey()
Definition: GenericTriggerEventFlag.h:175
GenericTriggerEventFlag::andOrL1_
bool andOrL1_
Definition: GenericTriggerEventFlag.h:68
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< DcsStatusCollection >
GenericTriggerEventFlag::acceptGt
bool acceptGt(const edm::Event &event)
Does this event fulfill the configured GT status logical expression combination?
Definition: GenericTriggerEventFlag.cc:359
L1GtTriggerMenuRcd.h
GenericTriggerEventFlag::dbLabel_
std::string dbLabel_
Definition: GenericTriggerEventFlag.h:53
GenericTriggerEventFlag::dcsInputToken_
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
Definition: GenericTriggerEventFlag.h:57
GenericTriggerEventFlag::l1Gt_
std::unique_ptr< L1GtUtils > l1Gt_
Definition: GenericTriggerEventFlag.h:45
GenericTriggerEventFlag::gtInputToken_
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
Definition: GenericTriggerEventFlag.h:62
GenericTriggerEventFlag::errorReplyHlt_
bool errorReplyHlt_
Definition: GenericTriggerEventFlag.h:81
GenericTriggerEventFlag::andOrHlt_
bool andOrHlt_
Definition: GenericTriggerEventFlag.h:75
GenericTriggerEventFlag::l1GtTriggerMenuToken_
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1GtTriggerMenuToken_
Definition: GenericTriggerEventFlag.h:49
GenericTriggerEventFlag::hltDBKey
std::string hltDBKey()
Definition: GenericTriggerEventFlag.h:176
l1t::UseEventSetupIn
UseEventSetupIn
Definition: L1TGlobalUtil.h:42
GenericTriggerEventFlag::expandLogicalExpression
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.
Definition: GenericTriggerEventFlag.cc:659
GenericTriggerEventFlag::hltConfigInit_
bool hltConfigInit_
Definition: GenericTriggerEventFlag.h:48
GenericTriggerEventFlag::hltLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
Definition: GenericTriggerEventFlag.h:80
l1t::UseEventSetupIn::Event
AlCaRecoTriggerBits.h
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
GenericTriggerEventFlag::l1DBKey_
std::string l1DBKey_
Definition: GenericTriggerEventFlag.h:71
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GenericTriggerEventFlag::onL1_
bool onL1_
Definition: GenericTriggerEventFlag.h:86
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
GenericTriggerEventFlag::acceptGtLogicalExpression
bool acceptGtLogicalExpression(const edm::Event &event, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits' logical expression?
Definition: GenericTriggerEventFlag.cc:384
config
Definition: config.py:1
L1GlobalTriggerEvmReadoutRecord.h
GenericTriggerEventFlag::gtInputTag_
edm::InputTag gtInputTag_
Definition: GenericTriggerEventFlag.h:61
GenericTriggerEventFlag::hltInputToken_
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
Definition: GenericTriggerEventFlag.h:77
GenericTriggerEventFlag::stage2_
bool stage2_
Definition: GenericTriggerEventFlag.h:69
GenericTriggerEventFlag::l1LogicalExpressionsCache_
std::vector< std::string > l1LogicalExpressionsCache_
Definition: GenericTriggerEventFlag.h:72
GenericTriggerEventFlag::l1BeforeMask_
bool l1BeforeMask_
Definition: GenericTriggerEventFlag.h:70
Run.h
GenericTriggerEventFlag::expressionsFromDB
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
Definition: GenericTriggerEventFlag.cc:705
GenericTriggerEventFlag::acceptDcsPartition
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
Definition: GenericTriggerEventFlag.cc:318
GenericTriggerEventFlag::gtDBKey_
std::string gtDBKey_
Definition: GenericTriggerEventFlag.h:65
GenericTriggerEventFlag::acceptHlt
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
Definition: GenericTriggerEventFlag.cc:561
funct::true
true
Definition: Factorize.h:173
GenericTriggerEventFlag::accept
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
Definition: GenericTriggerEventFlag.cc:266
edm::ParameterSet
Definition: ParameterSet.h:47
GenericTriggerEventFlag::onDcs_
bool onDcs_
Definition: GenericTriggerEventFlag.h:84
Event.h
L1GtUtils::UseEventSetupIn::Run
GenericTriggerEventFlag::onHlt_
bool onHlt_
Definition: GenericTriggerEventFlag.h:87
GenericTriggerEventFlag
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: GenericTriggerEventFlag.h:42
GenericTriggerEventFlag::gtEvmInputToken_
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
Definition: GenericTriggerEventFlag.h:64
AlCaRecoTriggerBitsRcd.h
GenericTriggerEventFlag::dcsPartitions_
std::vector< int > dcsPartitions_
Definition: GenericTriggerEventFlag.h:58
GenericTriggerEventFlag::onGt_
bool onGt_
Definition: GenericTriggerEventFlag.h:85
edm::EventSetup
Definition: EventSetup.h:58
GenericTriggerEventFlag::off
bool off()
Definition: GenericTriggerEventFlag.h:136
GenericTriggerEventFlag::on_
bool on_
Definition: GenericTriggerEventFlag.h:83
HLTConfigProvider.h
GenericTriggerEventFlag::gtDBKey
std::string gtDBKey()
Definition: GenericTriggerEventFlag.h:174
GenericTriggerEventFlag::andOr_
bool andOr_
Definition: GenericTriggerEventFlag.h:52
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd >
l1t::UseEventSetupIn::RunAndEvent
GenericTriggerEventFlag::configError_
const std::string configError_
Definition: GenericTriggerEventFlag.h:89
callgraph.module
module
Definition: callgraph.py:61
GenericTriggerEventFlag::emptyKeyError_
const std::string emptyKeyError_
Definition: GenericTriggerEventFlag.h:90
GenericTriggerEventFlag::gtEvmInputTag_
edm::InputTag gtEvmInputTag_
Definition: GenericTriggerEventFlag.h:63
GenericTriggerEventFlag::alCaRecoTriggerBitsToken_
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alCaRecoTriggerBitsToken_
Definition: GenericTriggerEventFlag.h:50
GenericTriggerEventFlag::on
bool on()
Definition: GenericTriggerEventFlag.h:135
HLTConfigProvider
Definition: HLTConfigProvider.h:29
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GenericTriggerEventFlag::andOrDcs_
bool andOrDcs_
Definition: GenericTriggerEventFlag.h:55
jets_cff.expr
expr
Definition: jets_cff.py:497
GenericTriggerEventFlag::verbose_
unsigned verbose_
Definition: GenericTriggerEventFlag.h:54
ESWatcher.h
T
long double T
Definition: Basic3DVectorLD.h:48
GenericTriggerEventFlag::acceptL1LogicalExpression
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms' logical expression?
Definition: GenericTriggerEventFlag.cc:492
L1GtUtils.h
GenericTriggerEventFlag::acceptDcs
bool acceptDcs(const edm::Event &event)
Definition: GenericTriggerEventFlag.cc:276
GenericTriggerEventFlag::hltLogicalExpressionsCache_
std::vector< std::string > hltLogicalExpressionsCache_
Definition: GenericTriggerEventFlag.h:79
GenericTriggerEventFlag::l1LogicalExpressions_
std::vector< std::string > l1LogicalExpressions_
Definition: GenericTriggerEventFlag.h:73
EventSetup.h
GenericTriggerEventFlag::dcsInputTag_
edm::InputTag dcsInputTag_
Definition: GenericTriggerEventFlag.h:56
GenericTriggerEventFlag::initRun
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
Definition: GenericTriggerEventFlag.cc:153
GenericTriggerEventFlag::watchDB_
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
Definition: GenericTriggerEventFlag.h:44
L1TGlobalUtil.h
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
GenericTriggerEventFlag::GenericTriggerEventFlag
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, l1t::UseEventSetupIn use=l1t::UseEventSetupIn::RunAndEvent)
Definition: GenericTriggerEventFlag.h:113
ConsumesCollector.h
GenericTriggerEventFlag::errorReplyGt_
bool errorReplyGt_
Definition: GenericTriggerEventFlag.h:67
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
GenericTriggerEventFlag::hltConfig_
HLTConfigProvider hltConfig_
Definition: GenericTriggerEventFlag.h:47
GenericTriggerEventFlag::l1uGt_
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
Definition: GenericTriggerEventFlag.h:46