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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
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)
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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::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 16 of file HLTPathSelector.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file HLTPathSelector.cc.

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

Member Function Documentation

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.

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

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) continue;
37  }
38  const unsigned int triggerIndex(hltConfig_.triggerIndex(path));
39  // abort on invalid trigger name
40  if (triggerIndex >= n) {
41  edm::LogError("HLTPathSelector") << "path: " << path << " - not found!";
42  continue;
43  }
44  hltPathsMap_[path] = triggerIndex;
45  }
46  }
47  else
48  edm::LogError("HLTPathSelector")
49  << " config extraction failure with process name "
50  << processName_;
51 }
unsigned int size() const
number of trigger paths in trigger table
void dump(const std::string &what) const
Dumping config info to cout.
HLTConfigProvider hltConfig_
std::map< std::string, unsigned int > hltPathsMap_
const std::vector< std::string > & triggerNames() const
names of trigger paths
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
const std::vector< std::string > hltPathsOfInterest_
std::string processName_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void HLTPathSelector::endJob ( void  )
private

Definition at line 95 of file HLTPathSelector.cc.

References DEFINE_FWK_MODULE, and tmap_.

95  {
96 
97  edm::LogInfo("HLTPathSelector")
98  << setw(32) << "HLT Path"
99  << setw(9) << "ACCEPT";
100  for (auto const& jt: tmap_)
101  edm::LogInfo("HLTPathSelector")
102  << setw(9) << jt.second;
103 }
std::map< std::string, int > tmap_
bool HLTPathSelector::filter ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 52 of file HLTPathSelector.cc.

References edm::HLTGlobalStatus::accept(), edm::HLTGlobalStatus::error(), RemoveAddSevLevel::flag, edm::Event::getByToken(), hltConfig_, hltPathsMap_, edm::HandleBase::isValid(), callgraph::path, edm::HLTGlobalStatus::size(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, tmap_, triggerEventToken_, edm::TriggerNames::triggerIndex(), edm::Event::triggerNames(), triggerResultsToken_, verbose_, and edm::HLTGlobalStatus::wasrun().

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

52  {
53  // get event products
54  edm::Handle<edm::TriggerResults> triggerResultsHandle_;
55  iEvent.getByToken(triggerResultsToken_, triggerResultsHandle_);
56  if (!triggerResultsHandle_.isValid()) {
57  edm::LogError("HLTPathSelector") << "Error in getting TriggerResults product from Event!";
58  return false;
59  }
60 
61  edm::Handle<trigger::TriggerEvent> triggerEventHandle_;
62  iEvent.getByToken(triggerEventToken_, triggerEventHandle_);
63  if (!triggerEventHandle_.isValid()) {
64  edm::LogError("HLTPathSelector") << "Error in getting TriggerEvent product from Event!";
65  return false;
66  }
67  // sanity check
68  assert(triggerResultsHandle_->size() == hltConfig_.size());
69 
70  int flag = 0;
71  for (auto const& it: hltPathsMap_) {
72  const std::string path(it.first);
73  const unsigned int triggerIndex(it.second);
74  assert(triggerIndex == iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(path));
75 
76  // Results from TriggerResults product
77  if (verbose_)
78  edm::LogInfo("HLTPathSelector")
79  << " Trigger path <" << path << "> status:"
80  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
81  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
82  << " Error=" << triggerResultsHandle_->error(triggerIndex);
83 
84  if (triggerResultsHandle_->wasrun(triggerIndex) && triggerResultsHandle_->accept(triggerIndex)) {
85  ++flag;
86  if (tmap_.find(path) == tmap_.end())
87  tmap_[path] = 1;
88  else
89  tmap_[path]++;
90  }
91  }
92  if (flag > 0) return true;
93  return false;
94 }
unsigned int size() const
number of trigger paths in trigger table
bool wasrun() const
Was at least one path run?
HLTConfigProvider hltConfig_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::map< std::string, unsigned int > hltPathsMap_
bool accept() const
Has at least one path accepted the event?
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
unsigned int size() const
Get number of paths stored.
bool error() const
Has any path encountered an error (exception)
bool isValid() const
Definition: HandleBase.h:74
std::map< std::string, int > tmap_
const edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301

Member Data Documentation

HLTConfigProvider HLTPathSelector::hltConfig_
private

Definition at line 36 of file HLTPathSelector.h.

Referenced by beginRun(), and filter().

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

Definition at line 38 of file HLTPathSelector.h.

Referenced by beginRun(), and filter().

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

Definition at line 30 of file HLTPathSelector.h.

Referenced by beginRun().

std::string HLTPathSelector::processName_
private

Definition at line 29 of file HLTPathSelector.h.

Referenced by beginRun().

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

Definition at line 39 of file HLTPathSelector.h.

Referenced by endJob(), and filter().

edm::InputTag HLTPathSelector::triggerEventTag_
private

Definition at line 32 of file HLTPathSelector.h.

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

Definition at line 34 of file HLTPathSelector.h.

Referenced by filter().

edm::InputTag HLTPathSelector::triggerResultsTag_
private

Definition at line 31 of file HLTPathSelector.h.

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

Definition at line 33 of file HLTPathSelector.h.

Referenced by filter().

bool HLTPathSelector::verbose_
private

Definition at line 28 of file HLTPathSelector.h.

Referenced by filter().