#include <GetterOfProducts.h>
Public Member Functions | |
edm::BranchType | branchType () const |
void | fillHandles (edm::Event const &event, std::vector< edm::Handle< T >> &handles) const |
void | fillHandles (edm::LuminosityBlock const &lumi, std::vector< edm::Handle< T >> &handles) const |
void | fillHandles (edm::Run const &run, std::vector< edm::Handle< T >> &handles) const |
GetterOfProducts () | |
template<typename U , typename M > | |
GetterOfProducts (U const &match, M *module, edm::BranchType branchType=edm::InEvent) | |
void | operator() (edm::BranchDescription const &branchDescription) |
std::vector< edm::EDGetTokenT< T > > const & | tokens () const |
Private Attributes | |
edm::BranchType | branchType_ |
std::function< EDGetTokenT< T >BranchDescription const &)> | matcher_ |
std::shared_ptr< std::vector< edm::EDGetTokenT< T > > > | tokens_ |
Intended to be used by EDProducers, EDFilters, and EDAnalyzers to get products from the Event, Run or LuminosityBlock. In most cases, the preferred method to get products is not to use this class. In most cases the preferred method is to use the function getByLabel with an InputTag that is configurable. But occasionally getByLabel will not work because one wants to select the product based on the data that is available in the event and not have to modify the configuration as the data content changes. A real example would be a module that collects HLT trigger information from products written by the many HLT filters. The number and labels of those products vary so much that it would not be reasonable to modify the configuration to get all of them each time a different HLT trigger table was used. This class handles that and similar cases.
This class is preferred over using getManyByType where it is possible to use it.
This method can select by type and branch type. There exists a predicate (in ProcessMatch.h) to also select on process name. It is possible to write other predicates which will select on anything in the BranchDescription. The selection is done during the initialization of the process. During this initialization a list of InputTags is filled with all matching products from the ProductRegistry. This list of InputTags is accessible to the module. In the future there are plans for modules to register the products they might get to the Framework which will allow it to optimize performance for parallel processing among other things.
The fillHandles functions will get a handle for each product on the list of InputTags that is actually present in the current Event, LuminosityBlock, or Run. Internally, this function uses getByLabel and benefits from performance optimizations of getByLabel.
Typically one would use this as follows:
Add these headers:
include "FWCore/Framework/interface/GetterOfProducts.h" include "FWCore/Framework/interface/ProcessMatch.h"
Add this data member:
edm::GetterOfProducts<YourDataType> getterOfProducts_;
Add these to the constructor (1st line is usually in the data member initializer list and the 2nd line in the body of the constructor)
getterOfProducts_(edm::ProcessMatch(processName_), this) { callWhenNewProductsRegistered(getterOfProducts_);
Add this to the method called for each event:
std::vector<edm::Handle<YourDataType> > handles; getterOfProducts_.fillHandles(event, handles);
And that is all you need in most cases. In the above example, "YourDataType" is the type of the product you want to get. There are some variants for special cases
Use an extra argument to the constructor for products in the Run or LuminosityBlock.
getterOfProducts_ = edm::GetterOfProducts<Thing>(edm::ProcessMatch(processName_), this, edm::InRun);
You can use multiple GetterOfProducts's in the same module. The only tricky part is to use a lambda as follows to register the callbacks:
callWhenNewProductsRegistered([this](edm::BranchDescription const& bd) { getterOfProducts1_(bd); getterOfProducts2_(bd); });
Definition at line 121 of file GetterOfProducts.h.
|
inline |
Definition at line 123 of file GetterOfProducts.h.
|
inline |
Definition at line 126 of file GetterOfProducts.h.
|
inline |
Definition at line 181 of file GetterOfProducts.h.
|
inline |
Definition at line 143 of file GetterOfProducts.h.
Referenced by TriggerSummaryProducerAOD::fillTriggerObjectCollections(), TriggerSummaryProducerRAW::produce(), and TriggerSummaryProducerAOD::produce().
|
inline |
Definition at line 156 of file GetterOfProducts.h.
|
inline |
Definition at line 168 of file GetterOfProducts.h.
|
inline |
Definition at line 131 of file GetterOfProducts.h.
|
inline |
Definition at line 180 of file GetterOfProducts.h.
|
private |
|
private |
Definition at line 184 of file GetterOfProducts.h.
Referenced by edm::GetterOfProducts< trigger::HLTPrescaleTable >::operator()().
|
private |
Definition at line 187 of file GetterOfProducts.h.
Referenced by edm::GetterOfProducts< trigger::HLTPrescaleTable >::fillHandles(), edm::GetterOfProducts< trigger::HLTPrescaleTable >::operator()(), and edm::GetterOfProducts< trigger::HLTPrescaleTable >::tokens().