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 
32 
33 public:
34 
35  // Using this constructor will require InputTags to be specified in the configuration
38 
39  L1TGlobalUtil(edm::ParameterSet const& pset,
41 
42  // Using this constructor will cause it to look for valid InputTags in
43  // the following ways in the specified order until they are found.
44  // 1. The configuration
45  // 2. Search all products from the preferred input tags for the required type
46  // 3. Search all products from any other process for the required type
47  template <typename T>
48  L1TGlobalUtil(edm::ParameterSet const& pset,
50  T& module);
51 
52  template <typename T>
53  L1TGlobalUtil(edm::ParameterSet const& pset,
55  T& module);
56 
57  // Using this constructor will cause it to look for valid InputTags in
58  // the following ways in the specified order until they are found.
59  // 1. The constructor arguments
60  // 2. The configuration
61  // 3. Search all products from the preferred input tags for the required type
62  // 4. Search all products from any other process for the required type
63  template <typename T>
64  L1TGlobalUtil(edm::ParameterSet const& pset,
66  T& module,
69 
70  template <typename T>
71  L1TGlobalUtil(edm::ParameterSet const& pset,
73  T& module,
74  edm::InputTag const& l1tAlgBlkInputTag,
75  edm::InputTag const& l1tExtBlkInputTag);
76 
78  virtual ~L1TGlobalUtil();
79 
81  bool valid() const;
82 
85  }
86 
87  // OverridePrescalesAndMasks
88  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
89  // It is provided only until prescales and masks are available as CondFormats...
90  // Most users should simply ignore this method and use the default ctor only!
91  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
92  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1);
93 
95  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
96  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
97  void retrieveL1Setup(const edm::EventSetup& evSetup);
98  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
99  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
100 
101  inline void setUnprescaledUnmasked(bool unprescale, bool unmask) {
102  m_algorithmTriggersUnprescaled = unprescale;
104  }
105 
106  inline void setVerbosity(const int verbosity) {
108  }
109 
110  inline bool getFinalOR() const {return m_finalOR;}
111 
112  // get the trigger bit from the name
113  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
114 
115  // get the name from the trigger bit
116  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
117 
118  // Access results for particular trigger bit
119  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
120  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
121  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
122 
123  // Access Prescale
124  const bool getPrescaleByBit(int& bit, int& prescale) const;
125 
126  // Access Masks:
127  // follows logic of uGT board:
128  // finalDecision[AlgBit]
129  // Final word is after application of prescales.
130  // A prescale = 0 effectively masks out the algorithm in the final decision word
131  //
132  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
133 
134  // Access results for particular trigger name
135  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
136  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
137  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
138 
139  // Access Prescales
140  const bool getPrescaleByName(const std::string& algName, int& prescale) const;
141 
142  // Access Masks (see note) above
143  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
144 
145  // Some inline commands to return the full vectors
146  inline const std::vector<std::pair<std::string, bool> >& decisionsInitial() { return m_decisionsInitial; }
147  inline const std::vector<std::pair<std::string, bool> >& decisionsInterm() { return m_decisionsInterm; }
148  inline const std::vector<std::pair<std::string, bool> >& decisionsFinal() { return m_decisionsFinal; }
149 
150  // Access all prescales
151  inline const std::vector<std::pair<std::string, int> >& prescales() { return m_prescales; }
152 
153  // Access Masks (see note) above
154  inline const std::vector<std::pair<std::string, std::vector<int> > >& masks() { return m_masks; }
155 
156  // Menu names
157  inline const std::string& gtTriggerMenuName() const {return m_l1GtMenu->getName();}
158  inline const std::string& gtTriggerMenuVersion() const {return m_l1GtMenu->getVersion();}
159  inline const std::string& gtTriggerMenuComment() const {return m_l1GtMenu->getComment();}
160 
161  // Prescale Column
162  inline unsigned int prescaleColumn() const {return m_PreScaleColumn;}
163  inline unsigned int numberOfPreScaleColumns() const {return m_numberOfPreScaleColumns;}
164 
165 private:
166 
167  L1TGlobalUtil();
168 
170  void resetDecisionVectors();
171  void resetPrescaleVectors();
172  void resetMaskVectors();
173  void loadPrescalesAndMasks();
174 
175  // trigger menu
177  unsigned long long m_l1GtMenuCacheID;
178 
179 
180  // prescale factors
183  unsigned long long m_l1GtPfAlgoCacheID;
184 
185  // prescale or mask algo decisions
188 
189  // prescales and masks
191 
192  // algorithm maps
193  //const AlgorithmMap* m_algorithmMap;
194  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
195 
196  // Number of physics triggers
197  unsigned int m_numberPhysTriggers;
198  const unsigned int m_maxNumberPhysTriggers = 512;
199 
200  //file and container for prescale factors
202  unsigned int m_PreScaleColumn;
204 
205  std::vector<std::vector<int> > m_initialPrescaleFactorsAlgoTrig;
206  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
207  const std::map<int, std::vector<int> > m_initialTriggerMaskAlgoTrig;
208  const std::map<int, std::vector<int> >* m_triggerMaskAlgoTrig; // vector stores the BX
209 
210  // access to the results block from uGT
212 
213  // final OR
214  bool m_finalOR;
215 
216  // Vectors containing the trigger name and information about that trigger
217  std::vector<std::pair<std::string, bool> > m_decisionsInitial;
218  std::vector<std::pair<std::string, bool> > m_decisionsInterm;
219  std::vector<std::pair<std::string, bool> > m_decisionsFinal;
220  std::vector<std::pair<std::string, int> > m_prescales;
221  std::vector<std::pair<std::string, std::vector<int> > > m_masks; // vector stores the bx's that are mask for given algo
222 
225 
226  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
227 
228 };
229 
230 template <typename T>
233  T& module) :
234  L1TGlobalUtil(pset, iC, module) { }
235 
236 template <typename T>
239  T& module) :
240  L1TGlobalUtil() {
242  iC,
243  module));
244  m_readPrescalesFromFile=m_l1tGlobalUtilHelper->readPrescalesFromFile();
245  }
246 
247 template <typename T>
250  T& module,
253  L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag) { }
254 
255 template <typename T>
258  T& module,
261  L1TGlobalUtil() {
263  iC,
264  module,
265  l1tAlgBlkInputTag,
266  l1tExtBlkInputTag));
267  m_readPrescalesFromFile=m_l1tGlobalUtilHelper->readPrescalesFromFile();
268  }
269 }
270 #endif
void setVerbosity(const int verbosity)
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)
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:83
std::vector< std::pair< std::string, std::vector< int > > > m_masks
int iEvent
Definition: GenABIO.cc:230
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
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:208
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