CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFPhotonIsolationCalculator.cc
Go to the documentation of this file.
2 #include <cmath>
4 
15 
17  iParticleType_ = conf.getParameter<int>("particleType");
18  if (iParticleType_ == 1) {
19  fConeSize_ = conf.getParameter<double>("coneDR");
20  iNumberOfRings_ = conf.getParameter<int>("numberOfRings");
21  fRingSize_ = conf.getParameter<double>("ringSize");
22  //
23  bApplyVeto_ = conf.getParameter<bool>("applyVeto");
24  bApplyPFPUVeto_ = conf.getParameter<bool>("applyPFPUVeto");
25  bApplyDzDxyVeto_ = conf.getParameter<bool>("applyDzDxyVeto");
26  bApplyMissHitPhVeto_ = conf.getParameter<bool>("applyMissHitPhVeto");
27  bDeltaRVetoBarrel_ = conf.getParameter<bool>("deltaRVetoBarrel");
28  bDeltaRVetoEndcap_ = conf.getParameter<bool>("deltaRVetoEndcap");
29  bRectangleVetoBarrel_ = conf.getParameter<bool>("rectangleVetoBarrel");
30  bRectangleVetoEndcap_ = conf.getParameter<bool>("rectangleVetoEndcap");
31  bUseCrystalSize_ = conf.getParameter<bool>("useCrystalSize");
32  //
33  fDeltaRVetoBarrelPhotons_ = conf.getParameter<double>("deltaRVetoBarrelPhotons");
34  fDeltaRVetoBarrelNeutrals_ = conf.getParameter<double>("deltaRVetoBarrelNeutrals");
35  fDeltaRVetoBarrelCharged_ = conf.getParameter<double>("deltaRVetoBarrelCharged");
36  fDeltaRVetoEndcapPhotons_ = conf.getParameter<double>("deltaRVetoEndcapPhotons");
37  fDeltaRVetoEndcapNeutrals_ = conf.getParameter<double>("deltaRVetoEndcapNeutrals");
38  fDeltaRVetoEndcapCharged_ = conf.getParameter<double>("deltaRVetoEndcapCharged");
39  fNumberOfCrystalEndcapPhotons_ = conf.getParameter<double>("numberOfCrystalEndcapPhotons");
40  //
41  fRectangleDeltaPhiVetoBarrelPhotons_ = conf.getParameter<double>("rectangleDeltaPhiVetoBarrelPhotons");
42  fRectangleDeltaPhiVetoBarrelNeutrals_ = conf.getParameter<double>("rectangleDeltaPhiVetoBarrelNeutrals");
43  fRectangleDeltaPhiVetoBarrelCharged_ = conf.getParameter<double>("rectangleDeltaPhiVetoBarrelCharged");
44  fRectangleDeltaPhiVetoEndcapPhotons_ = conf.getParameter<double>("rectangleDeltaPhiVetoEndcapPhotons");
45  fRectangleDeltaPhiVetoEndcapNeutrals_ = conf.getParameter<double>("rectangleDeltaPhiVetoEndcapNeutrals");
46  fRectangleDeltaPhiVetoEndcapCharged_ = conf.getParameter<double>("rectangleDeltaPhiVetoEndcapCharged");
47  //
48  fRectangleDeltaEtaVetoBarrelPhotons_ = conf.getParameter<double>("rectangleDeltaEtaVetoBarrelPhotons");
49  fRectangleDeltaEtaVetoBarrelNeutrals_ = conf.getParameter<double>("rectangleDeltaEtaVetoBarrelNeutrals");
50  fRectangleDeltaEtaVetoBarrelCharged_ = conf.getParameter<double>("rectangleDeltaEtaVetoBarrelCharged");
51  fRectangleDeltaEtaVetoEndcapPhotons_ = conf.getParameter<double>("rectangleDeltaEtaVetoEndcapPhotons");
52  fRectangleDeltaEtaVetoEndcapNeutrals_ = conf.getParameter<double>("rectangleDeltaEtaVetoEndcapNeutrals");
53  fRectangleDeltaEtaVetoEndcapCharged_ = conf.getParameter<double>("rectangleDeltaEtaVetoEndcapCharged");
54  //
55  bCheckClosestZVertex_ = conf.getParameter<bool>("checkClosestZVertex");
56  initializeRings(iNumberOfRings_, fConeSize_);
57  }
58 }
59 
60 //--------------------------------------------------------------------------------------------------
61 
63  // Constructor.
64 }
65 
66 //--------------------------------------------------------------------------------------------------
68 
70  const edm::Handle<reco::PFCandidateCollection> pfCandidateHandle,
71  // reco::VertexRef vtx,
73  const edm::Event& e,
74  const edm::EventSetup& es,
76  reco::VertexRef vtx(vertices, 0);
77  this->fGetIsolation(&*aPho, pfCandidateHandle, vtx, vertices);
78  phoisol03.chargedHadronIso = this->getIsolationCharged();
79  phoisol03.neutralHadronIso = this->getIsolationNeutral();
80  phoisol03.photonIso = this->getIsolationPhoton();
81 }
82 
83 //--------------------------------------------------------------------------------------------------
84 void PFPhotonIsolationCalculator::initializeRings(int iNumberOfRings, float fRingSize) {
85  fIsolationInRings_.clear();
86  for (int isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
87  float fTemp = 0.0;
88  fIsolationInRings_.push_back(fTemp);
89 
90  float fTempPhoton = 0.0;
91  fIsolationInRingsPhoton_.push_back(fTempPhoton);
92 
93  float fTempNeutral = 0.0;
94  fIsolationInRingsNeutral_.push_back(fTempNeutral);
95 
96  float fTempCharged = 0.0;
97  fIsolationInRingsCharged_.push_back(fTempCharged);
98 
99  float fTempChargedAll = 0.0;
100  fIsolationInRingsChargedAll_.push_back(fTempChargedAll);
101  }
102 
103  fConeSize_ = fRingSize * (float)iNumberOfRings;
104 }
105 
106 //--------------------------------------------------------------------------------------------------
108  const edm::Handle<reco::PFCandidateCollection> pfCandidateHandle,
111  fGetIsolationInRings(photon, pfCandidateHandle, vtx, vertices);
113  return fIsolation_;
114 }
115 
116 //--------------------------------------------------------------------------------------------------
118  const reco::Photon* photon,
119  const edm::Handle<reco::PFCandidateCollection> pfCandidateHandle,
122  int isoBin;
123 
124  for (isoBin = 0; isoBin < iNumberOfRings_; isoBin++) {
125  fIsolationInRings_[isoBin] = 0.;
126  fIsolationInRingsPhoton_[isoBin] = 0.;
127  fIsolationInRingsNeutral_[isoBin] = 0.;
128  fIsolationInRingsCharged_[isoBin] = 0.;
129  fIsolationInRingsChargedAll_[isoBin] = 0.;
130  }
131 
132  iMissHits_ = 0;
133 
134  refSC = photon->superCluster();
135  pivotInBarrel = std::fabs((refSC->position().eta())) < 1.479;
136 
137  for (unsigned iPF = 0; iPF < pfCandidateHandle->size(); iPF++) {
138  reco::PFCandidateRef pfParticle(reco::PFCandidateRef(pfCandidateHandle, iPF));
139 
140  if (pfParticle->superClusterRef().isNonnull() && photon->superCluster().isNonnull() &&
141  pfParticle->superClusterRef() == photon->superCluster())
142  continue;
143 
144  if (pfParticle->pdgId() == 22) {
145  // Set the vertex of reco::Photon to the first PV
146  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle->vx(),
147  photon->superCluster()->y() - pfParticle->vy(),
148  photon->superCluster()->z() - pfParticle->vz());
149 
150  fEta_ = direction.Eta();
151  fPhi_ = direction.Phi();
152  fVx_ = pfParticle->vx();
153  fVy_ = pfParticle->vy();
154  fVz_ = pfParticle->vz();
155 
156  float fDeltaR = isPhotonParticleVetoed(pfParticle);
157  if (fDeltaR >= 0.) {
158  isoBin = (int)(fDeltaR / fRingSize_);
159  fIsolationInRingsPhoton_[isoBin] = fIsolationInRingsPhoton_[isoBin] + pfParticle->pt();
160  }
161 
162  } else if (std::abs(pfParticle->pdgId()) == 130) {
163  // Set the vertex of reco::Photon to the first PV
164  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle->vx(),
165  photon->superCluster()->y() - pfParticle->vy(),
166  photon->superCluster()->z() - pfParticle->vz());
167 
168  fEta_ = direction.Eta();
169  fPhi_ = direction.Phi();
170  fVx_ = pfParticle->vx();
171  fVy_ = pfParticle->vy();
172  fVz_ = pfParticle->vz();
173  float fDeltaR = isNeutralParticleVetoed(pfParticle);
174  if (fDeltaR >= 0.) {
175  isoBin = (int)(fDeltaR / fRingSize_);
176  fIsolationInRingsNeutral_[isoBin] = fIsolationInRingsNeutral_[isoBin] + pfParticle->pt();
177  }
178 
179  //}else if(abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || abs(pfParticle.pdgId()) == 211){
180  } else if (std::abs(pfParticle->pdgId()) == 211) {
181  // Set the vertex of reco::Photon to the first PV
182  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - (*vtx).x(),
183  photon->superCluster()->y() - (*vtx).y(),
184  photon->superCluster()->z() - (*vtx).z());
185 
186  fEta_ = direction.Eta();
187  fPhi_ = direction.Phi();
188  fVx_ = (*vtx).x();
189  fVy_ = (*vtx).y();
190  fVz_ = (*vtx).z();
191  float fDeltaR = isChargedParticleVetoed(pfParticle, vtx, vertices);
192  if (fDeltaR >= 0.) {
193  isoBin = (int)(fDeltaR / fRingSize_);
194  fIsolationInRingsCharged_[isoBin] = fIsolationInRingsCharged_[isoBin] + pfParticle->pt();
195  }
196  }
197  }
198 
199  for (int isoBin = 0; isoBin < iNumberOfRings_; isoBin++) {
200  fIsolationInRings_[isoBin] =
202  }
203 
204  return fIsolationInRings_;
205 }
206 
207 //--------------------------------------------------------------------------------------------------
209  float fDeltaR = deltaR(fEta_, fPhi_, pfIsoCand->eta(), pfIsoCand->phi());
210 
211  if (fDeltaR > fConeSize_)
212  return -999.;
213 
214  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
215  float fDeltaEta = fEta_ - pfIsoCand->eta();
216 
217  if (!bApplyVeto_)
218  return fDeltaR;
219 
220  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
221  // this will be changed in the future
222 
223  if (bApplyMissHitPhVeto_) {
224  if (iMissHits_ > 0)
225  if (pfIsoCand->mva_nothing_gamma() > 0.99) {
226  if (pfIsoCand->superClusterRef().isNonnull() && refSC.isNonnull()) {
227  if (pfIsoCand->superClusterRef() == refSC)
228  return -999.;
229  }
230  }
231  }
232 
233  if (pivotInBarrel) {
234  if (bDeltaRVetoBarrel_) {
235  if (fDeltaR < fDeltaRVetoBarrelPhotons_)
236  return -999.;
237  }
238 
239  if (bRectangleVetoBarrel_) {
242  return -999.;
243  }
244  }
245  } else {
246  if (bUseCrystalSize_ == true) {
248  0.00864 * std::fabs(refSC->position().z() / sqrt(refSC->position().perp2())) * fNumberOfCrystalEndcapPhotons_;
249  }
250 
251  if (bDeltaRVetoEndcap_) {
252  if (fDeltaR < fDeltaRVetoEndcapPhotons_)
253  return -999.;
254  }
255  if (bRectangleVetoEndcap_) {
258  return -999.;
259  }
260  }
261  }
262 
263  return fDeltaR;
264 }
265 
266 //--------------------------------------------------------------------------------------------------
268  float fDeltaR = deltaR(fEta_, fPhi_, pfIsoCand->eta(), pfIsoCand->phi());
269 
270  if (fDeltaR > fConeSize_)
271  return -999.;
272 
273  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
274  float fDeltaEta = fEta_ - pfIsoCand->eta();
275 
276  if (!bApplyVeto_)
277  return fDeltaR;
278 
279  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
280  // this will be changed in the future
281 
282  if (bApplyMissHitPhVeto_) {
283  if (iMissHits_ > 0)
284  if (pfIsoCand->mva_nothing_gamma() > 0.99) {
285  if (pfIsoCand->superClusterRef().isNonnull() && refSC.isNonnull()) {
286  if (pfIsoCand->superClusterRef() == refSC)
287  return -999.;
288  }
289  }
290  }
291 
292  if (pivotInBarrel) {
293  if (bDeltaRVetoBarrel_) {
294  if (fDeltaR < fDeltaRVetoBarrelPhotons_)
295  return -999.;
296  }
297 
298  if (bRectangleVetoBarrel_) {
301  return -999.;
302  }
303  }
304  } else {
305  if (bUseCrystalSize_ == true) {
307  0.00864 * std::fabs(refSC->position().z() / sqrt(refSC->position().perp2())) * fNumberOfCrystalEndcapPhotons_;
308  }
309 
310  if (bDeltaRVetoEndcap_) {
311  if (fDeltaR < fDeltaRVetoEndcapPhotons_)
312  return -999.;
313  }
314  if (bRectangleVetoEndcap_) {
317  return -999.;
318  }
319  }
320  }
321 
322  return fDeltaR;
323 }
324 
325 //--------------------------------------------------------------------------------------------------
327  float fDeltaR = deltaR(fEta_, fPhi_, pfIsoCand->eta(), pfIsoCand->phi());
328 
329  if (fDeltaR > fConeSize_)
330  return -999;
331 
332  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
333  float fDeltaEta = fEta_ - pfIsoCand->eta();
334 
335  if (!bApplyVeto_)
336  return fDeltaR;
337 
338  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
339  // this will be changed in the future
340  if (pivotInBarrel) {
342  return fDeltaR;
343  }
344 
345  if (bDeltaRVetoBarrel_) {
346  if (fDeltaR < fDeltaRVetoBarrelNeutrals_)
347  return -999.;
348  }
349  if (bRectangleVetoBarrel_) {
352  return -999.;
353  }
354  }
355 
356  } else {
358  return fDeltaR;
359  }
360  if (bDeltaRVetoEndcap_) {
361  if (fDeltaR < fDeltaRVetoEndcapNeutrals_)
362  return -999.;
363  }
364  if (bRectangleVetoEndcap_) {
367  return -999.;
368  }
369  }
370  }
371 
372  return fDeltaR;
373 }
374 
375 //--------------------------------------------------------------------------------------------------
377  float fDeltaR = deltaR(fEta_, fPhi_, pfIsoCand->eta(), pfIsoCand->phi());
378 
379  if (fDeltaR > fConeSize_)
380  return -999;
381 
382  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
383  float fDeltaEta = fEta_ - pfIsoCand->eta();
384 
385  if (!bApplyVeto_)
386  return fDeltaR;
387 
388  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
389  // this will be changed in the future
390  if (pivotInBarrel) {
392  return fDeltaR;
393  }
394 
395  if (bDeltaRVetoBarrel_) {
396  if (fDeltaR < fDeltaRVetoBarrelNeutrals_)
397  return -999.;
398  }
399  if (bRectangleVetoBarrel_) {
402  return -999.;
403  }
404  }
405 
406  } else {
408  return fDeltaR;
409  }
410  if (bDeltaRVetoEndcap_) {
411  if (fDeltaR < fDeltaRVetoEndcapNeutrals_)
412  return -999.;
413  }
414  if (bRectangleVetoEndcap_) {
417  return -999.;
418  }
419  }
420  }
421 
422  return fDeltaR;
423 }
424 
425 //----------------------------------------------------------------------------------------------------
428  //need code to handle special conditions
429 
430  return -999;
431 }
432 
433 //-----------------------------------------------------------------------------------------------------
435  reco::VertexRef vtxMain,
437  reco::VertexRef vtx = chargedHadronVertex(vertices, *pfIsoCand);
438  if (vtx.isNull())
439  return -999.;
440 
441  // float fVtxMainX = (*vtxMain).x();
442  // float fVtxMainY = (*vtxMain).y();
443  float fVtxMainZ = (*vtxMain).z();
444 
445  if (bApplyPFPUVeto_) {
446  if (vtx != vtxMain)
447  return -999.;
448  }
449 
450  if (bApplyDzDxyVeto_) {
451  if (iParticleType_ == kPhoton) {
452  float dz = std::fabs(pfIsoCand->trackRef()->dz((*vtxMain).position()));
453  if (dz > 0.2)
454  return -999.;
455 
456  double dxy = pfIsoCand->trackRef()->dxy((*vtxMain).position());
457  if (std::fabs(dxy) > 0.1)
458  return -999.;
459 
460  /*
461 float dz = fabs(vtx->z() - fVtxMainZ);
462 if (dz > 1.)
463  return -999.;
464 double dxy = ( -(vtx->x() - fVtxMainX)*pfIsoCand->py() + (vtx->y() - fVtxMainY)*pfIsoCand->px()) / pfIsoCand->pt();
465 if(fabs(dxy) > 0.2)
466  return -999.;
467 */
468  } else {
469  float dz = std::fabs(vtx->z() - fVtxMainZ);
470  if (dz > 1.)
471  return -999.;
472 
473  double dxy = (-(vtx->x() - fVx_) * pfIsoCand->py() + (vtx->y() - fVy_) * pfIsoCand->px()) / pfIsoCand->pt();
474  if (std::fabs(dxy) > 0.1)
475  return -999.;
476  }
477  }
478 
479  float fDeltaR = deltaR(pfIsoCand->eta(), pfIsoCand->phi(), fEta_, fPhi_);
480 
481  if (fDeltaR > fConeSize_)
482  return -999.;
483 
484  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
485  float fDeltaEta = fEta_ - pfIsoCand->eta();
486 
487  // std::abscout << " charged hadron: DR " << fDeltaR
488  // << " pt " << pfIsoCand->pt() << " eta,phi " << pfIsoCand->eta() << ", " << pfIsoCand->phi()
489  // << " fVtxMainZ " << (*vtxMain).z() << " cand z " << vtx->z() << std::endl;
490 
491  if (!bApplyVeto_)
492  return fDeltaR;
493 
494  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
495  // this will be changed in the future
496  if (pivotInBarrel) {
498  return fDeltaR;
499  }
500 
501  if (bDeltaRVetoBarrel_) {
502  if (fDeltaR < fDeltaRVetoBarrelCharged_)
503  return -999.;
504  }
505  if (bRectangleVetoBarrel_) {
508  return -999.;
509  }
510  }
511 
512  } else {
514  return fDeltaR;
515  }
516  if (bDeltaRVetoEndcap_) {
517  if (fDeltaR < fDeltaRVetoEndcapCharged_)
518  return -999.;
519  }
520  if (bRectangleVetoEndcap_) {
523  return -999.;
524  }
525  }
526  }
527 
528  return fDeltaR;
529 }
530 
531 //-----------------------------------------------------------------------------------------------------
533  reco::VertexRef vtxMain,
535  reco::VertexRef vtx = chargedHadronVertex(vertices, *pfIsoCand);
536  if (vtx.isNull())
537  return -999.;
538 
539  // float fVtxMainX = (*vtxMain).x();
540  // float fVtxMainY = (*vtxMain).y();
541  float fVtxMainZ = (*vtxMain).z();
542 
543  if (bApplyPFPUVeto_) {
544  if (vtx != vtxMain)
545  return -999.;
546  }
547 
548  if (bApplyDzDxyVeto_) {
549  if (iParticleType_ == kPhoton) {
550  float dz = std::fabs(pfIsoCand->trackRef()->dz((*vtxMain).position()));
551  if (dz > 0.2)
552  return -999.;
553 
554  double dxy = pfIsoCand->trackRef()->dxy((*vtxMain).position());
555  if (std::fabs(dxy) > 0.1)
556  return -999.;
557 
558  /*
559 float dz = fabs(vtx->z() - fVtxMainZ);
560 if (dz > 1.)
561  return -999.;
562 double dxy = ( -(vtx->x() - fVtxMainX)*pfIsoCand->py() + (vtx->y() - fVtxMainY)*pfIsoCand->px()) / pfIsoCand->pt();
563 if(fabs(dxy) > 0.2)
564  return -999.;
565 */
566  } else {
567  float dz = std::fabs(vtx->z() - fVtxMainZ);
568  if (dz > 1.)
569  return -999.;
570 
571  double dxy = (-(vtx->x() - fVx_) * pfIsoCand->py() + (vtx->y() - fVy_) * pfIsoCand->px()) / pfIsoCand->pt();
572  if (std::fabs(dxy) > 0.1)
573  return -999.;
574  }
575  }
576 
577  float fDeltaR = deltaR(pfIsoCand->eta(), pfIsoCand->phi(), fEta_, fPhi_);
578 
579  if (fDeltaR > fConeSize_)
580  return -999.;
581 
582  float fDeltaPhi = deltaPhi(fPhi_, pfIsoCand->phi());
583  float fDeltaEta = fEta_ - pfIsoCand->eta();
584 
585  // std::cout << " charged hadron: DR " << fDeltaR
586  // << " pt " << pfIsoCand->pt() << " eta,phi " << pfIsoCand->eta() << ", " << pfIsoCand->phi()
587  // << " fVtxMainZ " << (*vtxMain).z() << " cand z " << vtx->z() << std::endl;
588 
589  if (!bApplyVeto_)
590  return fDeltaR;
591 
592  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
593  // this will be changed in the future
594  if (pivotInBarrel) {
596  return fDeltaR;
597  }
598 
599  if (bDeltaRVetoBarrel_) {
600  if (fDeltaR < fDeltaRVetoBarrelCharged_)
601  return -999.;
602  }
603  if (bRectangleVetoBarrel_) {
606  return -999.;
607  }
608  }
609 
610  } else {
612  return fDeltaR;
613  }
614  if (bDeltaRVetoEndcap_) {
615  if (fDeltaR < fDeltaRVetoEndcapCharged_)
616  return -999.;
617  }
618  if (bRectangleVetoEndcap_) {
621  return -999.;
622  }
623  }
624  }
625 
626  return fDeltaR;
627 }
628 
629 //--------------------------------------------------------------------------------------------------
631  const reco::PFCandidate& pfcand) {
632  //code copied from Florian's PFNoPU class (corrected removing the double loop....)
633 
634  auto const& track = pfcand.trackRef();
635 
636  size_t iVertex = 0;
637  unsigned int index = 0;
638  unsigned int nFoundVertex = 0;
639 
640  float bestweight = 0;
641 
642  const reco::VertexCollection& vertices = *(verticesColl.product());
643 
644  for (auto const& vtx : vertices) {
645  float w = vtx.trackWeight(track); // 0 if does not belong here
646  //select the vertex for which the track has the highest weight
647  if (w > bestweight) { // should we break here?
648  bestweight = w;
649  iVertex = index;
650  nFoundVertex++;
651  }
652  ++index;
653  }
654 
655  if (nFoundVertex > 0) {
656  if (nFoundVertex != 1)
657  edm::LogWarning("TrackOnTwoVertex") << "a track is shared by at least two verteces. Used to be an assert";
658  return reco::VertexRef(verticesColl, iVertex);
659  }
660  // no vertex found with this track.
661 
662  // optional: as a secondary solution, associate the closest vertex in z
663  if (bCheckClosestZVertex_) {
664  double dzmin = 10000.;
665  double ztrack = pfcand.vertex().z();
666  bool foundVertex = false;
667  index = 0;
668  for (reco::VertexCollection::const_iterator iv = vertices.begin(); iv != vertices.end(); ++iv, ++index) {
669  double dz = std::fabs(ztrack - iv->z());
670  if (dz < dzmin) {
671  dzmin = dz;
672  iVertex = index;
673  foundVertex = true;
674  }
675  }
676 
677  if (foundVertex)
678  return reco::VertexRef(verticesColl, iVertex);
679  }
680 
681  return reco::VertexRef();
682 }
683 
685  const reco::PFCandidateCollection* Candidates) {
686  Int_t iMatch = -1;
687 
688  int i = 0;
689  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
690  const reco::PFCandidate& pfParticle = (*iPF);
691  if ((((pfParticle.pdgId() == 22) || std::abs(pfParticle.pdgId()) == 11))) {
692  if (pfParticle.superClusterRef() == photon->superCluster())
693  iMatch = i;
694  }
695 
696  i++;
697  }
698 
699  /*
700 if(iMatch == -1){
701 i=0;
702 float fPt = -1;
703 for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
704 const reco::PFCandidate& pfParticle = (*iPF);
705 if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
706  if(pfParticle.pt()>fPt){
707  fDeltaR = deltaR(pfParticle.eta(),pfParticle.phi(),photon->eta(),photon->phi());
708  if(fDeltaR<0.1){
709  iMatch = i;
710  fPt = pfParticle.pt();
711  }
712  }
713 }
714 i++;
715 }
716 }
717 */
718 
719  return iMatch;
720 }
721 
723  const reco::PFCandidateCollection* Candidates) {
724  Int_t iMatch = -1;
725 
726  int i = 0;
727  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
728  const reco::PFCandidate& pfParticle = (*iPF);
729  if ((((pfParticle.pdgId() == 22) || std::abs(pfParticle.pdgId()) == 11))) {
730  if (pfParticle.superClusterRef() == electron->superCluster())
731  iMatch = i;
732  }
733 
734  i++;
735  }
736 
737  if (iMatch == -1) {
738  i = 0;
739  float fPt = -1;
740  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
741  const reco::PFCandidate& pfParticle = (*iPF);
742  if ((((pfParticle.pdgId() == 22) || std::abs(pfParticle.pdgId()) == 11))) {
743  if (pfParticle.pt() > fPt) {
744  float fDeltaR = deltaR(pfParticle.eta(), pfParticle.phi(), electron->eta(), electron->phi());
745  if (fDeltaR < 0.1) {
746  iMatch = i;
747  fPt = pfParticle.pt();
748  }
749  }
750  }
751  i++;
752  }
753  }
754 
755  return iMatch;
756 }
T getParameter(std::string const &) const
int pdgId() const final
PDG identifier.
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double eta() const final
momentum pseudorapidity
float isNeutralParticleVetoed(const reco::PFCandidate *pfIsoCand)
const double w
Definition: UKUtility.cc:23
int matchPFObject(const reco::Photon *photon, const reco::PFCandidateCollection *pfParticlesColl)
std::vector< float > fGetIsolationInRings(const reco::Photon *photon, edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:334
double px() const final
x coordinate of momentum vector
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
void setup(const edm::ParameterSet &conf)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:602
std::vector< float > fIsolationInRingsChargedAll_
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::VertexRef chargedHadronVertex(edm::Handle< reco::VertexCollection > verticies, const reco::PFCandidate &pfcand)
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
bool isNull() const
Checks for null.
Definition: Ref.h:235
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< float > fIsolationInRingsNeutral_
T const * product() const
Definition: Handle.h:69
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double py() const final
y coordinate of momentum vector
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
float fGetIsolation(const reco::Photon *photon, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
float isPhotonParticleVetoed(const reco::PFCandidateRef pfIsoCand)
void initializeRings(int iNumberOfRings, float fRingSize)
float isChargedParticleVetoed(const reco::PFCandidate *pfIsoCand, edm::Handle< reco::VertexCollection > vertices)
double phi() const final
momentum azimuthal angle
void calculate(const reco::Photon *, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, edm::Handle< reco::VertexCollection > &vertices, const edm::Event &e, const edm::EventSetup &es, reco::Photon::PflowIsolationVariables &phoisol03)
std::vector< float > fIsolationInRingsCharged_
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:558