CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Merger.h
Go to the documentation of this file.
1 #ifndef UtilAlgos_Merger_h
2 #define UtilAlgos_Merger_h
3 
26 #include <vector>
27 
28 template<typename InputCollection,
29  typename OutputCollection = InputCollection,
31 class Merger : public edm::EDProducer {
32 public:
34  explicit Merger( const edm::ParameterSet& );
36  ~Merger();
37 
38 private:
40  virtual void produce( edm::Event&, const edm::EventSetup&) override;
42  typedef std::vector<edm::EDGetTokenT<InputCollection> > vtoken;
45 };
46 
47 template<typename InputCollection, typename OutputCollection, typename P>
49  srcToken_( edm::vector_transform(par.template getParameter<std::vector<edm::InputTag> >( "src" ), [this](edm::InputTag const & tag){return consumes<InputCollection>(tag);} ) ) {
50  produces<OutputCollection>();
51 }
52 
53 template<typename InputCollection, typename OutputCollection, typename P>
55 }
56 
57 template<typename InputCollection, typename OutputCollection, typename P>
59  std::auto_ptr<OutputCollection> coll( new OutputCollection );
60  for( typename vtoken::const_iterator s = srcToken_.begin(); s != srcToken_.end(); ++ s ) {
62  evt.getByToken( * s, h );
63  for( typename InputCollection::const_iterator c = h->begin(); c != h->end(); ++c ) {
64  coll->push_back( P::clone( * c ) );
65  }
66  }
67  evt.put( coll );
68 }
69 
70 #endif
71 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define P
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
~Merger()
destructor
Definition: Merger.h:54
std::vector< edm::EDGetTokenT< InputCollection > > vtoken
vector of strings
Definition: Merger.h:42
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Definition: Merger.h:31
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual void produce(edm::Event &, const edm::EventSetup &) override
process an event
Definition: Merger.h:58
string const
Definition: compareJSON.py:14
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
Merger(const edm::ParameterSet &)
constructor from parameter set
Definition: Merger.h:48
vtoken srcToken_
labels of the collections to be merged
Definition: Merger.h:44
def template
Definition: svgfig.py:520