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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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
 
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
 
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)
 
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::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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

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

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.

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

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.

References UniqueMerger< InputCollection, OutputCollection, P >::skipNulls_, GlobalPosition_Frontier_DevDB_cff::tag, and UniqueMerger< InputCollection, OutputCollection, P >::warnOnSkip_.

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 }
T getParameter(std::string const &) const
bool skipNulls_
choose whether to skip null/invalid pointers
Definition: UniqueMerger.h:51
bool warnOnSkip_
choose whether to warn when skipping pointers
Definition: UniqueMerger.h:53
vtoken srcToken_
labels of the collections to be merged
Definition: UniqueMerger.h:49
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
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

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

process an event

Definition at line 69 of file UniqueMerger.h.

References EnergyCorrector::c, clone(), coll, popcon2dropbox::copy(), edm::Event::get(), eostools::move(), edm::Event::put(), alignCSCRings::s, UniqueMerger< InputCollection, OutputCollection, P >::skipNulls_, UniqueMerger< InputCollection, OutputCollection, P >::srcToken_, and UniqueMerger< InputCollection, OutputCollection, P >::warnOnSkip_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
def copy(args, dbName)
bool skipNulls_
choose whether to skip null/invalid pointers
Definition: UniqueMerger.h:51
bool warnOnSkip_
choose whether to warn when skipping pointers
Definition: UniqueMerger.h:53
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
vtoken srcToken_
labels of the collections to be merged
Definition: UniqueMerger.h:49
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::set< typename OutputCollection::value_type > set_type
Definition: UniqueMerger.h:37
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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.

Referenced by UniqueMerger< InputCollection, OutputCollection, P >::produce(), and UniqueMerger< InputCollection, OutputCollection, P >::UniqueMerger().

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.

Referenced by UniqueMerger< InputCollection, OutputCollection, P >::produce().

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.

Referenced by UniqueMerger< InputCollection, OutputCollection, P >::produce(), and UniqueMerger< InputCollection, OutputCollection, P >::UniqueMerger().