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,
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;
45 };
46 
47 template <typename InputCollection, typename OutputCollection, typename P>
49  : srcToken_(edm::vector_transform(par.template getParameter<std::vector<edm::InputTag> >("src"),
50  [this](edm::InputTag const& tag) { return consumes<InputCollection>(tag); })) {
51  produces<OutputCollection>();
52 }
53 
54 template <typename InputCollection, typename OutputCollection, typename P>
56 
57 template <typename InputCollection, typename OutputCollection, typename P>
59  edm::Event& evt,
60  const edm::EventSetup&) const {
61  std::unique_ptr<OutputCollection> coll(new OutputCollection);
62  for (typename vtoken::const_iterator s = srcToken_.begin(); s != srcToken_.end(); ++s) {
64  evt.getByToken(*s, h);
65  for (typename InputCollection::const_iterator c = h->begin(); c != h->end(); ++c) {
66  coll->push_back(P::clone(*c));
67  }
68  }
69  evt.put(std::move(coll));
70 }
71 
72 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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:521
Definition: Merger.h:31
~Merger() override
destructor
Definition: Merger.h:55
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
def move(src, dest)
Definition: eostools.py:511
vtoken srcToken_
labels of the collections to be merged
Definition: Merger.h:44