CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TGlobalUtil.h
Go to the documentation of this file.
1 // L1TGlobalUtil: Utility class for parsing the L1 Trigger Menu
2 
3 #ifndef L1TGlobal_L1TGlobalUtil_h
4 #define L1TGlobal_L1TGlobalUtil_h
5 
6 // system include files
7 #include <memory>
8 
9 #include <vector>
10 
13 
16 
17 // Objects to produce for the output record.
21 
26 
28 
30 
32 
33 // forward declarations
34 
35 // class declaration
36 
37 namespace l1t {
38 
39  // Use this to tell the EventSetup whether it should prefetch
40  // data when processing beginRun or an Event or both. (This
41  // depends on when retrieveL1 and retrieveL1Setup are called)
43 
44  class L1TGlobalUtil {
45  public:
46  // Using this constructor will require InputTags to be specified in the configuration
50 
51  L1TGlobalUtil(edm::ParameterSet const& pset,
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  L1TGlobalUtil(edm::ParameterSet const& pset,
63  T& module,
65 
66  template <typename T>
67  L1TGlobalUtil(edm::ParameterSet const& pset,
69  T& module,
71 
72  // Using this constructor will cause it to look for valid InputTags in
73  // the following ways in the specified order until they are found.
74  // 1. The constructor arguments
75  // 2. The configuration
76  // 3. Search all products from the preferred input tags for the required type
77  // 4. Search all products from any other process for the required type
78  template <typename T>
79  L1TGlobalUtil(edm::ParameterSet const& pset,
81  T& module,
82  edm::InputTag const& l1tAlgBlkInputTag,
83  edm::InputTag const& l1tExtBlkInputTag,
85 
86  template <typename T>
87  L1TGlobalUtil(edm::ParameterSet const& pset,
89  T& module,
90  edm::InputTag const& l1tAlgBlkInputTag,
91  edm::InputTag const& l1tExtBlkInputTag,
93 
95  virtual ~L1TGlobalUtil();
96 
98  bool valid() const;
99 
101 
102  // OverridePrescalesAndMasks
103  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
104  // It is provided only until prescales and masks are available as CondFormats...
105  // Most users should simply ignore this method and use the default ctor only!
106  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
107  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn = 1.);
108 
110  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
111  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
112  void retrieveL1Setup(const edm::EventSetup& evSetup); // Use this one only during beginRun
113  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
114  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
115 
116  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
117 
118  inline bool getFinalOR() const { return m_finalOR; }
119 
120  // get the trigger bit from the name
121  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
122 
123  // get the name from the trigger bit
124  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
125 
126  // Access results for particular trigger bit
127  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
128  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
129  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
130 
131  // Access Prescale
132  const bool getPrescaleByBit(int& bit, double& prescale) const;
133 
134  // Access Masks:
135  // follows logic of uGT board:
136  // finalDecision[AlgBit]
137  // Final word is after application of prescales.
138  // A prescale = 0 effectively masks out the algorithm in the final decision word
139  //
140  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
141 
142  // Access results for particular trigger name
143  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
144  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
145  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
146 
147  // Access Prescales
148  const bool getPrescaleByName(const std::string& algName, double& prescale) const;
149 
150  // Access Masks (see note) above
151  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
152 
153  // Some inline commands to return the full vectors
154  inline const std::vector<std::pair<std::string, bool>>& decisionsInitial() { return m_decisionsInitial; }
155  inline const std::vector<std::pair<std::string, bool>>& decisionsInterm() { return m_decisionsInterm; }
156  inline const std::vector<std::pair<std::string, bool>>& decisionsFinal() { return m_decisionsFinal; }
157 
158  // Access all prescales
159  inline const std::vector<std::pair<std::string, double>>& prescales() { return m_prescales; }
160 
161  // Access Masks (see note) above
162  inline const std::vector<std::pair<std::string, std::vector<int>>>& masks() { return m_masks; }
163 
164  // Menu names
165  inline const std::string& gtTriggerMenuName() const { return m_l1GtMenu->getName(); }
166  inline const std::string& gtTriggerMenuVersion() const { return m_l1GtMenu->getVersion(); }
167  inline const std::string& gtTriggerMenuComment() const { return m_l1GtMenu->getComment(); }
168 
169  // Prescale Column
170  inline unsigned int prescaleColumn() const { return m_PreScaleColumn; }
171  inline unsigned int numberOfPreScaleColumns() const { return m_numberOfPreScaleColumns; }
172 
173  private:
174  L1TGlobalUtil();
175 
176  void retrieveL1Setup(const edm::EventSetup& evSetup, bool isRun);
177  void eventSetupConsumes(edm::ConsumesCollector& iC, UseEventSetupIn useEventSetupIn);
178 
180  void resetDecisionVectors();
181  void resetPrescaleVectors();
182  void resetMaskVectors();
183  void loadPrescalesAndMasks();
184 
185  // trigger menu
187  unsigned long long m_l1GtMenuCacheID;
188 
189  // prescale factors
192  unsigned long long m_l1GtPfAlgoCacheID;
193 
194  // prescales and masks
196 
197  // algorithm maps
198  //const AlgorithmMap* m_algorithmMap;
199  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
200 
201  // Number of physics triggers
202  unsigned int m_numberPhysTriggers;
203  const unsigned int m_maxNumberPhysTriggers = 512;
204 
205  //file and container for prescale factors
207  unsigned int m_PreScaleColumn;
209 
210  std::vector<std::vector<double>> m_initialPrescaleFactorsAlgoTrig;
211  const std::vector<std::vector<double>>* m_prescaleFactorsAlgoTrig;
212  const std::map<int, std::vector<int>> m_initialTriggerMaskAlgoTrig;
213  const std::map<int, std::vector<int>>* m_triggerMaskAlgoTrig; // vector stores the BX
214 
215  // access to the results block from uGT
217 
218  // final OR
219  bool m_finalOR;
220 
221  // Vectors containing the trigger name and information about that trigger
222  std::vector<std::pair<std::string, bool>> m_decisionsInitial;
223  std::vector<std::pair<std::string, bool>> m_decisionsInterm;
224  std::vector<std::pair<std::string, bool>> m_decisionsFinal;
225  std::vector<std::pair<std::string, double>> m_prescales;
226  std::vector<std::pair<std::string, std::vector<int>>> m_masks; // vector stores the bx's that are mask for given algo
227 
230 
231  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
232 
236 
240  };
241 
242  template <typename T>
245  T& module,
246  UseEventSetupIn useEventSetupIn)
247  : L1TGlobalUtil(pset, iC, module, useEventSetupIn) {}
248 
249  template <typename T>
252  T& module,
253  UseEventSetupIn useEventSetupIn)
254  : L1TGlobalUtil() {
255  m_l1tGlobalUtilHelper = std::make_unique<L1TGlobalUtilHelper>(pset, iC, module);
256  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
257  eventSetupConsumes(iC, useEventSetupIn);
258  }
259 
260  template <typename T>
263  T& module,
264  edm::InputTag const& l1tAlgBlkInputTag,
265  edm::InputTag const& l1tExtBlkInputTag,
266  UseEventSetupIn useEventSetupIn)
267  : L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag, useEventSetupIn) {}
268 
269  template <typename T>
272  T& module,
273  edm::InputTag const& l1tAlgBlkInputTag,
274  edm::InputTag const& l1tExtBlkInputTag,
275  UseEventSetupIn useEventSetupIn)
276  : L1TGlobalUtil() {
278  std::make_unique<L1TGlobalUtilHelper>(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag);
279  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
280  eventSetupConsumes(iC, useEventSetupIn);
281  }
282 } // namespace l1t
283 #endif
void setVerbosity(const int verbosity)
const bool getInitialDecisionByBit(int &bit, bool &decision) const
const L1TUtmTriggerMenu * m_l1GtMenu
edm::ESGetToken< L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd > m_L1TGlobalPrescalesVetosFractRunToken
std::string m_preScaleFileName
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
void retrieveL1Event(const edm::Event &iEvent, const edm::EventSetup &evSetup)
const std::string & gtTriggerMenuComment() const
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuRunToken
unsigned long long m_l1GtPfAlgoCacheID
const std::vector< std::pair< std::string, double > > & prescales()
const std::string & getVersion() const
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1.)
const bool getIntermDecisionByBit(int &bit, bool &decision) const
unsigned int m_numberOfPreScaleColumns
unsigned int m_PreScaleColumn
const l1t::PrescalesVetosFractHelper * m_l1GtPrescalesVetoes
std::unique_ptr< L1TGlobalUtilHelper > m_l1tGlobalUtilHelper
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
const std::string & gtTriggerMenuVersion() const
std::vector< std::pair< std::string, bool > > m_decisionsInitial
bool valid() const
check that the L1TGlobalUtil has been properly initialised
void resetDecisionVectors()
clear decision vectors on a menu change
const bool getPrescaleByName(const std::string &algName, double &prescale) const
std::vector< std::vector< double > > m_initialPrescaleFactorsAlgoTrig
const std::map< std::string, L1TUtmAlgorithm > * m_algorithmMap
const std::map< int, std::vector< int > > m_initialTriggerMaskAlgoTrig
static void fillDescription(edm::ParameterSetDescription &desc)
std::vector< std::pair< std::string, std::vector< int > > > m_masks
int iEvent
Definition: GenABIO.cc:224
const std::map< int, std::vector< int > > * m_triggerMaskAlgoTrig
const std::vector< std::pair< std::string, bool > > & decisionsInterm()
void eventSetupConsumes(edm::ConsumesCollector &iC, UseEventSetupIn useEventSetupIn)
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuEventToken
const std::string & gtTriggerMenuName() const
const std::vector< std::pair< std::string, bool > > & decisionsInitial()
static void fillDescription(edm::ParameterSetDescription &desc)
unsigned int prescaleColumn() const
const std::vector< std::vector< double > > * m_prescaleFactorsAlgoTrig
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
std::vector< std::pair< std::string, double > > m_prescales
const bool getPrescaleByBit(int &bit, double &prescale) const
const bool getMaskByName(const std::string &algName, std::vector< int > &mask) const
std::vector< std::pair< std::string, bool > > m_decisionsInterm
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
int m_verbosity
verbosity level
unsigned long long m_l1GtMenuCacheID
bool getFinalOR() const
const bool getFinalDecisionByBit(int &bit, bool &decision) const
std::vector< std::pair< std::string, bool > > m_decisionsFinal
const std::string & getComment() const
tuple filename
Definition: lut2db_cfg.py:20
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
const bool getMaskByBit(int &bit, std::vector< int > &mask) const
unsigned int numberOfPreScaleColumns() const
edm::Handle< BXVector< GlobalAlgBlk > > m_uGtAlgBlk
const std::vector< std::pair< std::string, std::vector< int > > > & masks()
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
UseEventSetupIn
Definition: L1TGlobalUtil.h:42
const unsigned int m_maxNumberPhysTriggers
long double T
virtual ~L1TGlobalUtil()
destructor
void retrieveL1Setup(const edm::EventSetup &evSetup)
unsigned int m_numberPhysTriggers
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)
edm::ESGetToken< L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd > m_L1TGlobalPrescalesVetosFractEventToken
const std::string & getName() const
tuple module
Definition: callgraph.py:69