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 <vector>
8 
10 
11 // Objects to produce for the output record.
15 
18 
20 
22 
24 
25 // forward declarations
26 
27 // class declaration
28 
29 namespace l1t {
30 
31  class L1TGlobalUtil {
32  public:
33  // Using this constructor will require InputTags to be specified in the configuration
35 
37 
38  // Using this constructor will cause it to look for valid InputTags in
39  // the following ways in the specified order until they are found.
40  // 1. The configuration
41  // 2. Search all products from the preferred input tags for the required type
42  // 3. Search all products from any other process for the required type
43  template <typename T>
45 
46  template <typename T>
47  L1TGlobalUtil(edm::ParameterSet const& pset, edm::ConsumesCollector& iC, T& module);
48 
49  // Using this constructor will cause it to look for valid InputTags in
50  // the following ways in the specified order until they are found.
51  // 1. The constructor arguments
52  // 2. The configuration
53  // 3. Search all products from the preferred input tags for the required type
54  // 4. Search all products from any other process for the required type
55  template <typename T>
56  L1TGlobalUtil(edm::ParameterSet const& pset,
58  T& module,
61 
62  template <typename T>
63  L1TGlobalUtil(edm::ParameterSet const& pset,
65  T& module,
66  edm::InputTag const& l1tAlgBlkInputTag,
67  edm::InputTag const& l1tExtBlkInputTag);
68 
70  virtual ~L1TGlobalUtil();
71 
73  bool valid() const;
74 
76 
77  // OverridePrescalesAndMasks
78  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
79  // It is provided only until prescales and masks are available as CondFormats...
80  // Most users should simply ignore this method and use the default ctor only!
81  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
83 
85  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
86  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
87  void retrieveL1Setup(const edm::EventSetup& evSetup);
88  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
89  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
90 
91  inline void setUnprescaledUnmasked(bool unprescale, bool unmask) {
92  m_algorithmTriggersUnprescaled = unprescale;
94  }
95 
96  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
97 
98  inline bool getFinalOR() const { return m_finalOR; }
99 
100  // get the trigger bit from the name
101  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
102 
103  // get the name from the trigger bit
104  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
105 
106  // Access results for particular trigger bit
107  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
108  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
109  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
110 
111  // Access Prescale
112  const bool getPrescaleByBit(int& bit, int& prescale) const;
113 
114  // Access Masks:
115  // follows logic of uGT board:
116  // finalDecision[AlgBit]
117  // Final word is after application of prescales.
118  // A prescale = 0 effectively masks out the algorithm in the final decision word
119  //
120  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
121 
122  // Access results for particular trigger name
123  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
124  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
125  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
126 
127  // Access Prescales
128  const bool getPrescaleByName(const std::string& algName, int& prescale) const;
129 
130  // Access Masks (see note) above
131  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
132 
133  // Some inline commands to return the full vectors
134  inline const std::vector<std::pair<std::string, bool>>& decisionsInitial() { return m_decisionsInitial; }
135  inline const std::vector<std::pair<std::string, bool>>& decisionsInterm() { return m_decisionsInterm; }
136  inline const std::vector<std::pair<std::string, bool>>& decisionsFinal() { return m_decisionsFinal; }
137 
138  // Access all prescales
139  inline const std::vector<std::pair<std::string, int>>& prescales() { return m_prescales; }
140 
141  // Access Masks (see note) above
142  inline const std::vector<std::pair<std::string, std::vector<int>>>& masks() { return m_masks; }
143 
144  // Menu names
145  inline const std::string& gtTriggerMenuName() const { return m_l1GtMenu->getName(); }
146  inline const std::string& gtTriggerMenuVersion() const { return m_l1GtMenu->getVersion(); }
147  inline const std::string& gtTriggerMenuComment() const { return m_l1GtMenu->getComment(); }
148 
149  // Prescale Column
150  inline unsigned int prescaleColumn() const { return m_PreScaleColumn; }
151  inline unsigned int numberOfPreScaleColumns() const { return m_numberOfPreScaleColumns; }
152 
153  private:
154  L1TGlobalUtil();
155 
157  void resetDecisionVectors();
158  void resetPrescaleVectors();
159  void resetMaskVectors();
160  void loadPrescalesAndMasks();
161 
162  // trigger menu
164  unsigned long long m_l1GtMenuCacheID;
165 
166  // prescale factors
169  unsigned long long m_l1GtPfAlgoCacheID;
170 
171  // prescale or mask algo decisions
174 
175  // prescales and masks
177 
178  // algorithm maps
179  //const AlgorithmMap* m_algorithmMap;
180  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
181 
182  // Number of physics triggers
183  unsigned int m_numberPhysTriggers;
184  const unsigned int m_maxNumberPhysTriggers = 512;
185 
186  //file and container for prescale factors
188  unsigned int m_PreScaleColumn;
190 
191  std::vector<std::vector<int>> m_initialPrescaleFactorsAlgoTrig;
192  const std::vector<std::vector<int>>* m_prescaleFactorsAlgoTrig;
193  const std::map<int, std::vector<int>> m_initialTriggerMaskAlgoTrig;
194  const std::map<int, std::vector<int>>* m_triggerMaskAlgoTrig; // vector stores the BX
195 
196  // access to the results block from uGT
198 
199  // final OR
200  bool m_finalOR;
201 
202  // Vectors containing the trigger name and information about that trigger
203  std::vector<std::pair<std::string, bool>> m_decisionsInitial;
204  std::vector<std::pair<std::string, bool>> m_decisionsInterm;
205  std::vector<std::pair<std::string, bool>> m_decisionsFinal;
206  std::vector<std::pair<std::string, int>> m_prescales;
207  std::vector<std::pair<std::string, std::vector<int>>> m_masks; // vector stores the bx's that are mask for given algo
208 
211 
212  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
213  };
214 
215  template <typename T>
217  : L1TGlobalUtil(pset, iC, module) {}
218 
219  template <typename T>
221  m_l1tGlobalUtilHelper.reset(new L1TGlobalUtilHelper(pset, iC, module));
222  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
223  }
224 
225  template <typename T>
228  T& module,
231  : L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag) {}
232 
233  template <typename T>
236  T& module,
239  : L1TGlobalUtil() {
240  m_l1tGlobalUtilHelper.reset(new L1TGlobalUtilHelper(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag));
241  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
242  }
243 } // namespace l1t
244 #endif
void setVerbosity(const int verbosity)
Definition: L1TGlobalUtil.h:96
const bool getInitialDecisionByBit(int &bit, bool &decision) const
const L1TUtmTriggerMenu * m_l1GtMenu
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
const std::vector< std::pair< std::string, int > > & prescales()
bool m_algorithmTriggersUnmasked
unsigned long long m_l1GtPfAlgoCacheID
const std::string & getVersion() const
void setUnprescaledUnmasked(bool unprescale, bool unmask)
Definition: L1TGlobalUtil.h:91
const bool getPrescaleByBit(int &bit, int &prescale) const
const bool getIntermDecisionByBit(int &bit, bool &decision) const
unsigned int m_numberOfPreScaleColumns
unsigned int m_PreScaleColumn
delete x;
Definition: CaloConfig.h:22
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
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 std::map< std::string, L1TUtmAlgorithm > * m_algorithmMap
const std::map< int, std::vector< int > > m_initialTriggerMaskAlgoTrig
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1TGlobalUtil.h:75
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()
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
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 bool getFinalDecisionByName(const std::string &algName, bool &decision) const
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1)
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
Definition: L1TGlobalUtil.h:98
const l1t::PrescalesVetosHelper * m_l1GtPrescalesVetoes
const bool getFinalDecisionByBit(int &bit, bool &decision) const
std::vector< std::pair< std::string, bool > > m_decisionsFinal
const std::string & getComment() const
const bool getPrescaleByName(const std::string &algName, int &prescale) const
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
const bool getMaskByBit(int &bit, std::vector< int > &mask) const
bool m_algorithmTriggersUnprescaled
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
const unsigned int m_maxNumberPhysTriggers
long double T
virtual ~L1TGlobalUtil()
destructor
void retrieveL1Setup(const edm::EventSetup &evSetup)
Definition: vlib.h:198
std::vector< std::pair< std::string, int > > m_prescales
unsigned int m_numberPhysTriggers
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)
const std::string & getName() const