CMS 3D CMS Logo

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 
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>
63  T& module,
65 
66  template <typename T>
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>
81  T& module,
85 
86  template <typename T>
89  T& module,
93 
95  virtual ~L1TGlobalUtil();
96 
98  bool valid() const;
99 
101  edm::InputTag const& iAlg,
102  edm::InputTag const& iExt,
103  bool readPrescalesFromFile) {
104  L1TGlobalUtilHelper::fillDescription(desc, iAlg, iExt, readPrescalesFromFile);
105  }
106 
107  // OverridePrescalesAndMasks
108  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
109  // It is provided only until prescales and masks are available as CondFormats...
110  // Most users should simply ignore this method and use the default ctor only!
111  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
112  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn = 1.);
113 
115  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
116  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
117  void retrieveL1Setup(const edm::EventSetup& evSetup); // Use this one only during beginRun
118  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
119  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
120 
121  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
122 
123  inline bool getFinalOR() const { return m_finalOR; }
124 
125  // get the trigger bit from the name
126  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
127 
128  // get the name from the trigger bit
129  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
130 
131  // Access results for particular trigger bit
132  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
133  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
134  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
135 
136  // Access Prescale
137  const bool getPrescaleByBit(int& bit, double& prescale) const;
138 
139  // Access Masks:
140  // follows logic of uGT board:
141  // finalDecision[AlgBit]
142  // Final word is after application of prescales.
143  // A prescale = 0 effectively masks out the algorithm in the final decision word
144  //
145  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
146 
147  // Access results for particular trigger name
148  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
149  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
150  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
151 
152  // Access Prescales
153  const bool getPrescaleByName(const std::string& algName, double& prescale) const;
154 
155  // Access Masks (see note) above
156  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
157 
158  // Some inline commands to return the full vectors
159  inline const std::vector<std::pair<std::string, bool>>& decisionsInitial() { return m_decisionsInitial; }
160  inline const std::vector<std::pair<std::string, bool>>& decisionsInterm() { return m_decisionsInterm; }
161  inline const std::vector<std::pair<std::string, bool>>& decisionsFinal() { return m_decisionsFinal; }
162 
163  // Access all prescales
164  inline const std::vector<std::pair<std::string, double>>& prescales() { return m_prescales; }
165 
166  // Access Masks (see note) above
167  inline const std::vector<std::pair<std::string, std::vector<int>>>& masks() { return m_masks; }
168 
169  // Menu names
170  inline const std::string& gtTriggerMenuName() const { return m_l1GtMenu->getName(); }
171  inline const std::string& gtTriggerMenuVersion() const { return m_l1GtMenu->getVersion(); }
172  inline const std::string& gtTriggerMenuComment() const { return m_l1GtMenu->getComment(); }
173 
174  // Prescale Column
175  inline unsigned int prescaleColumn() const { return m_PreScaleColumn; }
176  inline unsigned int numberOfPreScaleColumns() const { return m_numberOfPreScaleColumns; }
177 
178  private:
179  L1TGlobalUtil();
180 
181  void retrieveL1Setup(const edm::EventSetup& evSetup, bool isRun);
182  void eventSetupConsumes(edm::ConsumesCollector& iC, UseEventSetupIn useEventSetupIn);
183 
185  void resetDecisionVectors();
186  void resetPrescaleVectors();
187  void resetMaskVectors();
188  void loadPrescalesAndMasks();
189 
190  // trigger menu
192  unsigned long long m_l1GtMenuCacheID;
193 
194  // prescale factors
197  unsigned long long m_l1GtPfAlgoCacheID;
198 
199  // prescales and masks
201 
202  // algorithm maps
203  //const AlgorithmMap* m_algorithmMap;
204  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
205 
206  // Number of physics triggers
207  unsigned int m_numberPhysTriggers;
208  const unsigned int m_maxNumberPhysTriggers = 512;
209 
210  //file and container for prescale factors
212  unsigned int m_PreScaleColumn;
214 
215  std::vector<std::vector<double>> m_initialPrescaleFactorsAlgoTrig;
216  const std::vector<std::vector<double>>* m_prescaleFactorsAlgoTrig;
217  const std::map<int, std::vector<int>> m_initialTriggerMaskAlgoTrig;
218  const std::map<int, std::vector<int>>* m_triggerMaskAlgoTrig; // vector stores the BX
219 
220  // access to the results block from uGT
222 
223  // final OR
224  bool m_finalOR;
225 
226  // Vectors containing the trigger name and information about that trigger
227  std::vector<std::pair<std::string, bool>> m_decisionsInitial;
228  std::vector<std::pair<std::string, bool>> m_decisionsInterm;
229  std::vector<std::pair<std::string, bool>> m_decisionsFinal;
230  std::vector<std::pair<std::string, double>> m_prescales;
231  std::vector<std::pair<std::string, std::vector<int>>> m_masks; // vector stores the bx's that are mask for given algo
232 
235 
236  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
237 
241 
245  };
246 
247  template <typename T>
250  T& module,
251  UseEventSetupIn useEventSetupIn)
252  : L1TGlobalUtil(pset, iC, module, useEventSetupIn) {}
253 
254  template <typename T>
257  T& module,
258  UseEventSetupIn useEventSetupIn)
259  : L1TGlobalUtil() {
260  m_l1tGlobalUtilHelper = std::make_unique<L1TGlobalUtilHelper>(pset, iC, module);
261  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
262  eventSetupConsumes(iC, useEventSetupIn);
263  }
264 
265  template <typename T>
268  T& module,
271  UseEventSetupIn useEventSetupIn)
272  : L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag, useEventSetupIn) {}
273 
274  template <typename T>
277  T& module,
280  UseEventSetupIn useEventSetupIn)
281  : L1TGlobalUtil() {
283  std::make_unique<L1TGlobalUtilHelper>(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag);
284  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
285  eventSetupConsumes(iC, useEventSetupIn);
286  }
287 } // namespace l1t
288 #endif
void setVerbosity(const int verbosity)
const std::string & getName() const
bool getFinalOR() const
const L1TUtmTriggerMenu * m_l1GtMenu
edm::ESGetToken< L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd > m_L1TGlobalPrescalesVetosFractRunToken
const std::string & getComment() const
std::string m_preScaleFileName
const bool getInitialDecisionByBit(int &bit, bool &decision) const
unsigned int prescaleColumn() const
const bool getMaskByName(const std::string &algName, std::vector< int > &mask) const
void retrieveL1Event(const edm::Event &iEvent, const edm::EventSetup &evSetup)
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuRunToken
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
unsigned long long m_l1GtPfAlgoCacheID
const std::vector< std::pair< std::string, double > > & prescales()
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1.)
unsigned int m_numberOfPreScaleColumns
unsigned int m_PreScaleColumn
delete x;
Definition: CaloConfig.h:22
const std::string & gtTriggerMenuName() const
const l1t::PrescalesVetosFractHelper * m_l1GtPrescalesVetoes
std::unique_ptr< L1TGlobalUtilHelper > m_l1tGlobalUtilHelper
std::vector< std::pair< std::string, bool > > m_decisionsInitial
void resetDecisionVectors()
clear decision vectors on a menu change
constexpr uint32_t mask
Definition: gpuClustering.h:26
std::vector< std::vector< double > > m_initialPrescaleFactorsAlgoTrig
const std::string & gtTriggerMenuComment() const
unsigned int numberOfPreScaleColumns() const
const bool getIntermDecisionByBit(int &bit, bool &decision) const
const std::map< std::string, L1TUtmAlgorithm > * m_algorithmMap
const std::map< int, std::vector< int > > m_initialTriggerMaskAlgoTrig
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()
static void fillDescription(edm::ParameterSetDescription &desc, edm::InputTag const &iAlg, edm::InputTag const &iExt, bool readPrescalesFromFile)
void eventSetupConsumes(edm::ConsumesCollector &iC, UseEventSetupIn useEventSetupIn)
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuEventToken
const bool getFinalDecisionByBit(int &bit, bool &decision) const
const std::vector< std::pair< std::string, bool > > & decisionsInitial()
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
const std::vector< std::vector< double > > * m_prescaleFactorsAlgoTrig
std::vector< std::pair< std::string, double > > m_prescales
const std::string & gtTriggerMenuVersion() const
static void fillDescription(edm::ParameterSetDescription &desc, edm::InputTag const &iAlg, edm::InputTag const &iExt, bool readPrescalesFromFile)
const int verbosity
std::vector< std::pair< std::string, bool > > m_decisionsInterm
const bool getPrescaleByName(const std::string &algName, double &prescale) const
int m_verbosity
verbosity level
unsigned long long m_l1GtMenuCacheID
bool valid() const
check that the L1TGlobalUtil has been properly initialised
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
std::vector< std::pair< std::string, bool > > m_decisionsFinal
const bool getPrescaleByBit(int &bit, double &prescale) const
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
edm::Handle< BXVector< GlobalAlgBlk > > m_uGtAlgBlk
const std::vector< std::pair< std::string, std::vector< int > > > & masks()
const std::string & getVersion() const
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
const bool getMaskByBit(int &bit, std::vector< int > &mask) 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