CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DuplicatedElectronCleaner.cc
Go to the documentation of this file.
1 //
2 // $Id: DuplicatedElectronCleaner.cc,v 1.5 2013/02/27 23:26:56 wmtan Exp $
3 //
4 
25 //#include "DataFormats/Common/interface/RefVector.h"
27 //#include "DataFormats/Common/interface/PtrVector.h"
28 
32 
33 namespace pat{
35  public:
36  explicit DuplicatedElectronCleaner(const edm::ParameterSet & iConfig);
38 
39  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
40  virtual void endJob();
41 
42  private:
46  };
47 } // namespace
48 
50  electronSrc_(iConfig.getParameter<edm::InputTag>("electronSource")),
51  try_(0), pass_(0)
52 {
53  //produces<edm::RefVector<reco::GsfElectronCollection> >();
54  produces<edm::RefToBaseVector<reco::GsfElectron> >();
55  //produces<edm::PtrVector<reco::GsfElectron> >();
56 }
57 
59 {
60 }
61 
62 void
64 {
65  using namespace edm;
67  iEvent.getByLabel(electronSrc_, electrons);
68  try_ += electrons->size();
69 
70  //std::auto_ptr<RefVector<reco::GsfElectronCollection> > result(new RefVector<reco::GsfElectronCollection>());
71  std::auto_ptr<RefToBaseVector<reco::GsfElectron> > result(new RefToBaseVector<reco::GsfElectron>());
72  //std::auto_ptr<PtrVector<reco::GsfElectron> > result(new PtrVector<reco::GsfElectron>());
73  std::auto_ptr< std::vector<size_t> > duplicates = duplicateRemover_.duplicatesToRemove(*electrons);
74 
75  std::vector<size_t>::const_iterator itdup = duplicates->begin(), enddup = duplicates->end();
76  for (size_t i = 0, n = electrons->size(); i < n; ++i) {
77  while ((itdup != enddup) && (*itdup < i)) { ++itdup; }
78  if ((itdup != enddup) && (*itdup == i)) continue;
79  //result->push_back(electrons->refAt(i).castTo<edm::Ref<reco::GsfElectronCollection> >());
80  result->push_back(electrons->refAt(i));
81  //result->push_back(electrons->ptrAt(i));
82  }
83  pass_ += result->size();
84  iEvent.put(result);
85 }
86 
87 void
89 {
90 }
91 
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Remove duplicates from the list of electrons.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
tuple result
Definition: query.py:137
pat::DuplicatedElectronRemover duplicateRemover_
DuplicatedElectronCleaner(const edm::ParameterSet &iConfig)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
unsigned long long uint64_t
Definition: Time.h:15