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 
82  }
83 
84  // OverridePrescalesAndMasks
85  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
86  // It is provided only until prescales and masks are available as CondFormats...
87  // Most users should simply ignore this method and use the default ctor only!
88  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
89  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1);
90 
92  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
93  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
94  void retrieveL1Setup(const edm::EventSetup& evSetup);
95  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
96  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
97 
98  inline void setUnprescaledUnmasked(const bool unprescale, const bool unmask) {
99  m_algorithmTriggersUnprescaled = unprescale;
101  }
102 
103  inline void setVerbosity(const int verbosity) {
105  }
106 
107  inline bool getFinalOR() const {return m_finalOR;}
108 
109  // get the trigger bit from the name
110  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
111 
112  // get the name from the trigger bit
113  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
114 
115  // Access results for particular trigger bit
116  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
117  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
118  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
119 
120  // Access Prescale
121  const bool getPrescaleByBit(int& bit, int& prescale) const;
122 
123  // Access Masks:
124  // follows logic of uGT board:
125  // finalDecision[AlgBit]
126  // Final word is after application of prescales.
127  // A prescale = 0 effectively masks out the algorithm in the final decision word
128  //
129  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
130 
131  // Access results for particular trigger name
132  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
133  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
134  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
135 
136  // Access Prescales
137  const bool getPrescaleByName(const std::string& algName, int& prescale) const;
138 
139  // Access Masks (see note) above
140  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
141 
142  // Some inline commands to return the full vectors
143  inline const std::vector<std::pair<std::string, bool> >& decisionsInitial() { return m_decisionsInitial; }
144  inline const std::vector<std::pair<std::string, bool> >& decisionsInterm() { return m_decisionsInterm; }
145  inline const std::vector<std::pair<std::string, bool> >& decisionsFinal() { return m_decisionsFinal; }
146 
147  // Access all prescales
148  inline const std::vector<std::pair<std::string, int> >& prescales() { return m_prescales; }
149 
150  // Access Masks (see note) above
151  inline const std::vector<std::pair<std::string, std::vector<int> > >& masks() { return m_masks; }
152 
153  // Menu names
154  inline const std::string& gtTriggerMenuName() const {return m_l1GtMenu->getName();}
155  inline const std::string& gtTriggerMenuVersion() const {return m_l1GtMenu->getVersion();}
156  inline const std::string& gtTriggerMenuComment() const {return m_l1GtMenu->getComment();}
157 
158  // Prescale Column
159  inline unsigned int prescaleColumn() const {return m_PreScaleColumn;}
160  inline unsigned int numberOfPreScaleColumns() const {return m_numberOfPreScaleColumns;}
161 
162 private:
163 
164  L1TGlobalUtil();
165 
167  void resetDecisionVectors();
168  void resetPrescaleVectors();
169  void resetMaskVectors();
170  void loadPrescalesAndMasks();
171 
172  // trigger menu
174  unsigned long long m_l1GtMenuCacheID;
175 
176 
177  // prescale factors
180  unsigned long long m_l1GtPfAlgoCacheID;
181 
182  // prescale or mask algo decisions
185 
186  // prescales and masks
188 
189  // algorithm maps
190  //const AlgorithmMap* m_algorithmMap;
191  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
192 
193  // Number of physics triggers
194  unsigned int m_numberPhysTriggers;
195  const unsigned int m_maxNumberPhysTriggers = 512;
196 
197  //file and container for prescale factors
199  unsigned int m_PreScaleColumn;
201 
202  std::vector<std::vector<int> > m_initialPrescaleFactorsAlgoTrig;
203  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
204  const std::map<int, std::vector<int> > m_initialTriggerMaskAlgoTrig;
205  const std::map<int, std::vector<int> >* m_triggerMaskAlgoTrig; // vector stores the BX
206 
207  // access to the results block from uGT
209 
210  // final OR
211  bool m_finalOR;
212 
213  // Vectors containing the trigger name and information about that trigger
214  std::vector<std::pair<std::string, bool> > m_decisionsInitial;
215  std::vector<std::pair<std::string, bool> > m_decisionsInterm;
216  std::vector<std::pair<std::string, bool> > m_decisionsFinal;
217  std::vector<std::pair<std::string, int> > m_prescales;
218  std::vector<std::pair<std::string, std::vector<int> > > m_masks; // vector stores the bx's that are mask for given algo
219 
222 
223  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
224 
225 };
226 
227 template <typename T>
230  T& module) :
231  L1TGlobalUtil(pset, iC, module) { }
232 
233 template <typename T>
236  T& module) :
237  L1TGlobalUtil() {
239  iC,
240  module));
241  m_readPrescalesFromFile=m_l1tGlobalUtilHelper->readPrescalesFromFile();
242  }
243 
244 template <typename T>
247  T& module,
250  L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag) { }
251 
252 template <typename T>
255  T& module,
258  L1TGlobalUtil() {
260  iC,
261  module,
262  l1tAlgBlkInputTag,
263  l1tExtBlkInputTag));
264  m_readPrescalesFromFile=m_l1tGlobalUtilHelper->readPrescalesFromFile();
265  }
266 }
267 #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
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
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:80
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
void setUnprescaledUnmasked(const bool unprescale, const bool unmask)
Definition: L1TGlobalUtil.h:98
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