CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFCandWithSuperClusterExtractor.cc
Go to the documentation of this file.
2 
8 
9 using namespace edm;
10 using namespace reco;
11 
13  : thePFCandToken(iC.consumes<PFCandidateCollection>(par.getParameter<edm::InputTag>("inputCandView"))),
14  theDepositLabel(par.getUntrackedParameter<std::string>("DepositLabel")),
15  theVetoSuperClusterMatch(par.getParameter<bool>("SCMatch_Veto")),
16  theMissHitVetoSuperClusterMatch(par.getParameter<bool>("MissHitSCMatch_Veto")),
17  theDiff_r(par.getParameter<double>("Diff_r")),
18  theDiff_z(par.getParameter<double>("Diff_z")),
19  theDR_Max(par.getParameter<double>("DR_Max")),
20  theDR_Veto(par.getParameter<double>("DR_Veto")) {
21  // std::cout << " Loading PFCandWithSuperClusterExtractor " << std::endl;
22 }
23 /*
24 reco::IsoDeposit::Vetos PFCandWithSuperClusterExtractor::vetos(const edm::Event & ev,
25  const edm::EventSetup & evSetup, const reco::Candidate & cand) const
26 {
27  reco::isodeposit::Direction dir(cand.eta(),cand.phi());
28  return reco::IsoDeposit::Vetos(1,veto(dir));
29 }
30 */
31 
34  result.vetoDir = dir;
35  result.dR = theDR_Veto;
36  return result;
37 }
38 
40  const EventSetup& eventSetup,
41  const Photon& cand) const {
42  reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
43  IsoDeposit deposit(candDir);
44  deposit.setVeto(veto(candDir));
45  deposit.addCandEnergy(cand.pt());
46 
48  event.getByToken(thePFCandToken, PFCandH);
49 
50  double eta = cand.eta(), phi = cand.phi();
51  const reco::Particle::Point& vtx = cand.vertex();
52  for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
53  double dR = deltaR(it->eta(), it->phi(), eta, phi);
54  // veto SC
55  if (theVetoSuperClusterMatch && cand.superCluster().isNonnull() && it->superClusterRef().isNonnull() &&
56  cand.superCluster() == it->superClusterRef())
57  continue;
58  if ((dR < theDR_Max) && (dR > theDR_Veto) && (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
59  ((it->vertex() - vtx).Rho() < theDiff_r)) {
60  // ok
61  reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
62  deposit.addDeposit(dirTrk, it->pt());
63  }
64  }
65 
66  return deposit;
67 }
68 
70  const EventSetup& eventSetup,
71  const GsfElectron& cand) const {
72  reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
73  IsoDeposit deposit(candDir);
74  deposit.setVeto(veto(candDir));
75  deposit.addCandEnergy(cand.pt());
76 
78  event.getByToken(thePFCandToken, PFCandH);
79 
80  double eta = cand.eta(), phi = cand.phi();
81  const reco::Particle::Point& vtx = cand.vertex();
82  for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
83  double dR = deltaR(it->eta(), it->phi(), eta, phi);
84  // If MissHits>0 (possibly reconstructed as a photon in the PF in this case, kill the the photon if sharing the same SC)
85  if (cand.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) > 0 &&
86  theMissHitVetoSuperClusterMatch && it->mva_nothing_gamma() > 0.99 && cand.superCluster().isNonnull() &&
87  it->superClusterRef().isNonnull() && cand.superCluster() == it->superClusterRef()) {
88  continue;
89  }
90  if ((dR < theDR_Max) && (dR > theDR_Veto) && (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
91  ((it->vertex() - vtx).Rho() < theDiff_r)) {
92  // ok
93  reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
94  deposit.addDeposit(dirTrk, it->pt());
95  }
96  }
97 
98  return deposit;
99 }
100 
102  const EventSetup& eventSetup,
103  const Track& cand) const {
104  reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
105  IsoDeposit deposit(candDir);
106  deposit.setVeto(veto(candDir));
107  deposit.addCandEnergy(cand.pt());
109  event.getByToken(thePFCandToken, PFCandH);
110 
111  double eta = cand.eta(), phi = cand.phi();
112  const reco::Particle::Point& vtx = cand.vertex();
113  for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
114  double dR = deltaR(it->eta(), it->phi(), eta, phi);
115 
116  if ((dR < theDR_Max) && (dR > theDR_Veto) && (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
117  ((it->vertex() - vtx).Rho() < theDiff_r)) {
118  // ok
119  reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
120  deposit.addDeposit(dirTrk, it->pt());
121  }
122  }
123 
124  return deposit;
125 }
126 
128  const EventSetup& eventSetup,
129  const PFCandidate& cand) const {
130  reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
131  IsoDeposit deposit(candDir);
132  deposit.setVeto(veto(candDir));
133  deposit.addCandEnergy(cand.pt());
135  event.getByToken(thePFCandToken, PFCandH);
136 
137  double eta = cand.eta(), phi = cand.phi();
138  const reco::Particle::Point& vtx = cand.vertex();
139  for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
140  // veto SC
141  if (theVetoSuperClusterMatch && cand.superClusterRef().isNonnull() && it->superClusterRef().isNonnull() &&
142  cand.superClusterRef() == it->superClusterRef())
143  continue;
144  double dR = deltaR(it->eta(), it->phi(), eta, phi);
145 
146  if ((dR < theDR_Max) && (dR > theDR_Veto) && (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
147  ((it->vertex() - vtx).Rho() < theDiff_r)) {
148  // ok
149  reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
150  deposit.addDeposit(dirTrk, it->pt());
151  }
152  }
153 
154  return deposit;
155 }
156 
159 
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double pt() const final
transverse momentum
double vz() const override
z coordinate of vertex position
edm::EDGetTokenT< reco::PFCandidateCollection > thePFCandToken
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
const Point & vertex() const override
vertex position (overwritten by PF...)
tuple result
Definition: mps_fire.py:311
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
double pt() const
track transverse momentum
Definition: TrackBase.h:637
math::XYZPoint Point
point in the space
Definition: Particle.h:25
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::IsoDeposit depositFromObject(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Photon &cand) const
reco::IsoDeposit::Veto veto(const reco::IsoDeposit::Direction &dir) const
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:661
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &muon) const override
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:60
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
#define DEFINE_EDM_PLUGIN(factory, type, name)
double vz() const override
z coordinate of vertex position
Definition: PFCandidate.h:418
double phi() const final
momentum azimuthal angle
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:580
double eta() const final
momentum pseudorapidity