CMS 3D CMS Logo

CandPtrProjector.cc
Go to the documentation of this file.
11 
13 public:
14  explicit CandPtrProjector(edm::ParameterSet const& iConfig);
15  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
16  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
17 
18 private:
22 };
23 
25  : candSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("src"))},
26  vetoSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("veto"))},
27  useDeltaRforFootprint_(iConfig.getParameter<bool>("useDeltaRforFootprint")) {
28  produces<edm::PtrVector<reco::Candidate>>();
29 }
30 
32  using namespace edm;
34  iEvent.getByToken(vetoSrcToken_, vetoes);
35 
36  auto result = std::make_unique<PtrVector<reco::Candidate>>();
37  std::set<reco::CandidatePtr> vetoedPtrs;
38  for (auto const& veto : *vetoes) {
39  auto const n = veto.numberOfSourceCandidatePtrs();
40  for (size_t j{}; j < n; ++j) {
41  vetoedPtrs.insert(veto.sourceCandidatePtr(j));
42  }
43  }
44 
46  iEvent.getByToken(candSrcToken_, cands);
47  for (size_t i{}; i < cands->size(); ++i) {
48  auto const c = cands->ptrAt(i);
49  if (vetoedPtrs.find(c) == vetoedPtrs.cend()) {
50  bool addcand = true;
52  for (const auto& it : vetoedPtrs)
53  if (it.isNonnull() && it.isAvailable() && reco::deltaR2(*it, *c) < 0.00000025) {
54  addcand = false;
55  break;
56  }
57  if (addcand)
58  result->push_back(c);
59  }
60  }
61  iEvent.put(std::move(result));
62 }
63 
66  desc.add<edm::InputTag>("src");
67  desc.add<edm::InputTag>("veto");
68  desc.add<bool>("useDeltaRforFootprint", false);
69  descriptions.addWithDefaultLabel(desc);
70 }
71 
CandPtrProjector::CandPtrProjector
CandPtrProjector(edm::ParameterSet const &iConfig)
Definition: CandPtrProjector.cc:24
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CandPtrProjector::candSrcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > candSrcToken_
Definition: CandPtrProjector.cc:19
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
CandPtrProjector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CandPtrProjector.cc:64
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.h
deltaR.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PtrVector.h
RefToBaseVector.h
CandPtrProjector::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: CandPtrProjector.cc:31
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
CandPtrProjector
Definition: CandPtrProjector.cc:12
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CandPtrProjector::vetoSrcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > vetoSrcToken_
Definition: CandPtrProjector.cc:20
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
mps_fire.result
result
Definition: mps_fire.py:303
Candidate.h
ParameterSet.h
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
edm::InputTag
Definition: InputTag.h:15
CandPtrProjector::useDeltaRforFootprint_
bool useDeltaRforFootprint_
Definition: CandPtrProjector.cc:21
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87