test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
67  edm::InputTag const& l1tAlgBlkInputTag,
68  edm::InputTag const& l1tExtBlkInputTag);
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  // If vetoMask = true and Algorithm is true, the FINOR (final global decision) is forced to false (ie. event is vetoed)
130  // If vetoMask = false, algorithm cannot veto FINOR (final global decision)
131  const bool getMaskByBit(int& bit, bool& mask) const;
132  const bool getVetoMaskByBit(int& bit, bool& veto) 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, bool& mask) const;
144  const bool getVetoMaskByName(const std::string& algName, bool& veto) const;
145 
146  // Some inline commands to return the full vectors
147  inline const std::vector<std::pair<std::string, bool> >& decisionsInitial() { return m_decisionsInitial; }
148  inline const std::vector<std::pair<std::string, bool> >& decisionsInterm() { return m_decisionsInterm; }
149  inline const std::vector<std::pair<std::string, bool> >& decisionsFinal() { return m_decisionsFinal; }
150 
151  // Access all prescales
152  inline const std::vector<std::pair<std::string, int> >& prescales() { return m_prescales; }
153 
154  // Access Masks (see note) above
155  inline const std::vector<std::pair<std::string, bool> >& masks() { return m_masks; }
156  inline const std::vector<std::pair<std::string, bool> >& vetoMasks() { return m_vetoMasks; }
157 
158  // Menu names
159  inline const std::string& gtTriggerMenuName() const {return m_l1GtMenu->getName();}
160  inline const std::string& gtTriggerMenuVersion() const {return m_l1GtMenu->getVersion();}
161  inline const std::string& gtTriggerMenuComment() const {return m_l1GtMenu->getComment();}
162 
163  // Prescale Column
164  inline unsigned int prescaleColumn() const {return m_PreScaleColumn;}
165 
166 private:
167 
168  L1TGlobalUtil();
169 
171  void resetDecisionVectors();
172  void resetPrescaleVectors();
173  void resetMaskVectors();
174  void loadPrescalesAndMasks();
175 
176  // trigger menu
178  unsigned long long m_l1GtMenuCacheID;
179 
180 
181  // 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 
199  //file and container for prescale factors
201  unsigned int m_PreScaleColumn;
202 
203  std::vector<std::vector<int> > m_initialPrescaleFactorsAlgoTrig;
204  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
205  std::vector<unsigned int> m_initialTriggerMaskAlgoTrig;
206  const std::vector<unsigned int>* m_triggerMaskAlgoTrig;
208  const std::vector<int>* m_triggerMaskVetoAlgoTrig;
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, bool> > m_masks;
222  std::vector<std::pair<std::string, bool> > m_vetoMasks;
223 
226 
227  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
228 
229 };
230 
231 template <typename T>
234  T& module) :
235  L1TGlobalUtil(pset, iC, module) { }
236 
237 template <typename T>
240  T& module) :
241  L1TGlobalUtil() {
243  iC,
244  module));
245  }
246 
247 template <typename T>
250  T& module,
251  edm::InputTag const& l1tAlgBlkInputTag,
252  edm::InputTag const& l1tExtBlkInputTag) :
253  L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag) { }
254 
255 template <typename T>
258  T& module,
259  edm::InputTag const& l1tAlgBlkInputTag,
260  edm::InputTag const& l1tExtBlkInputTag) :
261  L1TGlobalUtil() {
263  iC,
264  module,
265  l1tAlgBlkInputTag,
266  l1tExtBlkInputTag));
267  }
268 }
269 #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_PreScaleColumn
const std::vector< std::pair< std::string, bool > > & masks()
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
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
std::vector< std::pair< std::string, bool > > m_masks
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
const bool getMaskByName(const std::string &algName, bool &mask) const
const std::map< std::string, L1TUtmAlgorithm > * m_algorithmMap
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1TGlobalUtil.h:80
int iEvent
Definition: GenABIO.cc:230
const std::vector< int > * m_triggerMaskVetoAlgoTrig
const std::vector< std::pair< std::string, bool > > & decisionsInterm()
const std::vector< std::pair< std::string, bool > > & vetoMasks()
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)
std::vector< std::pair< std::string, bool > > m_vetoMasks
std::vector< std::pair< std::string, bool > > m_decisionsInterm
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
const bool getVetoMaskByBit(int &bit, bool &veto) const
int m_verbosity
verbosity level
unsigned long long m_l1GtMenuCacheID
bool getFinalOR() const
const bool getMaskByBit(int &bit, bool &mask) const
const l1t::PrescalesVetosHelper * m_l1GtPrescalesVetoes
const bool getVetoMaskByName(const std::string &algName, bool &veto) const
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
tuple filename
Definition: lut2db_cfg.py:20
const bool getPrescaleByName(const std::string &algName, int &prescale) const
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
bool m_algorithmTriggersUnprescaled
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
edm::Handle< BXVector< GlobalAlgBlk > > m_uGtAlgBlk
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
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