CMS 3D CMS Logo

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::global::EDProducer<> {
32 public:
34  explicit Merger( const edm::ParameterSet& );
36  ~Merger() override;
37 
38 private:
40  void produce( edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
42  typedef std::vector<edm::EDGetTokenT<InputCollection> > vtoken;
44  vtoken srcToken_;
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::unique_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(std::move(coll));
68 }
69 
70 #endif
71 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
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
std::vector< edm::EDGetTokenT< InputCollection > > vtoken
vector of strings
Definition: Merger.h:42
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
process an event
Definition: Merger.h:58
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
Definition: Merger.h:31
JetCorrectorParametersCollection coll
Definition: classes.h:10
~Merger() override
destructor
Definition: Merger.h:54
std::pair< OmniClusterRef, TrackingParticleRef > P
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
HLT enums.
Merger(const edm::ParameterSet &)
constructor from parameter set
Definition: Merger.h:48
def move(src, dest)
Definition: eostools.py:511
vtoken srcToken_
labels of the collections to be merged
Definition: Merger.h:44