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 
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,
266  UseEventSetupIn useEventSetupIn)
267  : L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag, useEventSetupIn) {}
268 
269  template <typename T>
272  T& module,
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 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
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
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 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
static void fillDescription(edm::ParameterSetDescription &desc)
const std::vector< std::vector< double > > * m_prescaleFactorsAlgoTrig
std::vector< std::pair< std::string, double > > m_prescales
const std::string & gtTriggerMenuVersion() const
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