CMS 3D CMS Logo

Merger.h
Go to the documentation of this file.
1 #ifndef UtilAlgos_Merger_h
2 #define UtilAlgos_Merger_h
3 
28 #include <vector>
29 
30 template <typename InputCollection,
33 class Merger : public edm::global::EDProducer<> {
34 public:
36  explicit Merger(const edm::ParameterSet&);
38  ~Merger() override;
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
43  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
45  typedef std::vector<edm::EDGetTokenT<InputCollection>> vtoken;
48 };
49 
50 template <typename InputCollection, typename OutputCollection, typename P>
52  : srcToken_(edm::vector_transform(par.template getParameter<std::vector<edm::InputTag>>("src"),
53  [this](edm::InputTag const& tag) { return consumes<InputCollection>(tag); })) {
54  produces<OutputCollection>();
55 }
56 
57 template <typename InputCollection, typename OutputCollection, typename P>
59 
60 template <typename InputCollection, typename OutputCollection, typename P>
62  edm::Event& evt,
63  const edm::EventSetup&) const {
64  std::unique_ptr<OutputCollection> coll(new OutputCollection);
65  for (typename vtoken::const_iterator s = srcToken_.begin(); s != srcToken_.end(); ++s) {
67  evt.getByToken(*s, h);
68  for (typename InputCollection::const_iterator c = h->begin(); c != h->end(); ++c) {
69  coll->push_back(P::clone(*c));
70  }
71  }
72  evt.put(std::move(coll));
73 }
74 
75 template <typename InputCollection, typename OutputCollection, typename P>
78  desc.add<std::vector<edm::InputTag>>("src",
79  {
80  edm::InputTag("collection1"),
81  edm::InputTag("collection2"),
82  });
83  descriptions.addWithDefaultLabel(desc);
84 }
85 
86 #endif
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
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:526
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:45
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
process an event
Definition: Merger.h:61
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
Definition: Merger.h:33
~Merger() override
destructor
Definition: Merger.h:58
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:51
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Merger.h:76
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:47