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 
23 // forward declarations
24 
25 // class declaration
26 
27 namespace l1t {
28 
30 
31 public:
32 
33  // Using this constructor will require InputTags to be specified in the configuration
36 
37  L1TGlobalUtil(edm::ParameterSet const& pset,
39 
40  // Using this constructor will cause it to look for valid InputTags in
41  // the following ways in the specified order until they are found.
42  // 1. The configuration
43  // 2. Search all products from the preferred input tags for the required type
44  // 3. Search all products from any other process for the required type
45  template <typename T>
46  L1TGlobalUtil(edm::ParameterSet const& pset,
48  T& module);
49 
50  template <typename T>
51  L1TGlobalUtil(edm::ParameterSet const& pset,
53  T& module);
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 constructor arguments
58  // 2. The configuration
59  // 3. Search all products from the preferred input tags for the required type
60  // 4. Search all products from any other process for the required type
61  template <typename T>
62  L1TGlobalUtil(edm::ParameterSet const& pset,
64  T& module,
65  edm::InputTag const& l1tAlgBlkInputTag,
66  edm::InputTag const& l1tExtBlkInputTag);
67 
68  template <typename T>
69  L1TGlobalUtil(edm::ParameterSet const& pset,
71  T& module,
72  edm::InputTag const& l1tAlgBlkInputTag,
73  edm::InputTag const& l1tExtBlkInputTag);
74 
76  virtual ~L1TGlobalUtil();
77 
80  }
81 
82  // OverridePrescalesAndMasks
83  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
84  // It is provided only until prescales and masks are available as CondFormats...
85  // Most users should simply ignore this method and use the default ctor only!
86  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
87  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1);
88 
90  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
91  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
92  void retrieveL1Setup(const edm::EventSetup& evSetup);
93  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
94  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
95 
96  inline void setVerbosity(const int verbosity) {
98  }
99 
100  inline bool getFinalOR() const {return m_finalOR;}
101 
102  // get the trigger bit from the name
103  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
104 
105  // get the name from the trigger bit
106  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
107 
108  // Access results for particular trigger bit
109  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
110  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
111  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
112 
113  // Access Prescale
114  const bool getPrescaleByBit(int& bit, int& prescale) const;
115 
116  // Access Masks:
117  // follows logic of uGT board:
118  // finalDecision[AlgBit]
119  // Final word is after application of prescales.
120  // A prescale = 0 effectively masks out the algorithm in the final decision word
121  //
122  // If vetoMask = true and Algorithm is true, the FINOR (final global decision) is forced to false (ie. event is vetoed)
123  // If vetoMask = false, algorithm cannot veto FINOR (final global decision)
124  const bool getMaskByBit(int& bit, bool& mask) const;
125  const bool getVetoMaskByBit(int& bit, bool& veto) const;
126 
127  // Access results for particular trigger name
128  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
129  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
130  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
131 
132  // Access Prescales
133  const bool getPrescaleByName(const std::string& algName, int& prescale) const;
134 
135  // Access Masks (see note) above
136  const bool getMaskByName(const std::string& algName, bool& mask) const;
137  const bool getVetoMaskByName(const std::string& algName, bool& veto) const;
138 
139  // Some inline commands to return the full vectors
140  inline const std::vector<std::pair<std::string, bool> >& decisionsInitial() { return m_decisionsInitial; }
141  inline const std::vector<std::pair<std::string, bool> >& decisionsInterm() { return m_decisionsInterm; }
142  inline const std::vector<std::pair<std::string, bool> >& decisionsFinal() { return m_decisionsFinal; }
143 
144  // Access all prescales
145  inline const std::vector<std::pair<std::string, int> >& prescales() { return m_prescales; }
146 
147  // Access Masks (see note) above
148  inline const std::vector<std::pair<std::string, bool> >& masks() { return m_masks; }
149  inline const std::vector<std::pair<std::string, bool> >& vetoMasks() { return m_vetoMasks; }
150 
151  // Menu names
152  inline const std::string& gtTriggerMenuName() const {return m_l1GtMenu->getName();}
153  inline const std::string& gtTriggerMenuVersion() const {return m_l1GtMenu->getVersion();}
154  inline const std::string& gtTriggerMenuComment() const {return m_l1GtMenu->getComment();}
155 
156  // Prescale Column
157  inline unsigned int prescaleColumn() const {return m_PreScaleColumn;}
158 
159 private:
160 
161  L1TGlobalUtil();
162 
164  void resetDecisionVectors();
165  void resetPrescaleVectors();
166  void resetMaskVectors();
167  void loadPrescalesAndMasks();
168 
169  // trigger menu
171  unsigned long long m_l1GtMenuCacheID;
172 
173  // prescales and masks
175 
176  // algorithm maps
177  //const AlgorithmMap* m_algorithmMap;
178  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
179 
180  // Number of physics triggers
181  unsigned int m_numberPhysTriggers;
182 
183  //file and container for prescale factors
185  unsigned int m_PreScaleColumn;
186 
187  std::vector<std::vector<int> > m_initialPrescaleFactorsAlgoTrig;
188  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
189  std::vector<unsigned int> m_initialTriggerMaskAlgoTrig;
190  const std::vector<unsigned int>* m_triggerMaskAlgoTrig;
191  std::vector<unsigned int> m_initialTriggerMaskVetoAlgoTrig;
192  const std::vector<unsigned int>* m_triggerMaskVetoAlgoTrig;
193 
194  // access to the results block from uGT
196 
197  // final OR
198  bool m_finalOR;
199 
200  // Vectors containing the trigger name and information about that trigger
201  std::vector<std::pair<std::string, bool> > m_decisionsInitial;
202  std::vector<std::pair<std::string, bool> > m_decisionsInterm;
203  std::vector<std::pair<std::string, bool> > m_decisionsFinal;
204  std::vector<std::pair<std::string, int> > m_prescales;
205  std::vector<std::pair<std::string, bool> > m_masks;
206  std::vector<std::pair<std::string, bool> > m_vetoMasks;
207 
210 
211  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
212 
213 };
214 
215 template <typename T>
218  T& module) :
219  L1TGlobalUtil(pset, iC, module) { }
220 
221 template <typename T>
224  T& module) :
225  L1TGlobalUtil() {
227  iC,
228  module));
229  }
230 
231 template <typename T>
234  T& module,
235  edm::InputTag const& l1tAlgBlkInputTag,
236  edm::InputTag const& l1tExtBlkInputTag) :
237  L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag) { }
238 
239 template <typename T>
242  T& module,
243  edm::InputTag const& l1tAlgBlkInputTag,
244  edm::InputTag const& l1tExtBlkInputTag) :
245  L1TGlobalUtil() {
247  iC,
248  module,
249  l1tAlgBlkInputTag,
250  l1tExtBlkInputTag));
251  }
252 }
253 #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()
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< 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:78
int iEvent
Definition: GenABIO.cc:230
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()
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
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 bool getVetoMaskByName(const std::string &algName, bool &veto) const
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
std::vector< unsigned int > m_initialTriggerMaskVetoAlgoTrig
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
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