CMS 3D CMS Logo

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

#include <HLTPathSelector.h>

Inheritance diagram for HLTPathSelector:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HLTPathSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob ()
 
bool filter (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

HLTConfigProvider hltConfig_
 
std::map< std::string, unsigned int > hltPathsMap_
 
const std::vector< std::string > hltPathsOfInterest_
 
std::string processName_
 
std::map< std::string, int > tmap_
 
edm::InputTag triggerEventTag_
 
const edm::EDGetTokenT< trigger::TriggerEventtriggerEventToken_
 
edm::InputTag triggerResultsTag_
 
const edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file HLTPathSelector.h.

Constructor & Destructor Documentation

◆ HLTPathSelector()

HLTPathSelector::HLTPathSelector ( const edm::ParameterSet ps)
explicit

Definition at line 11 of file HLTPathSelector.cc.

12  : verbose_(ps.getUntrackedParameter<bool>("verbose", false)),
13  processName_(ps.getParameter<std::string>("processName")),
14  hltPathsOfInterest_(ps.getParameter<std::vector<std::string> >("hltPathsOfInterest")),
16  ps.getUntrackedParameter<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "HLT"))),
18  ps.getUntrackedParameter<edm::InputTag>("triggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT"))),
19  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsTag_)),
20  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventTag_)) {}

Member Function Documentation

◆ beginRun()

void HLTPathSelector::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 21 of file HLTPathSelector.cc.

21  {
22  bool changed(true);
23  if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
24  if (changed) {
25  edm::LogInfo("HLTPathSelector") << "HLT initialised";
26  hltConfig_.dump("PrescaleTable");
27  }
28  hltPathsMap_.clear();
29  const unsigned int n(hltConfig_.size());
30  const std::vector<std::string>& pathList = hltConfig_.triggerNames();
31  for (auto path : pathList) {
32  if (!hltPathsOfInterest_.empty()) {
33  int nmatch = 0;
34  for (auto kt : hltPathsOfInterest_)
35  nmatch += TPRegexp(kt).Match(path);
36  if (!nmatch)
37  continue;
38  }
39  const unsigned int triggerIndex(hltConfig_.triggerIndex(path));
40  // abort on invalid trigger name
41  if (triggerIndex >= n) {
42  edm::LogError("HLTPathSelector") << "path: " << path << " - not found!";
43  continue;
44  }
45  hltPathsMap_[path] = triggerIndex;
46  }
47  } else
48  edm::LogError("HLTPathSelector") << " config extraction failure with process name " << processName_;
49 }

References HLTConfigProvider::dump(), hltConfig_, hltPathsMap_, hltPathsOfInterest_, HLTConfigProvider::init(), dqmiodumpmetadata::n, castor_dqm_sourceclient_file_cfg::path, processName_, HLTConfigProvider::size(), HLTConfigProvider::triggerIndex(), and HLTConfigProvider::triggerNames().

◆ endJob()

void HLTPathSelector::endJob ( void  )
private

Definition at line 93 of file HLTPathSelector.cc.

93  {
94  edm::LogInfo("HLTPathSelector") << setw(32) << "HLT Path" << setw(9) << "ACCEPT";
95  for (auto const& jt : tmap_)
96  edm::LogInfo("HLTPathSelector") << setw(9) << jt.second;
97 }

References tmap_.

◆ filter()

bool HLTPathSelector::filter ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 50 of file HLTPathSelector.cc.

50  {
51  // get event products
52  edm::Handle<edm::TriggerResults> triggerResultsHandle_;
53  iEvent.getByToken(triggerResultsToken_, triggerResultsHandle_);
54  if (!triggerResultsHandle_.isValid()) {
55  edm::LogError("HLTPathSelector") << "Error in getting TriggerResults product from Event!";
56  return false;
57  }
58 
59  edm::Handle<trigger::TriggerEvent> triggerEventHandle_;
60  iEvent.getByToken(triggerEventToken_, triggerEventHandle_);
61  if (!triggerEventHandle_.isValid()) {
62  edm::LogError("HLTPathSelector") << "Error in getting TriggerEvent product from Event!";
63  return false;
64  }
65  // sanity check
66  assert(triggerResultsHandle_->size() == hltConfig_.size());
67 
68  int flag = 0;
69  for (auto const& it : hltPathsMap_) {
70  const std::string path(it.first);
71  const unsigned int triggerIndex(it.second);
72  assert(triggerIndex == iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(path));
73 
74  // Results from TriggerResults product
75  if (verbose_)
76  edm::LogInfo("HLTPathSelector") << " Trigger path <" << path << "> status:"
77  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
78  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
79  << " Error=" << triggerResultsHandle_->error(triggerIndex);
80 
81  if (triggerResultsHandle_->wasrun(triggerIndex) && triggerResultsHandle_->accept(triggerIndex)) {
82  ++flag;
83  if (tmap_.find(path) == tmap_.end())
84  tmap_[path] = 1;
85  else
86  tmap_[path]++;
87  }
88  }
89  if (flag > 0)
90  return true;
91  return false;
92 }

References edm::HLTGlobalStatus::accept(), cms::cuda::assert(), edm::HLTGlobalStatus::error(), RemoveAddSevLevel::flag, hltConfig_, hltPathsMap_, iEvent, edm::HandleBase::isValid(), castor_dqm_sourceclient_file_cfg::path, edm::HLTGlobalStatus::size(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, tmap_, triggerEventToken_, triggerResultsToken_, verbose_, and edm::HLTGlobalStatus::wasrun().

Member Data Documentation

◆ hltConfig_

HLTConfigProvider HLTPathSelector::hltConfig_
private

Definition at line 35 of file HLTPathSelector.h.

Referenced by beginRun(), and filter().

◆ hltPathsMap_

std::map<std::string, unsigned int> HLTPathSelector::hltPathsMap_
private

Definition at line 37 of file HLTPathSelector.h.

Referenced by beginRun(), and filter().

◆ hltPathsOfInterest_

const std::vector<std::string> HLTPathSelector::hltPathsOfInterest_
private

Definition at line 29 of file HLTPathSelector.h.

Referenced by beginRun().

◆ processName_

std::string HLTPathSelector::processName_
private

Definition at line 28 of file HLTPathSelector.h.

Referenced by beginRun().

◆ tmap_

std::map<std::string, int> HLTPathSelector::tmap_
private

Definition at line 38 of file HLTPathSelector.h.

Referenced by endJob(), and filter().

◆ triggerEventTag_

edm::InputTag HLTPathSelector::triggerEventTag_
private

Definition at line 31 of file HLTPathSelector.h.

◆ triggerEventToken_

const edm::EDGetTokenT<trigger::TriggerEvent> HLTPathSelector::triggerEventToken_
private

Definition at line 33 of file HLTPathSelector.h.

Referenced by filter().

◆ triggerResultsTag_

edm::InputTag HLTPathSelector::triggerResultsTag_
private

Definition at line 30 of file HLTPathSelector.h.

◆ triggerResultsToken_

const edm::EDGetTokenT<edm::TriggerResults> HLTPathSelector::triggerResultsToken_
private

Definition at line 32 of file HLTPathSelector.h.

Referenced by filter().

◆ verbose_

bool HLTPathSelector::verbose_
private

Definition at line 27 of file HLTPathSelector.h.

Referenced by filter().

HLTPathSelector::triggerEventToken_
const edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: HLTPathSelector.h:33
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HLTPathSelector::triggerResultsToken_
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: HLTPathSelector.h:32
HLTPathSelector::verbose_
bool verbose_
Definition: HLTPathSelector.h:27
edm::LogInfo
Definition: MessageLogger.h:254
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
cms::cuda::assert
assert(be >=bs)
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HLTConfigProvider::dump
void dump(const std::string &what) const
Dumping config info to cout.
Definition: HLTConfigProvider.h:43
HLTPathSelector::processName_
std::string processName_
Definition: HLTPathSelector.h:28
edm::Handle< edm::TriggerResults >
HLTPathSelector::hltPathsOfInterest_
const std::vector< std::string > hltPathsOfInterest_
Definition: HLTPathSelector.h:29
edm::HLTGlobalStatus::size
unsigned int size() const
Get number of paths stored.
Definition: HLTGlobalStatus.h:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTConfigProvider::size
unsigned int size() const
number of trigger paths in trigger table
Definition: HLTConfigProvider.h:62
HLTPathSelector::triggerResultsTag_
edm::InputTag triggerResultsTag_
Definition: HLTPathSelector.h:30
edm::LogError
Definition: MessageLogger.h:183
HLTPathSelector::hltPathsMap_
std::map< std::string, unsigned int > hltPathsMap_
Definition: HLTPathSelector.h:37
iEvent
int iEvent
Definition: GenABIO.cc:224
HLTConfigProvider::triggerIndex
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Definition: HLTConfigProvider.h:72
HLTPathSelector::triggerEventTag_
edm::InputTag triggerEventTag_
Definition: HLTPathSelector.h:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
HLTConfigProvider::triggerNames
const std::vector< std::string > & triggerNames() const
names of trigger paths
Definition: HLTConfigProvider.h:68
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HLTPathSelector::hltConfig_
HLTConfigProvider hltConfig_
Definition: HLTPathSelector.h:35
HLTPathSelector::tmap_
std::map< std::string, int > tmap_
Definition: HLTPathSelector.h:38
edm::InputTag
Definition: InputTag.h:15
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116