CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
L1TGlobalPrescaler Class Reference
Inheritance diagram for L1TGlobalPrescaler:
edm::one::EDFilter<> edm::one::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual bool filter (edm::Event &event, edm::EventSetup const &setup) override
 
 L1TGlobalPrescaler (edm::ParameterSet const &config)
 
- Public Member Functions inherited from edm::one::EDFilter<>
 EDFilter ()=default
 
- Public Member Functions inherited from edm::one::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilterBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

enum  Mode {
  Mode::ApplyPrescaleValues, Mode::ApplyPrescaleRatios, Mode::ApplyColumnValues, Mode::ApplyColumnRatios,
  Mode::Invalid = -1
}
 

Private Attributes

std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggersm_counters
 
const int m_l1tPrescaleColumn
 
const std::array< double, GlobalAlgBlk::maxPhysicsTriggersm_l1tPrescales
 
const edm::EDGetTokenT< GlobalAlgBlkBxCollectionm_l1tResultsToken
 
const Mode m_mode
 
int m_oldIndex
 
std::array< double, GlobalAlgBlk::maxPhysicsTriggersm_prescales
 

Static Private Attributes

static const Entry< Modes_modes []
 

Additional Inherited Members

- Public Types inherited from edm::one::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 110 of file L1TGlobalPrescaler.cc.

Member Enumeration Documentation

enum L1TGlobalPrescaler::Mode
strongprivate
Enumerator
ApplyPrescaleValues 
ApplyPrescaleRatios 
ApplyColumnValues 
ApplyColumnRatios 
Invalid 

Definition at line 119 of file L1TGlobalPrescaler.cc.

119  {
120  ApplyPrescaleValues, // apply the given prescale values
121  ApplyPrescaleRatios, // apply prescales equal to ratio between the given values and the ones read from the EventSetup
122  ApplyColumnValues, // apply the prescale values from the EventSetup corresponding to the given column index
123  ApplyColumnRatios, // apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup
124  Invalid = -1
125  };

Constructor & Destructor Documentation

L1TGlobalPrescaler::L1TGlobalPrescaler ( edm::ParameterSet const &  config)

Definition at line 150 of file L1TGlobalPrescaler.cc.

References ApplyColumnRatios, ApplyColumnValues, ApplyPrescaleRatios, ApplyPrescaleValues, edm::errors::Configuration, Exception, edm::ParameterSet::getParameter(), Invalid, m_counters, m_l1tPrescales, m_mode, m_prescales, and AlCaHLTBitMon_QueryRunRegistry::string.

150  :
151  m_mode( get_enum_value(s_modes, config.getParameter<std::string>("mode").c_str(), Mode::Invalid) ),
152  m_l1tResultsToken( consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("l1tResults")) ),
154  make_array<double, GlobalAlgBlk::maxPhysicsTriggers>(config.getParameter<std::vector<double>>("l1tPrescales")) :
155  std::array<double, GlobalAlgBlk::maxPhysicsTriggers>() ),
157  config.getParameter<uint32_t>("l1tPrescaleColumn") : 0 ),
158  m_oldIndex(-1)
159 {
160  switch (m_mode) {
161  // if the mode is "applyPrescaleValues", use the given values
164  break;
165 
166  // otherwise we need to read the prescale values from the EventSetup
170  break;
171 
172  // this should never happen
173  case Mode::Invalid:
174  throw edm::Exception(edm::errors::Configuration) << "invalid mode \"" << config.getParameter<std::string>("mode") << "\"";
175  }
176 
177  m_counters.fill(0);
178  produces<GlobalAlgBlkBxCollection>();
179 }
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_l1tPrescales
std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
Definition: config.py:1
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1tResultsToken
static const Entry< Mode > s_modes[]

Member Function Documentation

void L1TGlobalPrescaler::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 311 of file L1TGlobalPrescaler.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), DEFINE_FWK_MODULE, edm::ParameterSetDescription::ifValue(), SelectingProcedure_cff::l1tResults, GlobalAlgBlk::maxPhysicsTriggers, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, or, s_modes, edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

311  {
312  // collection with the original uGT results
313  edm::ParameterDescription<edm::InputTag> l1tResults("l1tResults", edm::InputTag("gtStage2Digis"), true);
314  l1tResults.setComment("Collection with the original uGT results");
315 
316  // define how to apply the prescale values
317  edm::ParameterDescription<std::string> mode("mode", "applyPrescaleValues", true);
318  mode.setComment(build_comment_from_entries("Define how to apply the prescale values:", s_modes));
319 
320  // target prescale values (for modes "applyPrescaleValues" or "applyPrescaleRatios")
321  edm::ParameterDescription<std::vector<double>> l1tPrescales("l1tPrescales", std::vector<double>(GlobalAlgBlk::maxPhysicsTriggers, 1.), true);
322  l1tPrescales.setComment("Target prescale values (for modes \"applyPrescaleValues\" or \"applyPrescaleRatios\")");
323 
324  // target prescale column (for modes "applyColumnValues" or "applyColumnRatios")
325  edm::ParameterDescription<uint32_t> l1tPrescaleColumn("l1tPrescaleColumn", 0, true);
326  l1tPrescaleColumn.setComment("Target prescale column (for modes \"applyColumnValues\" or \"applyColumnRatios\")");
327 
328  // validaton of all possible configurations and applyPrescaleValues example
329  {
331  desc.addNode(l1tResults);
332  desc.ifValue(mode,
333  // if mode is "applyPrescaleValues" or "applyPrescaleRatios", read the target prescales
334  "applyPrescaleValues" >> l1tPrescales or
335  "applyPrescaleRatios" >> l1tPrescales or
336  // if mode is "applyColumnValues" or "applyColumnRatios", read the target column
337  "applyColumnValues" >> l1tPrescaleColumn or
338  "applyColumnRatios" >> l1tPrescaleColumn );
339  descriptions.add("l1tGlobalPrescaler", desc);
340  }
341 
342  // applyColumnRatios example
343  {
345  desc.addNode(l1tResults);
346  desc.add<std::string>("mode", "applyColumnRatios")->setComment("apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup");
347  desc.addNode(l1tPrescaleColumn);
348  descriptions.add("l1tGlobalPrescalerTargetColumn", desc);
349  }
350 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const Entry< Mode > s_modes[]
bool L1TGlobalPrescaler::filter ( edm::Event event,
edm::EventSetup const &  setup 
)
overridevirtual

Implements edm::one::EDFilterBase.

Definition at line 181 of file L1TGlobalPrescaler.cc.

References ApplyColumnRatios, ApplyColumnValues, ApplyPrescaleRatios, BXVector< T >::at(), edm::errors::Configuration, cmsPerfStripChart::format, edm::EventSetup::get(), GlobalAlgBlk::getAlgoDecisionFinal(), GlobalAlgBlk::getFinalORVeto(), GlobalAlgBlk::getPreScColumn(), h, cmsBatch::handle, i, diffTreeTool::index, BXVector< T >::isEmpty(), edm::errors::LogicError, m_counters, m_l1tPrescaleColumn, m_l1tPrescales, m_l1tResultsToken, m_mode, m_oldIndex, m_prescales, GlobalAlgBlk::maxPhysicsTriggers, min(), eostools::move(), or, L1TGlobalPrescalesVetos::prescale_table_, mps_fire::result, GlobalAlgBlk::setAlgoDecisionFinal(), GlobalAlgBlk::setFinalOR(), GlobalAlgBlk::setFinalORPreVeto(), and GlobalAlgBlk::setPreScColumn().

181  {
183  event.getByToken(m_l1tResultsToken, handle);
184 
185  // if the input collection does not have any information for bx 0,
186  // produce an empty collection, and fail
187  if (handle->isEmpty(0)) {
188  std::unique_ptr<GlobalAlgBlkBxCollection> result(new GlobalAlgBlkBxCollection());
189  event.put(std::move(result));
190  return false;
191  }
192 
193  // read the prescale index
194  int index = handle->at(0,0).getPreScColumn();
195  assert(index >= 0);
196 
197  // Mode::ApplyPrescaleRatios
198  // apply prescales equal to ratio between the given values and the ones read from the EventSetup
199  if (m_mode == Mode::ApplyPrescaleRatios and m_oldIndex != index) {
201  setup.get<L1TGlobalPrescalesVetosRcd>().get(h);
202  auto const & prescaleTable = h->prescale_table_;
203  if (index >= (int) prescaleTable.size())
204  throw edm::Exception(edm::errors::LogicError) << boost::format("The prescale index %d is invalid, it should be smaller than the prescale table size %d.") % index % prescaleTable.size();
205  auto const & prescales = prescaleTable[index];
206  unsigned long i = 0;
207  for (; i < std::min(prescales.size(), (unsigned long) GlobalAlgBlk::maxPhysicsTriggers); ++i)
208  if (prescales[i] == 0)
209  // if the trigger was disabled, keep it disabled
210  m_prescales[i] = 0.;
211  else
212  // if the target prescale is lower than the original prescale, keep the trigger unprescaled
213  m_prescales[i] = m_l1tPrescales[i] < prescales[i] ? 1. : (double) m_l1tPrescales[i] / prescales[i];
214  for (; i < (unsigned long) GlobalAlgBlk::maxPhysicsTriggers; ++i)
215  // disable the triggers not included in the prescale table
216  m_prescales[i] = 0.;
217  // reset the prescales
218  m_counters.fill(0);
219  m_oldIndex = index;
220  }
221 
222  // Mode::ApplyColumnValues
223  // apply the prescale values from the EventSetup corresponding to the given column index
226  setup.get<L1TGlobalPrescalesVetosRcd>().get(h);
227  auto const & prescaleTable = h->prescale_table_;
228  if (m_l1tPrescaleColumn >= (int) prescaleTable.size())
229  throw edm::Exception(edm::errors::Configuration) << boost::format("The prescale index %d is invalid, it should be smaller than the prescale table size %d.") % m_l1tPrescaleColumn % prescaleTable.size();
230  auto const & targets = prescaleTable[m_l1tPrescaleColumn];
231  unsigned long i = 0;
232  for (; i < std::min(targets.size(), (unsigned long) GlobalAlgBlk::maxPhysicsTriggers); ++i)
233  // read the prescales from the EventSetup
234  m_prescales[i] = targets[i];
235  for (; i < (unsigned long) GlobalAlgBlk::maxPhysicsTriggers; ++i)
236  // disable the triggers not included in the prescale table
237  m_prescales[i] = 0.;
238  // reset the prescales
239  m_counters.fill(0);
241  }
242 
243  // Mode::ApplyColumnRatios
244  // apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup
245  if (m_mode == Mode::ApplyColumnRatios and m_oldIndex != index) {
247  setup.get<L1TGlobalPrescalesVetosRcd>().get(h);
248  auto const & prescaleTable = h->prescale_table_;
249  if (index >= (int) prescaleTable.size())
250  throw edm::Exception(edm::errors::LogicError) << boost::format("The prescale index %d is invalid, it should be smaller than the prescale table size %d.") % index % prescaleTable.size();
251  if (m_l1tPrescaleColumn >= (int) prescaleTable.size())
252  throw edm::Exception(edm::errors::Configuration) << boost::format("The prescale index %d is invalid, it should be smaller than the prescale table size %d.") % m_l1tPrescaleColumn % prescaleTable.size();
253  auto const & prescales = prescaleTable[index];
254  auto const & targets = prescaleTable[m_l1tPrescaleColumn];
255  unsigned long i = 0;
256  for (; i < std::min({prescales.size(), targets.size(), (unsigned long) GlobalAlgBlk::maxPhysicsTriggers}); ++i)
257  if (prescales[i] == 0)
258  // if the trigger was disabled, keep it disabled
259  m_prescales[i] = 0.;
260  else
261  // if the target prescale is lower than the original prescale, keep the trigger unprescaled
262  m_prescales[i] = targets[i] < prescales[i] ? 1. : (double) targets[i] / prescales[i];
263  for (; i < (unsigned long) GlobalAlgBlk::maxPhysicsTriggers; ++i)
264  // disable the triggers not included in the prescale table
265  m_prescales[i] = 0.;
266  // reset the prescales
267  m_counters.fill(0);
268  m_oldIndex = index;
269  }
270 
271  // make a copy of the GlobalAlgBlk for bx 0
272  GlobalAlgBlk algoBlock = handle->at(0,0);
273 
274  bool finalOr = false;
275 
276  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) {
277  if (m_prescales[i] == 0) {
278  // mask this trigger: reset the bit
279  algoBlock.setAlgoDecisionFinal(i, false);
280  } else if (algoBlock.getAlgoDecisionFinal(i)) {
281  // prescale this trigger
282  ++m_counters[i];
283  if (std::fmod(m_counters[i], m_prescales[i]) < 1)
284  // the prescale is successful, keep the bit set
285  finalOr = true;
286  else
287  // the prescale failed, reset the bit
288  algoBlock.setAlgoDecisionFinal(i, false);
289  }
290  }
291 
292  // set the final OR
293  algoBlock.setFinalORPreVeto(finalOr);
294  if (algoBlock.getFinalORVeto())
295  finalOr = false;
296  algoBlock.setFinalOR(finalOr);
297 
298  // set the new prescale column
301 
302  // create a new GlobalAlgBlkBxCollection, and set the new prescaled decisions for bx 0
303  std::unique_ptr<GlobalAlgBlkBxCollection> result(new GlobalAlgBlkBxCollection());
304  result->push_back(0, algoBlock);
305  event.put(std::move(result));
306 
307  return finalOr;
308 }
int i
Definition: DBlmapReader.cc:9
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void setFinalORPreVeto(bool fOR)
Definition: GlobalAlgBlk.h:59
std::vector< bool > const & getAlgoDecisionFinal() const
Definition: GlobalAlgBlk.h:88
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_l1tPrescales
std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
bool isEmpty(int bx) const
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
Definition: GlobalAlgBlk.h:31
const bool getFinalORVeto() const
Definition: GlobalAlgBlk.h:69
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
const int getPreScColumn() const
Definition: GlobalAlgBlk.h:70
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
format
Some error handling for the usage.
T min(T a, T b)
Definition: MathUtil.h:58
void setFinalOR(bool fOR)
Definition: GlobalAlgBlk.h:60
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1tResultsToken
std::vector< std::vector< int > > prescale_table_
void setPreScColumn(int psC)
Definition: GlobalAlgBlk.h:61
def move(src, dest)
Definition: eostools.py:510
void setAlgoDecisionFinal(unsigned int bit, bool val)
const T & at(int bx, unsigned i) const

Member Data Documentation

std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers> L1TGlobalPrescaler::m_counters
private

Definition at line 140 of file L1TGlobalPrescaler.cc.

Referenced by filter(), and L1TGlobalPrescaler().

const int L1TGlobalPrescaler::m_l1tPrescaleColumn
private

Definition at line 141 of file L1TGlobalPrescaler.cc.

Referenced by filter().

const std::array<double, GlobalAlgBlk::maxPhysicsTriggers> L1TGlobalPrescaler::m_l1tPrescales
private

Definition at line 138 of file L1TGlobalPrescaler.cc.

Referenced by filter(), and L1TGlobalPrescaler().

const edm::EDGetTokenT<GlobalAlgBlkBxCollection> L1TGlobalPrescaler::m_l1tResultsToken
private

Definition at line 137 of file L1TGlobalPrescaler.cc.

Referenced by filter().

const Mode L1TGlobalPrescaler::m_mode
private

Definition at line 136 of file L1TGlobalPrescaler.cc.

Referenced by filter(), and L1TGlobalPrescaler().

int L1TGlobalPrescaler::m_oldIndex
private

Definition at line 142 of file L1TGlobalPrescaler.cc.

Referenced by filter().

std::array<double, GlobalAlgBlk::maxPhysicsTriggers> L1TGlobalPrescaler::m_prescales
private

Definition at line 139 of file L1TGlobalPrescaler.cc.

Referenced by filter(), and L1TGlobalPrescaler().

const Entry< L1TGlobalPrescaler::Mode > L1TGlobalPrescaler::s_modes
staticprivate
Initial value:
{
{ Mode::ApplyPrescaleValues, "applyPrescaleValues", "apply the given prescale values" },
{ Mode::ApplyPrescaleRatios, "applyPrescaleRatios", "apply prescales equal to ratio between the given values and the ones read from the EventSetup" },
{ Mode::ApplyColumnValues, "applyColumnValues", "apply the prescale values from the EventSetup corresponding to the given column index" },
{ Mode::ApplyColumnRatios, "applyColumnRatios", "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup" },
{ Mode::Invalid, 0 , 0 }
}

Definition at line 128 of file L1TGlobalPrescaler.cc.

Referenced by fillDescriptions().