CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
UniqueMerger< InputCollection, OutputCollection, P > Class Template Reference

#include <UniqueMerger.h>

Inheritance diagram for UniqueMerger< InputCollection, OutputCollection, P >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::set< typename OutputCollection::value_type > set_type
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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
 

Public Member Functions

 UniqueMerger (const edm::ParameterSet &)
 constructor from parameter set More...
 
 ~UniqueMerger () override
 destructor More...
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
std::vector< ESProxyIndex > 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
 
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 Types

typedef std::vector< edm::EDGetTokenT< InputCollection > > vtoken
 vector of strings More...
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 process an event More...
 

Private Attributes

bool skipNulls_
 choose whether to skip null/invalid pointers More...
 
vtoken srcToken_
 labels of the collections to be merged More...
 
bool warnOnSkip_
 choose whether to warn when skipping pointers More...
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::global::EDProducerBase
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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

template<typename InputCollection, typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
class UniqueMerger< InputCollection, OutputCollection, P >

Merges an arbitrary number of collections into a single collection, without duplicates. Based on logic from Merger.h. This class template differs from Merger.h in that it uses a set instead of std::vector. This requires the OutputCollection type to be sortable, which allows us to search for elements downstream efficiently.

Template parameters:

Author
Lauren Hay
Version
Revision
1.2

Definition at line 35 of file UniqueMerger.h.

Member Typedef Documentation

◆ set_type

template<typename InputCollection , typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
typedef std::set<typename OutputCollection::value_type> UniqueMerger< InputCollection, OutputCollection, P >::set_type

Definition at line 37 of file UniqueMerger.h.

◆ vtoken

template<typename InputCollection , typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
typedef std::vector<edm::EDGetTokenT<InputCollection> > UniqueMerger< InputCollection, OutputCollection, P >::vtoken
private

vector of strings

Definition at line 47 of file UniqueMerger.h.

Constructor & Destructor Documentation

◆ UniqueMerger()

template<typename InputCollection , typename OutputCollection , typename P >
UniqueMerger< InputCollection, OutputCollection, P >::UniqueMerger ( const edm::ParameterSet par)
explicit

constructor from parameter set

Definition at line 57 of file UniqueMerger.h.

58  : srcToken_(edm::vector_transform(par.template getParameter<std::vector<edm::InputTag> >("src"),
59  [this](edm::InputTag const& tag) { return consumes<InputCollection>(tag); })),
60  skipNulls_(par.getParameter<bool>("skipNulls")),
61  warnOnSkip_(par.getParameter<bool>("warnOnSkip")) {
62  produces<OutputCollection>();
63 }

References GlobalPosition_Frontier_DevDB_cff::tag.

◆ ~UniqueMerger()

template<typename InputCollection , typename OutputCollection , typename P >
UniqueMerger< InputCollection, OutputCollection, P >::~UniqueMerger ( )
override

destructor

Definition at line 66 of file UniqueMerger.h.

66 {}

Member Function Documentation

◆ produce()

template<typename InputCollection , typename OutputCollection , typename P >
void UniqueMerger< InputCollection, OutputCollection, P >::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup  
) const
overrideprivatevirtual

process an event

Implements edm::global::EDProducerBase.

Definition at line 69 of file UniqueMerger.h.

71  {
72  set_type coll_set;
73  for (auto const& s : srcToken_) {
74  for (auto const& c : evt.get(s)) {
75  if (!skipNulls_ || (c.isNonnull() && c.isAvailable())) {
76  coll_set.emplace(P::clone(c));
77  } else if (warnOnSkip_) {
78  edm::LogWarning("InvalidPointer") << "Found an invalid pointer. Will not merge to collection.";
79  }
80  }
81  }
82  std::unique_ptr<OutputCollection> coll(new OutputCollection(coll_set.size()));
83  std::copy(coll_set.begin(), coll_set.end(), coll->begin());
84  evt.put(std::move(coll));
85 }

References c, clone(), filterCSVwithJSON::copy, edm::Event::get(), eostools::move(), HLTTauReferences_cfi::OutputCollection, edm::Event::put(), and alignCSCRings::s.

Member Data Documentation

◆ skipNulls_

template<typename InputCollection , typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
bool UniqueMerger< InputCollection, OutputCollection, P >::skipNulls_
private

choose whether to skip null/invalid pointers

Definition at line 51 of file UniqueMerger.h.

◆ srcToken_

template<typename InputCollection , typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
vtoken UniqueMerger< InputCollection, OutputCollection, P >::srcToken_
private

labels of the collections to be merged

Definition at line 49 of file UniqueMerger.h.

◆ warnOnSkip_

template<typename InputCollection , typename OutputCollection = InputCollection, typename P = typename edm::clonehelper::CloneTrait<InputCollection>::type>
bool UniqueMerger< InputCollection, OutputCollection, P >::warnOnSkip_
private

choose whether to warn when skipping pointers

Definition at line 53 of file UniqueMerger.h.

filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
alignCSCRings.s
s
Definition: alignCSCRings.py:92
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
UniqueMerger::srcToken_
vtoken srcToken_
labels of the collections to be merged
Definition: UniqueMerger.h:49
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
UniqueMerger::skipNulls_
bool skipNulls_
choose whether to skip null/invalid pointers
Definition: UniqueMerger.h:51
UniqueMerger::set_type
std::set< typename OutputCollection::value_type > set_type
Definition: UniqueMerger.h:37
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
HLTTauReferences_cfi.OutputCollection
OutputCollection
Definition: HLTTauReferences_cfi.py:92
edm::Event::get
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:342
edm::InputTag
Definition: InputTag.h:15
UniqueMerger::warnOnSkip_
bool warnOnSkip_
choose whether to warn when skipping pointers
Definition: UniqueMerger.h:53