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 
11 
14 
15 // Objects to produce for the output record.
19 
24 
26 
28 
30 
31 // forward declarations
32 
33 // class declaration
34 
35 namespace l1t {
36 
37  // Use this to tell the EventSetup whether it should prefetch
38  // data when processing beginRun or an Event or both. (This
39  // depends on when retrieveL1 and retrieveL1Setup are called)
41 
42  class L1TGlobalUtil {
43  public:
44  // Using this constructor will require InputTags to be specified in the configuration
48 
52 
53  // Using this constructor will cause it to look for valid InputTags in
54  // the following ways in the specified order until they are found.
55  // 1. The configuration
56  // 2. Search all products from the preferred input tags for the required type
57  // 3. Search all products from any other process for the required type
58  template <typename T>
61  T& module,
63 
64  template <typename T>
67  T& module,
69 
70  // Using this constructor will cause it to look for valid InputTags in
71  // the following ways in the specified order until they are found.
72  // 1. The constructor arguments
73  // 2. The configuration
74  // 3. Search all products from the preferred input tags for the required type
75  // 4. Search all products from any other process for the required type
76  template <typename T>
79  T& module,
83 
84  template <typename T>
87  T& module,
91 
93  virtual ~L1TGlobalUtil();
94 
96  bool valid() const;
97 
99 
100  // OverridePrescalesAndMasks
101  // The ability to override the prescale/mask file will not be part of the permanent interface of this class.
102  // It is provided only until prescales and masks are available as CondFormats...
103  // Most users should simply ignore this method and use the default ctor only!
104  // Will look for prescale csv file in L1Trigger/L1TGlobal/data/Luminosity/startup/<filename>
105  void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn = 1);
106 
108  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
109  void retrieveL1(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
110  void retrieveL1Setup(const edm::EventSetup& evSetup); // Use this one only during beginRun
111  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup); // using helper
112  void retrieveL1Event(const edm::Event& iEvent, const edm::EventSetup& evSetup, edm::EDGetToken gtAlgToken);
113 
114  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
115 
116  inline bool getFinalOR() const { return m_finalOR; }
117 
118  // get the trigger bit from the name
119  const bool getAlgBitFromName(const std::string& AlgName, int& bit) const;
120 
121  // get the name from the trigger bit
122  const bool getAlgNameFromBit(int& bit, std::string& AlgName) const;
123 
124  // Access results for particular trigger bit
125  const bool getInitialDecisionByBit(int& bit, bool& decision) const;
126  const bool getIntermDecisionByBit(int& bit, bool& decision) const;
127  const bool getFinalDecisionByBit(int& bit, bool& decision) const;
128 
129  // Access Prescale
130  const bool getPrescaleByBit(int& bit, int& prescale) const;
131 
132  // Access Masks:
133  // follows logic of uGT board:
134  // finalDecision[AlgBit]
135  // Final word is after application of prescales.
136  // A prescale = 0 effectively masks out the algorithm in the final decision word
137  //
138  const bool getMaskByBit(int& bit, std::vector<int>& mask) const;
139 
140  // Access results for particular trigger name
141  const bool getInitialDecisionByName(const std::string& algName, bool& decision) const;
142  const bool getIntermDecisionByName(const std::string& algName, bool& decision) const;
143  const bool getFinalDecisionByName(const std::string& algName, bool& decision) const;
144 
145  // Access Prescales
146  const bool getPrescaleByName(const std::string& algName, int& prescale) const;
147 
148  // Access Masks (see note) above
149  const bool getMaskByName(const std::string& algName, std::vector<int>& mask) const;
150 
151  // Some inline commands to return the full vectors
152  inline const std::vector<std::pair<std::string, bool>>& decisionsInitial() { return m_decisionsInitial; }
153  inline const std::vector<std::pair<std::string, bool>>& decisionsInterm() { return m_decisionsInterm; }
154  inline const std::vector<std::pair<std::string, bool>>& decisionsFinal() { return m_decisionsFinal; }
155 
156  // Access all prescales
157  inline const std::vector<std::pair<std::string, int>>& prescales() { return m_prescales; }
158 
159  // Access Masks (see note) above
160  inline const std::vector<std::pair<std::string, std::vector<int>>>& masks() { return m_masks; }
161 
162  // Menu names
163  inline const std::string& gtTriggerMenuName() const { return m_l1GtMenu->getName(); }
164  inline const std::string& gtTriggerMenuVersion() const { return m_l1GtMenu->getVersion(); }
165  inline const std::string& gtTriggerMenuComment() const { return m_l1GtMenu->getComment(); }
166 
167  // Prescale Column
168  inline unsigned int prescaleColumn() const { return m_PreScaleColumn; }
169  inline unsigned int numberOfPreScaleColumns() const { return m_numberOfPreScaleColumns; }
170 
171  private:
172  L1TGlobalUtil();
173 
174  void retrieveL1Setup(const edm::EventSetup& evSetup, bool isRun);
175  void eventSetupConsumes(edm::ConsumesCollector& iC, UseEventSetupIn useEventSetupIn);
176 
178  void resetDecisionVectors();
179  void resetPrescaleVectors();
180  void resetMaskVectors();
181  void loadPrescalesAndMasks();
182 
183  // trigger menu
185  unsigned long long m_l1GtMenuCacheID;
186 
187  // prescale factors
190  unsigned long long m_l1GtPfAlgoCacheID;
191 
192  // prescales and masks
194 
195  // algorithm maps
196  //const AlgorithmMap* m_algorithmMap;
197  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
198 
199  // Number of physics triggers
200  unsigned int m_numberPhysTriggers;
201  const unsigned int m_maxNumberPhysTriggers = 512;
202 
203  //file and container for prescale factors
205  unsigned int m_PreScaleColumn;
207 
208  std::vector<std::vector<int>> m_initialPrescaleFactorsAlgoTrig;
209  const std::vector<std::vector<int>>* m_prescaleFactorsAlgoTrig;
210  const std::map<int, std::vector<int>> m_initialTriggerMaskAlgoTrig;
211  const std::map<int, std::vector<int>>* m_triggerMaskAlgoTrig; // vector stores the BX
212 
213  // access to the results block from uGT
215 
216  // final OR
217  bool m_finalOR;
218 
219  // Vectors containing the trigger name and information about that trigger
220  std::vector<std::pair<std::string, bool>> m_decisionsInitial;
221  std::vector<std::pair<std::string, bool>> m_decisionsInterm;
222  std::vector<std::pair<std::string, bool>> m_decisionsFinal;
223  std::vector<std::pair<std::string, int>> m_prescales;
224  std::vector<std::pair<std::string, std::vector<int>>> m_masks; // vector stores the bx's that are mask for given algo
225 
228 
229  std::unique_ptr<L1TGlobalUtilHelper> m_l1tGlobalUtilHelper;
230 
233 
236  };
237 
238  template <typename T>
241  T& module,
242  UseEventSetupIn useEventSetupIn)
243  : L1TGlobalUtil(pset, iC, module, useEventSetupIn) {}
244 
245  template <typename T>
248  T& module,
249  UseEventSetupIn useEventSetupIn)
250  : L1TGlobalUtil() {
252  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
253  eventSetupConsumes(iC, useEventSetupIn);
254  }
255 
256  template <typename T>
259  T& module,
262  UseEventSetupIn useEventSetupIn)
263  : L1TGlobalUtil(pset, iC, module, l1tAlgBlkInputTag, l1tExtBlkInputTag, useEventSetupIn) {}
264 
265  template <typename T>
268  T& module,
271  UseEventSetupIn useEventSetupIn)
272  : L1TGlobalUtil() {
274  m_readPrescalesFromFile = m_l1tGlobalUtilHelper->readPrescalesFromFile();
275  eventSetupConsumes(iC, useEventSetupIn);
276  }
277 } // namespace l1t
278 #endif
l1t::L1TGlobalUtil::OverridePrescalesAndMasks
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1)
Definition: L1TGlobalUtil.cc:59
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
l1t::L1TGlobalUtil::gtTriggerMenuComment
const std::string & gtTriggerMenuComment() const
Definition: L1TGlobalUtil.h:165
l1t::L1TGlobalUtil::decisionsInterm
const std::vector< std::pair< std::string, bool > > & decisionsInterm()
Definition: L1TGlobalUtil.h:153
l1t::L1TGlobalUtil::m_numberOfPreScaleColumns
unsigned int m_numberOfPreScaleColumns
Definition: L1TGlobalUtil.h:206
L1TUtmTriggerMenuRcd.h
L1TUtmTriggerMenu::getName
const std::string & getName() const
Definition: L1TUtmTriggerMenu.h:79
l1t::L1TGlobalUtil::getPrescaleByBit
const bool getPrescaleByBit(int &bit, int &prescale) const
Definition: L1TGlobalUtil.cc:507
l1t::L1TGlobalUtil::m_PreScaleColumn
unsigned int m_PreScaleColumn
Definition: L1TGlobalUtil.h:205
l1t::L1TGlobalUtil::m_l1GtPrescalesVetoes
const l1t::PrescalesVetosHelper * m_l1GtPrescalesVetoes
Definition: L1TGlobalUtil.h:189
l1t::L1TGlobalUtil::fillDescription
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1TGlobalUtil.h:98
l1t::L1TGlobalUtil::numberOfPreScaleColumns
unsigned int numberOfPreScaleColumns() const
Definition: L1TGlobalUtil.h:169
GlobalExtBlk.h
l1t::L1TGlobalUtil::valid
bool valid() const
check that the L1TGlobalUtil has been properly initialised
Definition: L1TGlobalUtil.cc:57
l1t::L1TGlobalUtil::m_prescaleFactorsAlgoTrig
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1TGlobalUtil.h:209
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
l1t::L1TGlobalUtil::m_decisionsInterm
std::vector< std::pair< std::string, bool > > m_decisionsInterm
Definition: L1TGlobalUtil.h:221
l1t::L1TGlobalUtil::getFinalDecisionByName
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
Definition: L1TGlobalUtil.cc:546
l1t::UseEventSetupIn::Run
l1t::L1TGlobalUtil::m_l1GtMenu
const L1TUtmTriggerMenu * m_l1GtMenu
Definition: L1TGlobalUtil.h:184
L1TUtmTriggerMenu::getComment
const std::string & getComment() const
Definition: L1TUtmTriggerMenu.h:91
l1t::UseEventSetupIn
UseEventSetupIn
Definition: L1TGlobalUtil.h:40
l1t::L1TGlobalUtil::m_finalOR
bool m_finalOR
Definition: L1TGlobalUtil.h:217
l1t::UseEventSetupIn::Event
l1t::L1TGlobalUtil::retrieveL1Setup
void retrieveL1Setup(const edm::EventSetup &evSetup)
Definition: L1TGlobalUtil.cc:83
l1t::L1TGlobalUtil::eventSetupConsumes
void eventSetupConsumes(edm::ConsumesCollector &iC, UseEventSetupIn useEventSetupIn)
Definition: L1TGlobalUtil.cc:397
l1t::L1TGlobalUtil::m_algorithmMap
const std::map< std::string, L1TUtmAlgorithm > * m_algorithmMap
Definition: L1TGlobalUtil.h:197
L1TUtmAlgorithm.h
l1t::L1TGlobalUtil::m_l1GtMenuCacheID
unsigned long long m_l1GtMenuCacheID
Definition: L1TGlobalUtil.h:185
edm::Handle
Definition: AssociativeIterator.h:50
l1t::L1TGlobalUtil::m_masks
std::vector< std::pair< std::string, std::vector< int > > > m_masks
Definition: L1TGlobalUtil.h:224
ESGetToken.h
l1t::L1TGlobalUtil::prescales
const std::vector< std::pair< std::string, int > > & prescales()
Definition: L1TGlobalUtil.h:157
L1TGlobalUtilHelper.h
L1TGlobalPrescalesVetosRcd.h
L1TUtmTriggerMenu
Definition: L1TUtmTriggerMenu.h:36
l1t::L1TGlobalUtil::loadPrescalesAndMasks
void loadPrescalesAndMasks()
Definition: L1TGlobalUtil.cc:281
l1t::L1TGlobalUtil::getFinalDecisionByBit
const bool getFinalDecisionByBit(int &bit, bool &decision) const
Definition: L1TGlobalUtil.cc:498
l1t::L1TGlobalUtil::getMaskByName
const bool getMaskByName(const std::string &algName, std::vector< int > &mask) const
Definition: L1TGlobalUtil.cc:564
l1t::L1TGlobalUtil::m_L1TUtmTriggerMenuEventToken
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuEventToken
Definition: L1TGlobalUtil.h:234
l1t::L1TGlobalUtil::m_triggerMaskAlgoTrig
const std::map< int, std::vector< int > > * m_triggerMaskAlgoTrig
Definition: L1TGlobalUtil.h:211
l1t::L1TGlobalUtilHelper::fillDescription
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1TGlobalUtilHelper.cc:22
l1t::L1TGlobalUtil::m_L1TUtmTriggerMenuRunToken
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_L1TUtmTriggerMenuRunToken
Definition: L1TGlobalUtil.h:231
l1t::L1TGlobalUtil::m_maxNumberPhysTriggers
const unsigned int m_maxNumberPhysTriggers
Definition: L1TGlobalUtil.h:201
l1t::L1TGlobalUtil::decisionsFinal
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
Definition: L1TGlobalUtil.h:154
l1t::L1TGlobalUtil
Definition: L1TGlobalUtil.h:42
l1t::L1TGlobalUtil::m_l1tGlobalUtilHelper
std::unique_ptr< L1TGlobalUtilHelper > m_l1tGlobalUtilHelper
Definition: L1TGlobalUtil.h:229
SiStripSourceConfigTier0_cff.l1tExtBlkInputTag
l1tExtBlkInputTag
Definition: SiStripSourceConfigTier0_cff.py:73
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
l1t::L1TGlobalUtil::m_L1TGlobalPrescalesVetosRunToken
edm::ESGetToken< L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd > m_L1TGlobalPrescalesVetosRunToken
Definition: L1TGlobalUtil.h:232
PrescalesVetosHelper.h
l1t::L1TGlobalUtil::m_readPrescalesFromFile
bool m_readPrescalesFromFile
Definition: L1TGlobalUtil.h:188
l1t::L1TGlobalUtil::L1TGlobalUtil
L1TGlobalUtil()
Definition: L1TGlobalUtil.cc:21
l1t::L1TGlobalUtil::getAlgNameFromBit
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
Definition: L1TGlobalUtil.cc:466
l1t::L1TGlobalUtil::m_l1GtPfAlgoCacheID
unsigned long long m_l1GtPfAlgoCacheID
Definition: L1TGlobalUtil.h:190
l1t::PrescalesVetosHelper
Definition: PrescalesVetosHelper.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1TUtmTriggerMenu.h
l1t::L1TGlobalUtil::getFinalOR
bool getFinalOR() const
Definition: L1TGlobalUtil.h:116
l1t::L1TGlobalUtil::m_decisionsFinal
std::vector< std::pair< std::string, bool > > m_decisionsFinal
Definition: L1TGlobalUtil.h:222
edm::ParameterSet
Definition: ParameterSet.h:36
l1t::L1TGlobalUtil::prescaleColumn
unsigned int prescaleColumn() const
Definition: L1TGlobalUtil.h:168
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
l1t::L1TGlobalUtil::gtTriggerMenuVersion
const std::string & gtTriggerMenuVersion() const
Definition: L1TGlobalUtil.h:164
l1t::L1TGlobalUtil::m_preScaleFileName
std::string m_preScaleFileName
Definition: L1TGlobalUtil.h:204
l1t::L1TGlobalUtil::getAlgBitFromName
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
Definition: L1TGlobalUtil.cc:456
l1t::L1TGlobalUtil::gtTriggerMenuName
const std::string & gtTriggerMenuName() const
Definition: L1TGlobalUtil.h:163
l1t::L1TGlobalUtil::retrieveL1
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)
Definition: L1TGlobalUtil.cc:65
iEvent
int iEvent
Definition: GenABIO.cc:224
l1t::L1TGlobalUtil::getInitialDecisionByBit
const bool getInitialDecisionByBit(int &bit, bool &decision) const
Definition: L1TGlobalUtil.cc:475
GlobalAlgBlk.h
l1t::L1TGlobalUtil::getIntermDecisionByBit
const bool getIntermDecisionByBit(int &bit, bool &decision) const
Definition: L1TGlobalUtil.cc:489
l1t::L1TGlobalUtil::resetPrescaleVectors
void resetPrescaleVectors()
Definition: L1TGlobalUtil.cc:434
edm::EventSetup
Definition: EventSetup.h:57
l1t::L1TGlobalUtil::retrieveL1Event
void retrieveL1Event(const edm::Event &iEvent, const edm::EventSetup &evSetup)
Definition: L1TGlobalUtil.cc:209
module
Definition: vlib.h:198
edm::EDGetToken
Definition: EDGetToken.h:35
l1t::L1TGlobalUtil::decisionsInitial
const std::vector< std::pair< std::string, bool > > & decisionsInitial()
Definition: L1TGlobalUtil.h:152
prescale
Definition: PrescaleEventFilter.cc:32
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd >
l1t::L1TGlobalUtil::m_initialTriggerMaskAlgoTrig
const std::map< int, std::vector< int > > m_initialTriggerMaskAlgoTrig
Definition: L1TGlobalUtil.h:210
l1t::UseEventSetupIn::RunAndEvent
l1t::L1TGlobalUtil::m_verbosity
int m_verbosity
verbosity level
Definition: L1TGlobalUtil.h:227
InputTag.h
l1t::L1TGlobalUtil::m_uGtAlgBlk
edm::Handle< BXVector< GlobalAlgBlk > > m_uGtAlgBlk
Definition: L1TGlobalUtil.h:214
L1TGlobalPrescalesVetos.h
l1t::L1TGlobalUtil::resetDecisionVectors
void resetDecisionVectors()
clear decision vectors on a menu change
Definition: L1TGlobalUtil.cc:413
l1t::L1TGlobalUtil::m_decisionsInitial
std::vector< std::pair< std::string, bool > > m_decisionsInitial
Definition: L1TGlobalUtil.h:220
l1t::L1TGlobalUtil::getIntermDecisionByName
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
Definition: L1TGlobalUtil.cc:536
L1TUtmTriggerMenu::getVersion
const std::string & getVersion() const
Definition: L1TUtmTriggerMenu.h:85
l1t::L1TGlobalUtil::setVerbosity
void setVerbosity(const int verbosity)
Definition: L1TGlobalUtil.h:114
l1t::L1TGlobalUtil::getInitialDecisionByName
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
Definition: L1TGlobalUtil.cc:526
l1t::L1TGlobalUtil::m_filledPrescales
bool m_filledPrescales
Definition: L1TGlobalUtil.h:193
T
long double T
Definition: Basic3DVectorLD.h:48
l1t::L1TGlobalUtil::m_L1TGlobalPrescalesVetosEventToken
edm::ESGetToken< L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd > m_L1TGlobalPrescalesVetosEventToken
Definition: L1TGlobalUtil.h:235
l1t::L1TGlobalUtil::m_initialPrescaleFactorsAlgoTrig
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
Definition: L1TGlobalUtil.h:208
HLT_2018_cff.psColumn
psColumn
Definition: HLT_2018_cff.py:88422
EventSetup.h
ConsumesCollector.h
l1t::L1TGlobalUtil::resetMaskVectors
void resetMaskVectors()
Definition: L1TGlobalUtil.cc:445
edm::Event
Definition: Event.h:73
l1t::L1TGlobalUtil::m_prescales
std::vector< std::pair< std::string, int > > m_prescales
Definition: L1TGlobalUtil.h:223
l1t::L1TGlobalUtil::m_numberPhysTriggers
unsigned int m_numberPhysTriggers
Definition: L1TGlobalUtil.h:200
l1t::L1TGlobalUtil::getMaskByBit
const bool getMaskByBit(int &bit, std::vector< int > &mask) const
Definition: L1TGlobalUtil.cc:516
edm::InputTag
Definition: InputTag.h:15
l1t::L1TGlobalUtil::masks
const std::vector< std::pair< std::string, std::vector< int > > > & masks()
Definition: L1TGlobalUtil.h:160
l1t::L1TGlobalUtil::~L1TGlobalUtil
virtual ~L1TGlobalUtil()
destructor
Definition: L1TGlobalUtil.cc:52
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
l1t::L1TGlobalUtil::getPrescaleByName
const bool getPrescaleByName(const std::string &algName, int &prescale) const
Definition: L1TGlobalUtil.cc:555
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
l1t::L1TGlobalUtilHelper
Definition: L1TGlobalUtilHelper.h:38
SiStripSourceConfigTier0_cff.l1tAlgBlkInputTag
l1tAlgBlkInputTag
Definition: SiStripSourceConfigTier0_cff.py:72