CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CollectionCombiner< Collection > Class Template Reference

#include <CollectionCombiner.h>

Inheritance diagram for CollectionCombiner< Collection >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 CollectionCombiner (const edm::ParameterSet &)
 ~CollectionCombiner ()

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

std::vector< edm::InputTaglabels

Detailed Description

template<typename Collection>
class CollectionCombiner< Collection >

Description: this templated EDProducer can merge (no duplicate removal) any number of collection of the same type. the usage is to declare a concrete combiner in SealModule: typedef CollectionCombiner<std::vector< Trajectory> > TrajectoryCombiner; DEFINE_FWK_MODULE(TrajectoryCombiner); edm::View cannot be used, because the template argument is used for the input and the output type.

Author:
Jean-Roch Vlimant

Definition at line 29 of file CollectionCombiner.h.


Constructor & Destructor Documentation

template<typename Collection >
CollectionCombiner< Collection >::CollectionCombiner ( const edm::ParameterSet iConfig) [explicit]

Definition at line 42 of file CollectionCombiner.h.

References edm::ParameterSet::getParameter(), and reco_calib_source_client_cfg::labels.

                                                                                {
  labels = iConfig.getParameter<std::vector<edm::InputTag> >("labels");
  produces<Collection>();
}
template<typename Collection >
CollectionCombiner< Collection >::~CollectionCombiner ( )

Definition at line 47 of file CollectionCombiner.h.

{}

Member Function Documentation

template<typename Collection >
void CollectionCombiner< Collection >::produce ( edm::Event iEvent,
const edm::EventSetup es 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 50 of file CollectionCombiner.h.

References edm::Event::getByLabel(), patZpeak::handle, i, reco_calib_source_client_cfg::labels, and edm::Event::put().

{
  unsigned int i=0,i_max=labels.size();
  edm::Handle<Collection> handle;
  std::auto_ptr<Collection> merged(new Collection());
  for (;i!=i_max;++i){
    iEvent.getByLabel(labels[i], handle);
    merged->insert(merged->end(), handle->begin(), handle->end());
  }
  iEvent.put(merged);
}

Member Data Documentation

template<typename Collection >
std::vector<edm::InputTag> CollectionCombiner< Collection >::labels [private]

Definition at line 38 of file CollectionCombiner.h.