CMS 3D CMS Logo

L1GtUtils.h
Go to the documentation of this file.
1 #ifndef GlobalTriggerAnalyzer_L1GtUtils_h
2 #define GlobalTriggerAnalyzer_L1GtUtils_h
3 
18 // system include files
19 #include <memory>
20 #include <string>
21 #include <utility>
22 
23 // user include files
25 
29 
32 
34 
36 
37 // forward declarations
40 class L1GtTriggerMask;
41 class L1GtTriggerMenu;
42 
45 
46 // class declaration
47 
48 class L1GtUtils {
49 public:
50  // Using this constructor will require InputTags to be specified in the configuration
52 
53  L1GtUtils(edm::ParameterSet const& pset, edm::ConsumesCollector& iC, bool useL1GtTriggerMenuLite);
54 
55  // Using this constructor will cause it to look for valid InputTags in
56  // the following ways in the specified order until they are found.
57  // 1. The configuration
58  // 2. Search all products from the preferred input tags for the required type
59  // 3. Search all products from any other process for the required type
60  template <typename T>
61  L1GtUtils(edm::ParameterSet const& pset, edm::ConsumesCollector&& iC, bool useL1GtTriggerMenuLite, T& module);
62 
63  template <typename T>
64  L1GtUtils(edm::ParameterSet const& pset, edm::ConsumesCollector& iC, bool useL1GtTriggerMenuLite, T& module);
65 
66  // Using this constructor will cause it to look for valid InputTags in
67  // the following ways in the specified order until they are found.
68  // 1. The constructor arguments
69  // 2. The configuration
70  // 3. Search all products from the preferred input tags for the required type
71  // 4. Search all products from any other process for the required type
72  template <typename T>
73  L1GtUtils(edm::ParameterSet const& pset,
75  bool useL1GtTriggerMenuLite,
76  T& module,
80 
81  template <typename T>
82  L1GtUtils(edm::ParameterSet const& pset,
84  bool useL1GtTriggerMenuLite,
85  T& module,
86  edm::InputTag const& l1GtRecordInputTag,
87  edm::InputTag const& l1GtReadoutRecordInputTag,
88  edm::InputTag const& l1GtTriggerMenuLiteInputTag);
89 
91  virtual ~L1GtUtils();
92 
94 
95 public:
97 
114  public:
116 
119 
122 
123  public:
125  inline bool isValid() { return m_validLogicalExpression; }
126 
129  const int logicalExpressionRunUpdate(const edm::Run&, const edm::EventSetup&, const std::string&);
130  //
132  const int logicalExpressionRunUpdate(const edm::Run&, const edm::EventSetup&);
133 
135 
136  inline const std::vector<L1GtLogicParser::OperandToken>& expL1Triggers() { return m_expL1Triggers; }
137  const std::vector<std::pair<std::string, bool> >& decisionsBeforeMask();
138  const std::vector<std::pair<std::string, bool> >& decisionsAfterMask();
139  const std::vector<std::pair<std::string, int> >& prescaleFactors();
140  const std::vector<std::pair<std::string, int> >& triggerMasks();
141 
142  const std::vector<std::pair<std::string, int> >& errorCodes(const edm::Event&);
143 
144  private:
147  bool initialize();
148 
150  void reset(const std::vector<std::pair<std::string, bool> >&) const;
151  void reset(const std::vector<std::pair<std::string, int> >&) const;
152 
153  void l1Results(const edm::Event& iEvent);
154 
155  private:
157 
160 
162 
163  private:
164  // private members
165 
168 
171 
174 
177 
178  std::vector<L1GtLogicParser::OperandToken> m_expL1Triggers;
180 
182  std::vector<L1GtUtils::TriggerCategory> m_expTriggerCategory;
183 
186 
189  std::vector<bool> m_expTriggerInMenu;
190 
192  std::vector<std::pair<std::string, bool> > m_decisionsBeforeMask;
193  std::vector<std::pair<std::string, bool> > m_decisionsAfterMask;
194  std::vector<std::pair<std::string, int> > m_prescaleFactors;
195  std::vector<std::pair<std::string, int> > m_triggerMasks;
196  std::vector<std::pair<std::string, int> > m_errorCodes;
197  };
198 
199 public:
201 
202  // enum to string for TriggerCategory
203  const std::string triggerCategory(const TriggerCategory&) const;
204 
207 
209 
212 
214 
216  void getL1GtRunCache(const edm::Run&, const edm::EventSetup&, const bool, const bool);
217 
219  void getL1GtRunCache(const edm::Event&, const edm::EventSetup&, const bool, const bool);
220 
229 
230  const bool l1AlgoTechTrigBitNumber(const std::string& nameAlgoTechTrig,
231  TriggerCategory& trigCategory,
232  int& bitNumber) const;
233 
239 
240  const bool l1TriggerNameFromBit(const int& bitNumber,
241  const TriggerCategory& trigCategory,
242  std::string& aliasL1Trigger,
243  std::string& nameL1Trigger) const;
244 
255 
256  const int l1Results(const edm::Event& iEvent,
257  const std::string& nameAlgoTechTrig,
258  bool& decisionBeforeMask,
259  bool& decisionAfterMask,
260  int& prescaleFactor,
261  int& triggerMask) const;
262 
272 
274  const bool decisionBeforeMask(const edm::Event& iEvent, const std::string& nameAlgoTechTrig, int& errorCode) const;
275 
277  const bool decisionAfterMask(const edm::Event& iEvent, const std::string& nameAlgoTechTrig, int& errorCode) const;
278 
281  const bool decision(const edm::Event& iEvent, const std::string& nameAlgoTechTrig, int& errorCode) const;
282 
284  const int prescaleFactor(const edm::Event& iEvent, const std::string& nameAlgoTechTrig, int& errorCode) const;
285 
287  const int triggerMask(const edm::Event& iEvent, const std::string& nameAlgoTechTrig, int& errorCode) const;
288 
291  const int triggerMask(const std::string& nameAlgoTechTrig, int& errorCode) const;
292 
297 
298  const int prescaleFactorSetIndex(const edm::Event& iEvent, const TriggerCategory& trigCategory, int& errorCode) const;
299 
303 
304  const std::vector<int>& prescaleFactorSet(const edm::Event& iEvent,
305  const TriggerCategory& trigCategory,
306  int& errorCode);
307 
310  const std::vector<unsigned int>& triggerMaskSet(const TriggerCategory& trigCategory, int& errorCode);
311 
313  const std::string& l1TriggerMenu() const;
314 
317 
319  const L1GtTriggerMenu* ptrL1TriggerMenuEventSetup(int& errorCode);
320 
322  const L1GtTriggerMenuLite* ptrL1GtTriggerMenuLite(int& errorCode);
323 
326  const bool availableL1Configuration(int& errorCode, int& l1ConfCode) const;
327 
328 private:
329  static const std::string EmptyString;
330  static const int L1GtNotValidError;
331 
335  const bool trigResult(const DecisionWord& decWord,
336  const int bitNumber,
337  const std::string& nameAlgoTechTrig,
338  const TriggerCategory& trigCategory,
339  int& errorCode) const;
340 
341 private:
342  L1GtUtils();
343 
345 
348  unsigned long long m_l1GtStableParCacheID;
349 
352 
355 
358  unsigned long long m_l1GtPfAlgoCacheID;
359 
361  unsigned long long m_l1GtPfTechCacheID;
362 
363  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
364  const std::vector<std::vector<int> >* m_prescaleFactorsTechTrig;
365 
368  unsigned long long m_l1GtTmAlgoCacheID;
369 
371  unsigned long long m_l1GtTmTechCacheID;
372 
374  unsigned long long m_l1GtTmVetoAlgoCacheID;
375 
377  unsigned long long m_l1GtTmVetoTechCacheID;
378 
379  const std::vector<unsigned int>* m_triggerMaskAlgoTrig;
380  const std::vector<unsigned int>* m_triggerMaskTechTrig;
381 
382  const std::vector<unsigned int>* m_triggerMaskVetoAlgoTrig;
383  const std::vector<unsigned int>* m_triggerMaskVetoTechTrig;
384 
385  // trigger menu
387  unsigned long long m_l1GtMenuCacheID;
388 
392 
394 
396 
399 
403 
404  const std::vector<unsigned int>* m_triggerMaskAlgoTrigLite;
405  const std::vector<unsigned int>* m_triggerMaskTechTrigLite;
406 
407  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrigLite;
408  const std::vector<std::vector<int> >* m_prescaleFactorsTechTrigLite;
409 
411 
414 
417 
418 private:
420  unsigned int m_physicsDaqPartition;
421 
422  std::vector<unsigned int> m_triggerMaskSet;
423  std::vector<int> m_prescaleFactorSet;
424 
428 
429  std::unique_ptr<L1GtUtilsHelper> m_l1GtUtilsHelper;
430 };
431 
432 template <typename T>
434  : L1GtUtils(pset, iC, useL1GtTriggerMenuLite, module) {}
435 
436 template <typename T>
438  : L1GtUtils() {
439  m_l1GtUtilsHelper.reset(new L1GtUtilsHelper(pset, iC, useL1GtTriggerMenuLite, module));
440 }
441 
442 template <typename T>
446  T& module,
450  : L1GtUtils(pset,
451  iC,
452  useL1GtTriggerMenuLite,
453  module,
454  l1GtRecordInputTag,
455  l1GtReadoutRecordInputTag,
456  l1GtTriggerMenuLiteInputTag) {}
457 
458 template <typename T>
462  T& module,
466  : L1GtUtils() {
467  m_l1GtUtilsHelper.reset(new L1GtUtilsHelper(pset,
468  iC,
469  useL1GtTriggerMenuLite,
470  module,
471  l1GtRecordInputTag,
472  l1GtReadoutRecordInputTag,
473  l1GtTriggerMenuLiteInputTag));
474 }
475 
476 #endif /*GlobalTriggerAnalyzer_L1GtUtils_h*/
bool m_retrieveL1GtTriggerMenuLite
Definition: L1GtUtils.h:427
edm::RunID m_runIDCache
run cache ID
Definition: L1GtUtils.h:416
bool m_validLogicalExpression
true if the logical expression uses accepted L1GtLogicParser operators
Definition: L1GtUtils.h:173
const bool l1TriggerNameFromBit(const int &bitNumber, const TriggerCategory &trigCategory, std::string &aliasL1Trigger, std::string &nameL1Trigger) const
Definition: L1GtUtils.cc:441
void l1Results(const edm::Event &iEvent)
Definition: L1GtUtils.cc:2042
LogicalExpressionL1Results(const std::string &, L1GtUtils &)
constructor(s)
Definition: L1GtUtils.cc:1743
std::vector< std::pair< std::string, bool > > m_decisionsBeforeMask
Definition: L1GtUtils.h:192
std::vector< unsigned int > m_triggerMaskSet
Definition: L1GtUtils.h:422
unsigned long long m_l1GtMenuCacheID
Definition: L1GtUtils.h:387
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
Definition: L1GtUtils.h:379
const int logicalExpressionRunUpdate(const edm::Run &, const edm::EventSetup &, const std::string &)
Definition: L1GtUtils.cc:1853
std::vector< L1GtLogicParser::OperandToken > m_expL1Triggers
Definition: L1GtUtils.h:178
const L1GtTriggerMenuLite * ptrL1GtTriggerMenuLite(int &errorCode)
return a pointer to the L1GtTriggerMenuLite product
Definition: L1GtUtils.cc:1603
int m_l1ConfCode
code for L1 trigger configuration
Definition: L1GtUtils.h:167
const std::vector< unsigned int > * m_triggerMaskTechTrig
Definition: L1GtUtils.h:380
const L1GtTriggerMask * m_l1GtTmVetoTech
Definition: L1GtUtils.h:376
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
const bool l1AlgoTechTrigBitNumber(const std::string &nameAlgoTechTrig, TriggerCategory &trigCategory, int &bitNumber) const
Definition: L1GtUtils.cc:329
const int prescaleFactorSetIndex(const edm::Event &iEvent, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1227
TriggerCategory
Definition: L1GtUtils.h:96
const bool availableL1Configuration(int &errorCode, int &l1ConfCode) const
Definition: L1GtUtils.cc:1637
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrigLite
Definition: L1GtUtils.h:407
virtual ~L1GtUtils()
destructor
Definition: L1GtUtils.cc:94
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks & veto masks
Definition: L1GtUtils.h:367
const AlgorithmMap * m_algorithmMap
Definition: L1GtUtils.h:389
const std::vector< std::pair< std::string, int > > & prescaleFactors()
Definition: L1GtUtils.cc:1981
const bool decision(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
Definition: L1GtUtils.cc:1024
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
Definition: L1GtUtils.h:364
const L1GtStableParameters * m_l1GtStablePar
event setup cached stuff
Definition: L1GtUtils.h:347
unsigned long long m_l1GtPfAlgoCacheID
Definition: L1GtUtils.h:358
const std::vector< unsigned int > & triggerMaskSet(const TriggerCategory &trigCategory, int &errorCode)
Definition: L1GtUtils.cc:1455
const std::vector< std::pair< std::string, int > > & triggerMasks()
Definition: L1GtUtils.cc:1993
const std::string & l1TriggerMenu() const
return the L1 trigger menu name
Definition: L1GtUtils.cc:1535
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1GtUtils.h:363
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmAliasMapLite
Definition: L1GtUtils.h:401
std::map< unsigned int, std::string > L1TriggerMap
map containing the physics algorithms or the technical triggers
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmMapLite
Definition: L1GtUtils.h:400
unsigned long long m_l1GtTmVetoTechCacheID
Definition: L1GtUtils.h:377
const std::vector< std::pair< std::string, bool > > & decisionsAfterMask()
Definition: L1GtUtils.cc:1969
std::vector< std::pair< std::string, int > > m_errorCodes
Definition: L1GtUtils.h:196
std::vector< std::pair< std::string, int > > m_triggerMasks
Definition: L1GtUtils.h:195
std::vector< std::pair< std::string, int > > m_prescaleFactors
Definition: L1GtUtils.h:194
const std::vector< std::pair< std::string, bool > > & decisionsBeforeMask()
Definition: L1GtUtils.cc:1957
int iEvent
Definition: GenABIO.cc:224
const std::string & l1TriggerMenuImplementation() const
return the L1 trigger menu implementation
Definition: L1GtUtils.cc:1556
const AlgorithmMap * m_algorithmAliasMap
Definition: L1GtUtils.h:390
unsigned long long m_l1GtTmTechCacheID
Definition: L1GtUtils.h:371
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrigLite
Definition: L1GtUtils.h:408
const L1GtTriggerMask * m_l1GtTmVetoAlgo
Definition: L1GtUtils.h:373
std::vector< bool > DecisionWord
typedefs
static const std::string EmptyString
Definition: L1GtUtils.h:329
const std::string triggerCategory(const TriggerCategory &) const
public methods
Definition: L1GtUtils.cc:98
std::string m_logicalExpression
private members as input parameters
Definition: L1GtUtils.h:159
const L1GtPrescaleFactors * m_l1GtPfAlgo
prescale factors
Definition: L1GtUtils.h:357
unsigned long long m_l1GtTmAlgoCacheID
Definition: L1GtUtils.h:368
static void fillDescription(edm::ParameterSetDescription &desc)
unsigned int m_numberTechnicalTriggers
number of technical triggers
Definition: L1GtUtils.h:354
std::vector< bool > m_expTriggerInMenu
Definition: L1GtUtils.h:189
const std::vector< L1GtLogicParser::OperandToken > & expL1Triggers()
list of triggers in the logical expression, trigger decisions, prescale factors and masks...
Definition: L1GtUtils.h:136
bool m_retrieveL1EventSetup
flags to check which method was used to retrieve L1 trigger configuration
Definition: L1GtUtils.h:426
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:112
unsigned int m_physicsDaqPartition
index of physics DAQ partition
Definition: L1GtUtils.h:420
unsigned int m_numberAlgorithmTriggers
number of algorithm triggers
Definition: L1GtUtils.h:351
const int triggerMask(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1050
bool m_l1ResultsAlreadyCalled
set to true if the method l1Results was called once
Definition: L1GtUtils.h:176
const std::vector< int > & prescaleFactorSet(const edm::Event &iEvent, const TriggerCategory &trigCategory, int &errorCode)
Definition: L1GtUtils.cc:1399
bool m_expBitsTechTrigger
flag true, if the logical expression is built from technical trigger bits
Definition: L1GtUtils.h:185
std::vector< L1GtUtils::TriggerCategory > m_expTriggerCategory
trigger category for each L1 trigger in the logical expression
Definition: L1GtUtils.h:182
const L1GtTriggerMask * m_l1GtTmTech
Definition: L1GtUtils.h:370
const L1GtTriggerMenuLite * m_l1GtMenuLite
L1GtTriggerMenuLite cached stuff.
Definition: L1GtUtils.h:398
const bool decisionBeforeMask(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision before trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:996
void reset(const std::vector< std::pair< std::string, bool > > &) const
reset for each L1 trigger the value from pair.second
Definition: L1GtUtils.cc:2028
const L1GtPrescaleFactors * m_l1GtPfTech
Definition: L1GtUtils.h:360
const AlgorithmMap * m_technicalTriggerMap
Definition: L1GtUtils.h:391
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1GtUtils.h:93
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
Definition: L1GtUtils.h:382
std::unique_ptr< L1GtUtilsHelper > m_l1GtUtilsHelper
Definition: L1GtUtils.h:429
const std::vector< unsigned int > * m_triggerMaskTechTrigLite
Definition: L1GtUtils.h:405
static const bool useL1GtTriggerMenuLite(true)
bool m_l1GtMenuLiteValid
Definition: L1GtUtils.h:410
const std::vector< unsigned int > * m_triggerMaskAlgoTrigLite
Definition: L1GtUtils.h:404
bool m_beginRunCache
flag for call of getL1GtRunCache in beginRun
Definition: L1GtUtils.h:413
const bool trigResult(const DecisionWord &decWord, const int bitNumber, const std::string &nameAlgoTechTrig, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1722
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool)
get all the run-constant quantities for L1 trigger and cache them
Definition: L1GtUtils.cc:274
bool m_validL1Configuration
true if valid L1 configuration - if not, reset all quantities and return
Definition: L1GtUtils.h:170
const L1GtTriggerMenu * m_l1GtMenu
Definition: L1GtUtils.h:386
unsigned long long m_l1GtPfTechCacheID
Definition: L1GtUtils.h:361
static const int L1GtNotValidError
Definition: L1GtUtils.h:330
std::vector< std::pair< std::string, bool > > m_decisionsAfterMask
Definition: L1GtUtils.h:193
bool m_l1EventSetupValid
Definition: L1GtUtils.h:393
unsigned long long m_l1GtTmVetoAlgoCacheID
Definition: L1GtUtils.h:374
std::vector< int > m_prescaleFactorSet
Definition: L1GtUtils.h:423
const L1GtTriggerMenu * ptrL1TriggerMenuEventSetup(int &errorCode)
return a pointer to the L1 trigger menu from event setup
Definition: L1GtUtils.cc:1577
const bool decisionAfterMask(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision after trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1010
long double T
Definition: vlib.h:198
unsigned long long m_l1GtStableParCacheID
Definition: L1GtUtils.h:348
const L1GtTriggerMenuLite::L1TriggerMap * m_technicalTriggerMapLite
Definition: L1GtUtils.h:402
bool isValid()
return true if the logical expression is syntactically correct
Definition: L1GtUtils.h:125
Definition: Run.h:45
const std::vector< unsigned int > * m_triggerMaskVetoTechTrig
Definition: L1GtUtils.h:383
void retrieveL1GtTriggerMenuLite(const edm::Run &)
retrieve L1GtTriggerMenuLite (per run product) and cache it to improve the speed
Definition: L1GtUtils.cc:241
const std::vector< std::pair< std::string, int > > & errorCodes(const edm::Event &)
Definition: L1GtUtils.cc:2005
const int prescaleFactor(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return prescale factor for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1036