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:
23 };
24 
26  : candSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("src"))},
27  vetoSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("veto"))},
28  useDeltaRforFootprint_(iConfig.getParameter<bool>("useDeltaRforFootprint")),
29  extendVetoBySingleSourcePtr_(iConfig.getParameter<bool>("extendVetoBySingleSourcePtr")) {
30  produces<edm::PtrVector<reco::Candidate>>();
31 }
32 
34  using namespace edm;
36  iEvent.getByToken(vetoSrcToken_, vetoes);
37 
38  auto result = std::make_unique<PtrVector<reco::Candidate>>();
39  std::set<reco::CandidatePtr> vetoedPtrs;
40  for (auto const& veto : *vetoes) {
41  auto const n = veto.numberOfSourceCandidatePtrs();
42  for (size_t j{}; j < n; ++j) {
43  vetoedPtrs.insert(veto.sourceCandidatePtr(j));
44  }
45  }
46 
48  iEvent.getByToken(candSrcToken_, cands);
49  for (size_t i{}; i < cands->size(); ++i) {
50  auto const c = cands->ptrAt(i);
51  if (vetoedPtrs.find(c) == vetoedPtrs.cend()) {
52  bool addcand = true;
53  if ((extendVetoBySingleSourcePtr_) && (c->numberOfSourceCandidatePtrs() == 1))
54  addcand = (vetoedPtrs.find(c->sourceCandidatePtr(0)) == vetoedPtrs.cend());
56  for (const auto& it : vetoedPtrs)
57  if (it.isNonnull() && it.isAvailable() && reco::deltaR2(*it, *c) < 0.00000025) {
58  addcand = false;
59  break;
60  }
61  if (addcand)
62  result->push_back(c);
63  }
64  }
65  iEvent.put(std::move(result));
66 }
67 
70  desc.add<edm::InputTag>("src");
71  desc.add<edm::InputTag>("veto");
72  desc.add<bool>("useDeltaRforFootprint", false);
73  desc.add<bool>("extendVetoBySingleSourcePtr", true);
74  descriptions.addWithDefaultLabel(desc);
75 }
76 
CandPtrProjector::CandPtrProjector
CandPtrProjector(edm::ParameterSet const &iConfig)
Definition: CandPtrProjector.cc:25
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:428
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:68
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.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:33
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15144
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.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:58
CandPtrProjector
Definition: CandPtrProjector.cc:12
InputTag.h
CandPtrProjector::vetoSrcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > vetoSrcToken_
Definition: CandPtrProjector.cc:20
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
CandPtrProjector::extendVetoBySingleSourcePtr_
bool extendVetoBySingleSourcePtr_
Definition: CandPtrProjector.cc:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
mps_fire.result
result
Definition: mps_fire.py:311
Candidate.h
ParameterSet.h
EDProducer.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
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