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