CMS 3D CMS Logo

ShallowCloneProducer.h
Go to the documentation of this file.
1 #ifndef CandAlgos_ShallowCloneProducer_h
2 #define CandAlgos_ShallowCloneProducer_h
3 
21 
22 template <typename C>
24 public:
26  explicit ShallowCloneProducer(const edm::ParameterSet&);
28  ~ShallowCloneProducer() override;
29 
30 private:
32  void produce(edm::Event&, const edm::EventSetup&) override;
35 };
36 
37 template <typename C>
39  : srcToken_(consumes<C>(par.template getParameter<edm::InputTag>("src"))) {
40  produces<reco::CandidateCollection>();
41 }
42 
43 template <typename C>
45 
46 template <typename C>
48  std::unique_ptr<reco::CandidateCollection> coll(new reco::CandidateCollection);
49  edm::Handle<C> masterCollection;
50  evt.getByToken(srcToken_, masterCollection);
51  for (size_t i = 0; i < masterCollection->size(); ++i) {
52  reco::CandidateBaseRef masterClone(edm::Ref<C>(masterCollection, i));
53  coll->push_back(new reco::ShallowCloneCandidate(masterClone));
54  }
55  evt.put(std::move(coll));
56 }
57 
58 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
ShallowCloneProducer(const edm::ParameterSet &)
constructor from parameter set
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< C > srcToken_
labels of the collection to be converted
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
void produce(edm::Event &, const edm::EventSetup &) override
process an event
JetCorrectorParametersCollection coll
Definition: classes.h:10
HLT enums.
~ShallowCloneProducer() override
destructor
def move(src, dest)
Definition: eostools.py:511