CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
HLTPrescaler Class Reference

#include <HLTPrescaler.h>

Inheritance diagram for HLTPrescaler:
edm::stream::EDFilter< edm::GlobalCache< trigger::Efficiency > > edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &lb, edm::EventSetup const &iSetup) override
 
void endStream () override
 
bool filter (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 
 HLTPrescaler (edm::ParameterSet const &iConfig, const trigger::Efficiency *efficiency)
 
 ~HLTPrescaler () override
 
- Public Member Functions inherited from edm::stream::EDFilter< edm::GlobalCache< trigger::Efficiency > >
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~EDFilterBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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 & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void globalEndJob (const trigger::Efficiency *efficiency)
 
static std::unique_ptr< trigger::EfficiencyinitializeGlobalCache (edm::ParameterSet const &)
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

unsigned int acceptCount_
 accept counter More...
 
unsigned int eventCount_
 event counter More...
 
edm::EDGetTokenT< L1GlobalTriggerReadoutRecordgtDigi1Token_
 
edm::EDGetTokenT< GlobalAlgBlkBxCollectiongtDigi2Token_
 
edm::InputTag gtDigiTag_
 GT payload, to extract the prescale column index. More...
 
bool newLumi_
 check for (re)initialization of the prescale More...
 
unsigned int offsetCount_
 initial offset More...
 
unsigned int offsetPhase_
 
unsigned int prescaleFactor_
 accept one in prescaleFactor_; 0 means never to accept an event More...
 
edm::service::PrescaleServiceprescaleService_
 prescale service More...
 
unsigned int prescaleSet_
 l1 prescale set index More...
 

Static Private Attributes

static const unsigned int prescaleSeed_ = 65537
 "seed" used to initialize the prescale counter More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter< edm::GlobalCache< trigger::Efficiency > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

This class is an EDFilter implementing an HLT Prescaler module with associated book keeping.

Author
Martin Grunewald
Philipp Schieferdecker

Definition at line 42 of file HLTPrescaler.h.

Constructor & Destructor Documentation

◆ HLTPrescaler()

HLTPrescaler::HLTPrescaler ( edm::ParameterSet const &  iConfig,
const trigger::Efficiency efficiency 
)
explicit

Definition at line 30 of file HLTPrescaler.cc.

References LogDebug, Utilities::operator, and prescaleService_.

31  : prescaleSet_(0),
32  prescaleFactor_(1),
33  eventCount_(0),
34  acceptCount_(0),
35  offsetCount_(0),
36  offsetPhase_(iConfig.getParameter<unsigned int>("offset")),
37  prescaleService_(nullptr),
38  newLumi_(true),
39  gtDigiTag_(iConfig.getParameter<edm::InputTag>("L1GtReadoutRecordTag")),
40  gtDigi1Token_(consumes<L1GlobalTriggerReadoutRecord>(gtDigiTag_)),
41  gtDigi2Token_(consumes<GlobalAlgBlkBxCollection>(gtDigiTag_)) {
44  else
45  LogDebug("NoPrescaleService") << "PrescaleService unavailable, prescaleFactor=1!";
46 }
edm::service::PrescaleService * prescaleService_
prescale service
Definition: HLTPrescaler.h:85
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:78
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:75
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:88
unsigned int prescaleSet_
l1 prescale set index
Definition: HLTPrescaler.h:69
edm::InputTag gtDigiTag_
GT payload, to extract the prescale column index.
Definition: HLTPrescaler.h:91
edm::EDGetTokenT< GlobalAlgBlkBxCollection > gtDigi2Token_
Definition: HLTPrescaler.h:93
unsigned int offsetPhase_
Definition: HLTPrescaler.h:82
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtDigi1Token_
Definition: HLTPrescaler.h:92
unsigned int offsetCount_
initial offset
Definition: HLTPrescaler.h:81
#define LogDebug(id)
unsigned int prescaleFactor_
accept one in prescaleFactor_; 0 means never to accept an event
Definition: HLTPrescaler.h:72

◆ ~HLTPrescaler()

HLTPrescaler::~HLTPrescaler ( )
overridedefault

Member Function Documentation

◆ beginLuminosityBlock()

void HLTPrescaler::beginLuminosityBlock ( edm::LuminosityBlock const &  lb,
edm::EventSetup const &  iSetup 
)
overridevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 63 of file HLTPrescaler.cc.

References newLumi_.

63  {
64  newLumi_ = true;
65 }
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:88

◆ endStream()

void HLTPrescaler::endStream ( )
overridevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 132 of file HLTPrescaler.cc.

References acceptCount_, and eventCount_.

132  {
133  //since these are std::atomic, it is safe to increment them
134  // even if multiple endStreams are being called.
135  globalCache()->eventCount_ += eventCount_;
136  globalCache()->acceptCount_ += acceptCount_;
137  return;
138 }
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:78
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:75

◆ fillDescriptions()

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

Definition at line 55 of file HLTPrescaler.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

55  {
57  desc.add<unsigned int>("offset", 0);
58  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtStage2Digis"));
59  descriptions.add("hltPrescaler", desc);
60 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ filter()

bool HLTPrescaler::filter ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements edm::stream::EDFilterBase.

Definition at line 68 of file HLTPrescaler.cc.

References acceptCount_, BXVector< T >::begin(), eventCount_, edm::service::PrescaleService::getPrescale(), gtDigi1Token_, gtDigi2Token_, L1GlobalTriggerReadoutRecord::gtFdlWord(), L1GtFdlWord::gtPrescaleFactorIndexAlgo(), iEvent, BXVector< T >::isEmpty(), edm::HandleBase::isValid(), newLumi_, offsetCount_, offsetPhase_, hltMonBTagIPClient_cfi::pathName, prescaleFactor_, prescaleSeed_, prescaleService_, prescaleSet_, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

68  {
69  // during the first event of a LumiSection, read from the GT the prescale index for this
70  // LumiSection and get the corresponding prescale factor from the PrescaleService
71  if (newLumi_) {
72  newLumi_ = false;
73 
74  bool needsInit(eventCount_ == 0);
75 
76  if (prescaleService_) {
77  std::string const& pathName = iEvent.moduleCallingContext()->placeInPathContext()->pathContext()->pathName();
78  const unsigned int oldSet(prescaleSet_);
79  const unsigned int oldPrescale(prescaleFactor_);
80 
82  iEvent.getByToken(gtDigi2Token_, handle2);
83  if (handle2.isValid()) {
84  if (not handle2->isEmpty(0)) {
85  prescaleSet_ = static_cast<unsigned int>(handle2->begin(0)->getPreScColumn());
87  } else {
88  edm::LogWarning("HLT")
89  << "Cannot read prescale column index from GT2 data: using default as defined by configuration or DAQ";
91  }
92  } else {
94  iEvent.getByToken(gtDigi1Token_, handle1);
95  if (handle1.isValid()) {
97  // gtPrescaleFactorIndexTech() is also available
98  // by construction, they should always return the same index
100  } else {
101  edm::LogWarning("HLT")
102  << "Cannot read prescale column index from GT1 data: using default as defined by configuration or DAQ";
104  }
105  }
106 
107  if (prescaleSet_ != oldSet) {
108  edm::LogInfo("ChangedPrescale") << "lumiBlockNb = " << iEvent.getLuminosityBlock().id().luminosityBlock()
109  << ", set = " << prescaleSet_ << " [" << oldSet << "]"
110  << ", path = " << pathName << ": " << prescaleFactor_ << " [" << oldPrescale
111  << "]";
112  // reset the prescale counter
113  needsInit = true;
114  }
115  }
116 
117  if (needsInit && (prescaleFactor_ != 0)) {
118  // initialize the prescale counter to the first event number multiplied by a big "seed"
120  }
121  }
122 
123  const bool result((prescaleFactor_ == 0) ? false : ((eventCount_ + offsetCount_) % prescaleFactor_ == 0));
124 
125  ++eventCount_;
126  if (result)
127  ++acceptCount_;
128  return result;
129 }
const cms_uint16_t gtPrescaleFactorIndexAlgo() const
Definition: L1GtFdlWord.h:195
unsigned int getPrescale(std::string const &prescaledPath) const
edm::service::PrescaleService * prescaleService_
prescale service
Definition: HLTPrescaler.h:85
bool isEmpty(int bx) const
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
static const unsigned int prescaleSeed_
"seed" used to initialize the prescale counter
Definition: HLTPrescaler.h:96
const_iterator begin(int bx) const
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:78
int iEvent
Definition: GenABIO.cc:224
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:75
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:88
unsigned int prescaleSet_
l1 prescale set index
Definition: HLTPrescaler.h:69
edm::EDGetTokenT< GlobalAlgBlkBxCollection > gtDigi2Token_
Definition: HLTPrescaler.h:93
Log< level::Info, false > LogInfo
unsigned long long uint64_t
Definition: Time.h:13
unsigned int offsetPhase_
Definition: HLTPrescaler.h:82
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtDigi1Token_
Definition: HLTPrescaler.h:92
Log< level::Warning, false > LogWarning
unsigned int offsetCount_
initial offset
Definition: HLTPrescaler.h:81
unsigned int prescaleFactor_
accept one in prescaleFactor_; 0 means never to accept an event
Definition: HLTPrescaler.h:72

◆ globalEndJob()

void HLTPrescaler::globalEndJob ( const trigger::Efficiency efficiency)
static

Definition at line 141 of file HLTPrescaler.cc.

References accept(), L1TObjectsTimingClient_cff::efficiency, edmPickEvents::event, and SiStripPI::max.

141  {
142  unsigned int accept(efficiency->acceptCount_);
143  unsigned int event(efficiency->eventCount_);
144  edm::LogInfo("PrescaleSummary") << accept << "/" << event << " ("
145  << 100. * accept / static_cast<double>(std::max(1u, event))
146  << "% of events accepted).";
147  return;
148 }
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
Log< level::Info, false > LogInfo
Definition: event.py:1

◆ initializeGlobalCache()

static std::unique_ptr<trigger::Efficiency> HLTPrescaler::initializeGlobalCache ( edm::ParameterSet const &  )
inlinestatic

Definition at line 50 of file HLTPrescaler.h.

50  {
51  return std::make_unique<trigger::Efficiency>();
52  }

Member Data Documentation

◆ acceptCount_

unsigned int HLTPrescaler::acceptCount_
private

accept counter

Definition at line 78 of file HLTPrescaler.h.

Referenced by endStream(), and filter().

◆ eventCount_

unsigned int HLTPrescaler::eventCount_
private

event counter

Definition at line 75 of file HLTPrescaler.h.

Referenced by endStream(), and filter().

◆ gtDigi1Token_

edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> HLTPrescaler::gtDigi1Token_
private

Definition at line 92 of file HLTPrescaler.h.

Referenced by filter().

◆ gtDigi2Token_

edm::EDGetTokenT<GlobalAlgBlkBxCollection> HLTPrescaler::gtDigi2Token_
private

Definition at line 93 of file HLTPrescaler.h.

Referenced by filter().

◆ gtDigiTag_

edm::InputTag HLTPrescaler::gtDigiTag_
private

GT payload, to extract the prescale column index.

Definition at line 91 of file HLTPrescaler.h.

◆ newLumi_

bool HLTPrescaler::newLumi_
private

check for (re)initialization of the prescale

Definition at line 88 of file HLTPrescaler.h.

Referenced by beginLuminosityBlock(), and filter().

◆ offsetCount_

unsigned int HLTPrescaler::offsetCount_
private

initial offset

Definition at line 81 of file HLTPrescaler.h.

Referenced by filter().

◆ offsetPhase_

unsigned int HLTPrescaler::offsetPhase_
private

Definition at line 82 of file HLTPrescaler.h.

Referenced by filter().

◆ prescaleFactor_

unsigned int HLTPrescaler::prescaleFactor_
private

accept one in prescaleFactor_; 0 means never to accept an event

Definition at line 72 of file HLTPrescaler.h.

Referenced by filter().

◆ prescaleSeed_

const unsigned int HLTPrescaler::prescaleSeed_ = 65537
staticprivate

"seed" used to initialize the prescale counter

Definition at line 96 of file HLTPrescaler.h.

Referenced by filter().

◆ prescaleService_

edm::service::PrescaleService* HLTPrescaler::prescaleService_
private

prescale service

Definition at line 85 of file HLTPrescaler.h.

Referenced by filter(), and HLTPrescaler().

◆ prescaleSet_

unsigned int HLTPrescaler::prescaleSet_
private

l1 prescale set index

Definition at line 69 of file HLTPrescaler.h.

Referenced by filter().