CMS 3D CMS Logo

DuplicatedElectronCleaner.cc
Go to the documentation of this file.
1 //
2 //
3 
24 //#include "DataFormats/Common/interface/RefVector.h"
26 //#include "DataFormats/Common/interface/PtrVector.h"
27 
31 
32 namespace pat {
34  public:
35  explicit DuplicatedElectronCleaner(const edm::ParameterSet& iConfig);
36  ~DuplicatedElectronCleaner() override;
37 
38  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const final;
39 
40  private:
43  mutable std::atomic<uint64_t> try_, pass_;
44  };
45 } // namespace pat
46 
48  : electronSrcToken_(consumes<edm::View<reco::GsfElectron>>(iConfig.getParameter<edm::InputTag>("electronSource"))),
49  duplicateRemover_(),
50  try_(0),
51  pass_(0) {
52  //produces<edm::RefVector<reco::GsfElectronCollection> >();
53  produces<edm::RefToBaseVector<reco::GsfElectron>>();
54  //produces<edm::PtrVector<reco::GsfElectron> >();
55 }
56 
58 
60  using namespace edm;
62  iEvent.getByToken(electronSrcToken_, electrons);
63  try_ += electrons->size();
64 
65  //auto result = std::make_unique<RefVector<reco::GsfElectronCollection>>();
66  auto result = std::make_unique<RefToBaseVector<reco::GsfElectron>>();
67  //auto result = std::make_unique<PtrVector<reco::GsfElectron>>();
68  std::unique_ptr<std::vector<size_t>> duplicates = duplicateRemover_.duplicatesToRemove(*electrons);
69 
70  std::vector<size_t>::const_iterator itdup = duplicates->begin(), enddup = duplicates->end();
71  for (size_t i = 0, n = electrons->size(); i < n; ++i) {
72  while ((itdup != enddup) && (*itdup < i)) {
73  ++itdup;
74  }
75  if ((itdup != enddup) && (*itdup == i))
76  continue;
77  //result->push_back(electrons->refAt(i).castTo<edm::Ref<reco::GsfElectronCollection> >());
78  result->push_back(electrons->refAt(i));
79  //result->push_back(electrons->ptrAt(i));
80  }
81  pass_ += result->size();
82  iEvent.put(std::move(result));
83 }
84 
pat::DuplicatedElectronCleaner::pass_
std::atomic< uint64_t > pass_
Definition: DuplicatedElectronCleaner.cc:43
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
sistrip::View
View
Definition: ConstantsForView.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::DuplicatedElectronCleaner::electronSrcToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronSrcToken_
Definition: DuplicatedElectronCleaner.cc:41
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pat::DuplicatedElectronRemover
Definition: DuplicatedElectronRemover.h:21
pat::DuplicatedElectronCleaner::try_
std::atomic< uint64_t > try_
Definition: DuplicatedElectronCleaner.cc:43
RefToBaseVector.h
GsfElectron.h
edm::global::EDProducer
Definition: EDProducer.h:32
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
pat::DuplicatedElectronCleaner::DuplicatedElectronCleaner
DuplicatedElectronCleaner(const edm::ParameterSet &iConfig)
Definition: DuplicatedElectronCleaner.cc:47
Event.h
DuplicatedElectronRemover.h
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::DuplicatedElectronCleaner::duplicateRemover_
const pat::DuplicatedElectronRemover duplicateRemover_
Definition: DuplicatedElectronCleaner.cc:42
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
InputTag.h
pat::DuplicatedElectronCleaner
Remove duplicates from the list of electrons.
Definition: DuplicatedElectronCleaner.cc:33
pat::DuplicatedElectronCleaner::produce
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const final
Definition: DuplicatedElectronCleaner.cc:59
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
pat::DuplicatedElectronCleaner::~DuplicatedElectronCleaner
~DuplicatedElectronCleaner() override
Definition: DuplicatedElectronCleaner.cc:57
mps_fire.result
result
Definition: mps_fire.py:311
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73