CMS 3D CMS Logo

PFIsolationEstimator.cc
Go to the documentation of this file.
1 #include <TFile.h>
3 #include <cmath>
5 
6 #ifndef STANDALONE
20 
21 #endif
22 
23 //--------------------------------------------------------------------------------------------------
24 PFIsolationEstimator::PFIsolationEstimator() : fisInitialized(kFALSE) {
25  // Constructor.
26 }
27 
28 //--------------------------------------------------------------------------------------------------
30 
31 //--------------------------------------------------------------------------------------------------
32 void PFIsolationEstimator::initialize(Bool_t bApplyVeto, int iParticleType) {
34 
35  //By default check for an option vertex association
36  checkClosestZVertex = kTRUE;
37 
38  //Apply vetoes
40 
47 
54 
61 
63  //Setup veto conditions for electrons
64  setDeltaRVetoBarrel(kTRUE);
65  setDeltaRVetoEndcap(kTRUE);
66  setRectangleVetoBarrel(kFALSE);
67  setRectangleVetoEndcap(kFALSE);
68  setApplyDzDxyVeto(kFALSE);
69  setApplyPFPUVeto(kTRUE);
70  setApplyMissHitPhVeto(kTRUE); //NOTE: decided to go for this on the 26May 2012
71  //Current recommended default value for the electrons
72  setUseCrystalSize(kFALSE);
73 
74  // setDeltaRVetoBarrelPhotons(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
75  // setDeltaRVetoBarrelCharged(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
76  // setDeltaRVetoBarrelNeutrals(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
79  // setDeltaRVetoEndcapNeutrals(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
80 
81  setConeSize(0.4);
82 
83  } else {
84  //Setup veto conditions for photons
85  setApplyDzDxyVeto(kTRUE);
86  setApplyPFPUVeto(kTRUE);
87  setApplyMissHitPhVeto(kFALSE);
88  setDeltaRVetoBarrel(kTRUE);
89  setDeltaRVetoEndcap(kTRUE);
91  setRectangleVetoEndcap(kFALSE);
92  setUseCrystalSize(kTRUE);
93  setConeSize(0.3);
94 
104 
115  }
116 }
117 
118 //--------------------------------------------------------------------------------------------------
122 
123  // std::cout << " ********* Init Entering in kElectron setup "
124  // << " bApplyVeto " << bApplyVeto
125  // << " bDeltaRVetoBarrel " << bDeltaRVetoBarrel
126  // << " bDeltaRVetoEndcap " << bDeltaRVetoEndcap
127  // << " cone size " << fConeSize
128  // << " fDeltaRVetoEndcapPhotons " << fDeltaRVetoEndcapPhotons
129  // << " fDeltaRVetoEndcapNeutrals " << fDeltaRVetoEndcapNeutrals
130  // << " fDeltaRVetoEndcapCharged " << fDeltaRVetoEndcapCharged << std::endl;
131 }
132 
133 //--------------------------------------------------------------------------------------------------
137 }
138 
139 //--------------------------------------------------------------------------------------------------
140 void PFIsolationEstimator::initializeElectronIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize) {
143 }
144 
145 //--------------------------------------------------------------------------------------------------
146 void PFIsolationEstimator::initializePhotonIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize) {
149 }
150 
151 //--------------------------------------------------------------------------------------------------
152 void PFIsolationEstimator::initializeRings(int iNumberOfRings, float fRingSize) {
155 
156  fIsolationInRings.clear();
157  for (int isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
158  float fTemp = 0.0;
159  fIsolationInRings.push_back(fTemp);
160 
161  float fTempPhoton = 0.0;
162  fIsolationInRingsPhoton.push_back(fTempPhoton);
163 
164  float fTempNeutral = 0.0;
165  fIsolationInRingsNeutral.push_back(fTempNeutral);
166 
167  float fTempCharged = 0.0;
168  fIsolationInRingsCharged.push_back(fTempCharged);
169 
170  float fTempChargedAll = 0.0;
171  fIsolationInRingsChargedAll.push_back(fTempChargedAll);
172  }
173 
175 }
176 
177 //--------------------------------------------------------------------------------------------------
179  const reco::PFCandidateCollection* pfParticlesColl,
182  fGetIsolationInRings(pfCandidate, pfParticlesColl, vtx, vertices);
185 
186  return fIsolation;
187 }
188 
189 //--------------------------------------------------------------------------------------------------
190 std::vector<float> PFIsolationEstimator::fGetIsolationInRings(const reco::PFCandidate* pfCandidate,
191  const reco::PFCandidateCollection* pfParticlesColl,
194  int isoBin;
195 
196  for (isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
197  fIsolationInRings[isoBin] = 0.;
198  fIsolationInRingsPhoton[isoBin] = 0.;
199  fIsolationInRingsNeutral[isoBin] = 0.;
200  fIsolationInRingsCharged[isoBin] = 0.;
201  fIsolationInRingsChargedAll[isoBin] = 0.;
202  }
203 
204  fEta = pfCandidate->eta();
205  fPhi = pfCandidate->phi();
206  fPt = pfCandidate->pt();
207  fVx = pfCandidate->vx();
208  fVy = pfCandidate->vy();
209  fVz = pfCandidate->vz();
210 
211  pivotInBarrel = std::abs(pfCandidate->positionAtECALEntrance().eta()) < 1.479;
212 
213  for (unsigned iPF = 0; iPF < pfParticlesColl->size(); iPF++) {
214  const reco::PFCandidate& pfParticle = (*pfParticlesColl)[iPF];
215 
216  if (&pfParticle == (pfCandidate))
217  continue;
218 
219  if (pfParticle.pdgId() == 22) {
220  if (isPhotonParticleVetoed(&pfParticle) >= 0.) {
221  isoBin = (int)(fDeltaR / fRingSize);
222  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
223  }
224 
225  } else if (std::abs(pfParticle.pdgId()) == 130) {
226  if (isNeutralParticleVetoed(&pfParticle) >= 0.) {
227  isoBin = (int)(fDeltaR / fRingSize);
228  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
229  }
230 
231  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
232  } else if (std::abs(pfParticle.pdgId()) == 211) {
233  if (isChargedParticleVetoed(&pfParticle, vtx, vertices) >= 0.) {
234  isoBin = (int)(fDeltaR / fRingSize);
235  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
236  }
237  }
238  }
239 
240  for (int isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
241  fIsolationInRings[isoBin] =
243  }
244 
245  return fIsolationInRings;
246 }
247 
248 //--------------------------------------------------------------------------------------------------
250  const reco::PFCandidateCollection* pfParticlesColl,
253  fGetIsolationInRings(photon, pfParticlesColl, vtx, vertices);
255 
256  return fIsolation;
257 }
258 
259 //--------------------------------------------------------------------------------------------------
261  const reco::PFCandidateCollection* pfParticlesColl,
264  int isoBin;
265 
266  for (isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
267  fIsolationInRings[isoBin] = 0.;
268  fIsolationInRingsPhoton[isoBin] = 0.;
269  fIsolationInRingsNeutral[isoBin] = 0.;
270  fIsolationInRingsCharged[isoBin] = 0.;
271  fIsolationInRingsChargedAll[isoBin] = 0.;
272  }
273 
274  iMissHits = 0;
275 
276  refSC = photon->superCluster();
277  pivotInBarrel = std::abs((refSC->position().eta())) < 1.479;
278 
279  for (unsigned iPF = 0; iPF < pfParticlesColl->size(); iPF++) {
280  const reco::PFCandidate& pfParticle = (*pfParticlesColl)[iPF];
281 
282  if (pfParticle.superClusterRef().isNonnull() && photon->superCluster().isNonnull() &&
283  pfParticle.superClusterRef() == photon->superCluster())
284  continue;
285 
286  if (pfParticle.pdgId() == 22) {
287  // Set the vertex of reco::Photon to the first PV
288  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle.vx(),
289  photon->superCluster()->y() - pfParticle.vy(),
290  photon->superCluster()->z() - pfParticle.vz());
291 
292  fEta = direction.Eta();
293  fPhi = direction.Phi();
294  fVx = pfParticle.vx();
295  fVy = pfParticle.vy();
296  fVz = pfParticle.vz();
297 
298  if (isPhotonParticleVetoed(&pfParticle) >= 0.) {
299  isoBin = (int)(fDeltaR / fRingSize);
300  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
301  }
302 
303  } else if (std::abs(pfParticle.pdgId()) == 130) {
304  // Set the vertex of reco::Photon to the first PV
305  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle.vx(),
306  photon->superCluster()->y() - pfParticle.vy(),
307  photon->superCluster()->z() - pfParticle.vz());
308 
309  fEta = direction.Eta();
310  fPhi = direction.Phi();
311  fVx = pfParticle.vx();
312  fVy = pfParticle.vy();
313  fVz = pfParticle.vz();
314 
315  if (isNeutralParticleVetoed(&pfParticle) >= 0.) {
316  isoBin = (int)(fDeltaR / fRingSize);
317  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
318  }
319 
320  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
321  } else if (std::abs(pfParticle.pdgId()) == 211) {
322  // Set the vertex of reco::Photon to the first PV
323  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - (*vtx).x(),
324  photon->superCluster()->y() - (*vtx).y(),
325  photon->superCluster()->z() - (*vtx).z());
326 
327  fEta = direction.Eta();
328  fPhi = direction.Phi();
329  fVx = (*vtx).x();
330  fVy = (*vtx).y();
331  fVz = (*vtx).z();
332 
333  if (isChargedParticleVetoed(&pfParticle, vtx, vertices) >= 0.) {
334  isoBin = (int)(fDeltaR / fRingSize);
335  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
336  }
337  }
338  }
339 
340  for (int isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
341  fIsolationInRings[isoBin] =
343  }
344 
345  return fIsolationInRings;
346 }
347 
348 //--------------------------------------------------------------------------------------------------
350  const reco::PFCandidateCollection* pfParticlesColl,
353  fGetIsolationInRings(electron, pfParticlesColl, vtx, vertices);
355 
356  return fIsolation;
357 }
358 
359 //--------------------------------------------------------------------------------------------------
361  const reco::PFCandidateCollection* pfParticlesColl,
364  int isoBin;
365 
366  for (isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
367  fIsolationInRings[isoBin] = 0.;
368  fIsolationInRingsPhoton[isoBin] = 0.;
369  fIsolationInRingsNeutral[isoBin] = 0.;
370  fIsolationInRingsCharged[isoBin] = 0.;
371  fIsolationInRingsChargedAll[isoBin] = 0.;
372  }
373 
374  // int iMatch = matchPFObject(electron,pfParticlesColl);
375 
376  fEta = electron->eta();
377  fPhi = electron->phi();
378  fPt = electron->pt();
379  fVx = electron->vx();
380  fVy = electron->vy();
381  fVz = electron->vz();
382  iMissHits = electron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
383 
384  // if(electron->ecalDrivenSeed())
385  refSC = electron->superCluster();
386  pivotInBarrel = std::abs((refSC->position().eta())) < 1.479;
387 
388  for (unsigned iPF = 0; iPF < pfParticlesColl->size(); iPF++) {
389  const reco::PFCandidate& pfParticle = (*pfParticlesColl)[iPF];
390 
391  if (pfParticle.pdgId() == 22) {
392  if (isPhotonParticleVetoed(&pfParticle) >= 0.) {
393  isoBin = (int)(fDeltaR / fRingSize);
394  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
395  }
396 
397  } else if (std::abs(pfParticle.pdgId()) == 130) {
398  if (isNeutralParticleVetoed(&pfParticle) >= 0.) {
399  isoBin = (int)(fDeltaR / fRingSize);
400  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
401  }
402 
403  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
404  } else if (std::abs(pfParticle.pdgId()) == 211) {
405  if (isChargedParticleVetoed(&pfParticle, vtx, vertices) >= 0.) {
406  isoBin = (int)(fDeltaR / fRingSize);
407 
408  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
409  }
410  }
411  }
412 
413  for (int isoBin = 0; isoBin < iNumberOfRings; isoBin++) {
414  fIsolationInRings[isoBin] =
416  }
417 
418  return fIsolationInRings;
419 }
420 
421 //--------------------------------------------------------------------------------------------------
423  fDeltaR = deltaR(fEta, fPhi, pfIsoCand->eta(), pfIsoCand->phi());
424 
425  if (fDeltaR > fConeSize)
426  return -999.;
427 
428  fDeltaPhi = deltaPhi(fPhi, pfIsoCand->phi());
429  fDeltaEta = fEta - pfIsoCand->eta();
430 
431  if (!bApplyVeto)
432  return fDeltaR;
433 
434  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
435  // this will be changed in the future
436 
437  if (bApplyMissHitPhVeto) {
438  if (iMissHits > 0)
439  if (pfIsoCand->mva_nothing_gamma() > 0.99) {
440  if (pfIsoCand->superClusterRef().isNonnull() && refSC.isNonnull()) {
441  if (pfIsoCand->superClusterRef() == refSC)
442  return -999.;
443  }
444  }
445  }
446 
447  if (pivotInBarrel) {
448  if (bDeltaRVetoBarrel) {
450  return -999.;
451  }
452 
453  if (bRectangleVetoBarrel) {
456  return -999.;
457  }
458  }
459  } else {
460  if (bUseCrystalSize == true) {
461  fDeltaRVetoEndcapPhotons = 0.00864 * std::abs(sinh(refSC->position().eta())) * fNumberOfCrystalEndcapPhotons;
462  }
463 
464  if (bDeltaRVetoEndcap) {
466  return -999.;
467  }
468  if (bRectangleVetoEndcap) {
471  return -999.;
472  }
473  }
474  }
475 
476  return fDeltaR;
477 }
478 
479 //--------------------------------------------------------------------------------------------------
481  fDeltaR = deltaR(fEta, fPhi, pfIsoCand->eta(), pfIsoCand->phi());
482 
483  if (fDeltaR > fConeSize)
484  return -999;
485 
486  fDeltaPhi = deltaPhi(fPhi, pfIsoCand->phi());
487  fDeltaEta = fEta - pfIsoCand->eta();
488 
489  if (!bApplyVeto)
490  return fDeltaR;
491 
492  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
493  // this will be changed in the future
494  if (pivotInBarrel) {
496  return fDeltaR;
497  }
498 
499  if (bDeltaRVetoBarrel) {
501  return -999.;
502  }
503  if (bRectangleVetoBarrel) {
506  return -999.;
507  }
508  }
509 
510  } else {
512  return fDeltaR;
513  }
514  if (bDeltaRVetoEndcap) {
516  return -999.;
517  }
518  if (bRectangleVetoEndcap) {
521  return -999.;
522  }
523  }
524  }
525 
526  return fDeltaR;
527 }
528 
529 //----------------------------------------------------------------------------------------------------
532  //need code to handle special conditions
533 
534  return -999;
535 }
536 
537 //-----------------------------------------------------------------------------------------------------
539  reco::VertexRef vtxMain,
542  if (vtx.isNull())
543  return -999.;
544 
545  // float fVtxMainX = (*vtxMain).x();
546  // float fVtxMainY = (*vtxMain).y();
547  float fVtxMainZ = (*vtxMain).z();
548 
549  if (bApplyPFPUVeto) {
550  if (vtx != vtxMain)
551  return -999.;
552  }
553 
554  if (bApplyDzDxyVeto) {
555  if (iParticleType == kPhoton) {
556  float dz = std::abs(pfIsoCand->trackRef()->dz((*vtxMain).position()));
557  if (dz > 0.2)
558  return -999.;
559 
560  double dxy = pfIsoCand->trackRef()->dxy((*vtxMain).position());
561  if (std::abs(dxy) > 0.1)
562  return -999.;
563 
564  /*
565  float dz = std::abs(vtx->z() - fVtxMainZ);
566  if (dz > 1.)
567  return -999.;
568 
569 
570  double dxy = ( -(vtx->x() - fVtxMainX)*pfIsoCand->py() + (vtx->y() - fVtxMainY)*pfIsoCand->px()) / pfIsoCand->pt();
571 
572  if(std::abs(dxy) > 0.2)
573  return -999.;
574  */
575  } else {
576  float dz = std::abs(vtx->z() - fVtxMainZ);
577  if (dz > 1.)
578  return -999.;
579 
580  double dxy = (-(vtx->x() - fVx) * pfIsoCand->py() + (vtx->y() - fVy) * pfIsoCand->px()) / pfIsoCand->pt();
581  if (std::abs(dxy) > 0.1)
582  return -999.;
583  }
584  }
585 
586  fDeltaR = deltaR(pfIsoCand->eta(), pfIsoCand->phi(), fEta, fPhi);
587 
588  if (fDeltaR > fConeSize)
589  return -999.;
590 
591  fDeltaPhi = deltaPhi(fPhi, pfIsoCand->phi());
592  fDeltaEta = fEta - pfIsoCand->eta();
593 
594  // std::cout << " charged hadron: DR " << fDeltaR
595  // << " pt " << pfIsoCand->pt() << " eta,phi " << pfIsoCand->eta() << ", " << pfIsoCand->phi()
596  // << " fVtxMainZ " << (*vtxMain).z() << " cand z " << vtx->z() << std::endl;
597 
598  if (!bApplyVeto)
599  return fDeltaR;
600 
601  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
602  // this will be changed in the future
603  if (pivotInBarrel) {
605  return fDeltaR;
606  }
607 
608  if (bDeltaRVetoBarrel) {
610  return -999.;
611  }
612  if (bRectangleVetoBarrel) {
615  return -999.;
616  }
617  }
618 
619  } else {
621  return fDeltaR;
622  }
623  if (bDeltaRVetoEndcap) {
625  return -999.;
626  }
627  if (bRectangleVetoEndcap) {
630  return -999.;
631  }
632  }
633  }
634 
635  return fDeltaR;
636 }
637 
638 //--------------------------------------------------------------------------------------------------
640  const reco::PFCandidate& pfcand) {
641  //code copied from Florian's PFNoPU class
642 
643  reco::TrackBaseRef trackBaseRef(pfcand.trackRef());
644 
645  size_t iVertex = 0;
646  unsigned index = 0;
647  unsigned nFoundVertex = 0;
648 
649  float bestweight = 0;
650 
651  const reco::VertexCollection& vertices = *(verticesColl.product());
652 
653  for (reco::VertexCollection::const_iterator iv = vertices.begin(); iv != vertices.end(); ++iv, ++index) {
654  const reco::Vertex& vtx = *iv;
655 
656  // loop on tracks in vertices
657  for (reco::Vertex::trackRef_iterator iTrack = vtx.tracks_begin(); iTrack != vtx.tracks_end(); ++iTrack) {
658  const reco::TrackBaseRef& baseRef = *iTrack;
659 
660  // one of the tracks in the vertex is the same as
661  // the track considered in the function
662  if (baseRef == trackBaseRef) {
663  float w = vtx.trackWeight(baseRef);
664  //select the vertex for which the track has the highest weight
665  if (w > bestweight) {
666  bestweight = w;
667  iVertex = index;
668  nFoundVertex++;
669  }
670  }
671  }
672  }
673 
674  if (nFoundVertex > 0) {
675  if (nFoundVertex != 1)
676  edm::LogWarning("TrackOnTwoVertex") << "a track is shared by at least two verteces. Used to be an assert";
677  return reco::VertexRef(verticesColl, iVertex);
678  }
679  // no vertex found with this track.
680 
681  // optional: as a secondary solution, associate the closest vertex in z
682  if (checkClosestZVertex) {
683  double dzmin = 10000.;
684  double ztrack = pfcand.vertex().z();
685  bool foundVertex = false;
686  index = 0;
687  for (reco::VertexCollection::const_iterator iv = vertices.begin(); iv != vertices.end(); ++iv, ++index) {
688  double dz = std::abs(ztrack - iv->z());
689  if (dz < dzmin) {
690  dzmin = dz;
691  iVertex = index;
692  foundVertex = true;
693  }
694  }
695 
696  if (foundVertex)
697  return reco::VertexRef(verticesColl, iVertex);
698  }
699 
700  return reco::VertexRef();
701 }
702 
704  Int_t iMatch = -1;
705 
706  int i = 0;
707  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
708  const reco::PFCandidate& pfParticle = (*iPF);
709  // if((((pfParticle.pdgId()==22 && pfParticle.mva_nothing_gamma()>0.01) || TMath::Abs(pfParticle.pdgId())==11) )){
710  if ((((pfParticle.pdgId() == 22) || TMath::Abs(pfParticle.pdgId()) == 11))) {
711  if (pfParticle.superClusterRef() == photon->superCluster())
712  iMatch = i;
713  }
714 
715  i++;
716  }
717 
718  /*
719  if(iMatch == -1){
720  i=0;
721  float fPt = -1;
722  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
723  const reco::PFCandidate& pfParticle = (*iPF);
724  if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
725  if(pfParticle.pt()>fPt){
726  fDeltaR = deltaR(pfParticle.eta(),pfParticle.phi(),photon->eta(),photon->phi());
727  if(fDeltaR<0.1){
728  iMatch = i;
729  fPt = pfParticle.pt();
730  }
731  }
732  }
733  i++;
734  }
735  }
736 */
737 
738  return iMatch;
739 }
740 
742  const reco::PFCandidateCollection* Candidates) {
743  Int_t iMatch = -1;
744 
745  int i = 0;
746  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
747  const reco::PFCandidate& pfParticle = (*iPF);
748  // if((((pfParticle.pdgId()==22 && pfParticle.mva_nothing_gamma()>0.01) || TMath::Abs(pfParticle.pdgId())==11) )){
749  if ((((pfParticle.pdgId() == 22) || TMath::Abs(pfParticle.pdgId()) == 11))) {
750  if (pfParticle.superClusterRef() == electron->superCluster())
751  iMatch = i;
752  }
753 
754  i++;
755  }
756 
757  if (iMatch == -1) {
758  i = 0;
759  float fPt = -1;
760  for (reco::PFCandidateCollection::const_iterator iPF = Candidates->begin(); iPF != Candidates->end(); iPF++) {
761  const reco::PFCandidate& pfParticle = (*iPF);
762  if ((((pfParticle.pdgId() == 22) || TMath::Abs(pfParticle.pdgId()) == 11))) {
763  if (pfParticle.pt() > fPt) {
764  fDeltaR = deltaR(pfParticle.eta(), pfParticle.phi(), electron->eta(), electron->phi());
765  if (fDeltaR < 0.1) {
766  iMatch = i;
767  fPt = pfParticle.pt();
768  }
769  }
770  }
771  i++;
772  }
773  }
774 
775  return iMatch;
776 }
void setRectangleVetoEndcap(Bool_t bValue=kTRUE)
void setDeltaRVetoBarrel(Bool_t bValue=kTRUE)
std::vector< float > fIsolationInRings
std::vector< float > fIsolationInRingsChargedAll
void setNumberOfCrystalEndcapPhotons(float fValue=-1)
void setDeltaRVetoEndcap(Bool_t bValue=kTRUE)
double pt() const final
transverse momentum
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:335
void setRectangleDeltaPhiVetoBarrelPhotons(float fValue=-1.0)
void setApplyMissHitPhVeto(Bool_t bValue=kFALSE)
T w() const
std::vector< float > fGetIsolationInRings(const reco::PFCandidate *pfCandidate, const reco::PFCandidateCollection *pfParticlesColl, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
float isChargedParticleVetoed(const reco::PFCandidate *pfIsoCand, edm::Handle< reco::VertexCollection > vertices)
void setApplyDzDxyVeto(Bool_t bValue=kTRUE)
reco::VertexRef chargedHadronVertex(edm::Handle< reco::VertexCollection > verticies, const reco::PFCandidate &pfcand)
T const * product() const
Definition: Handle.h:70
double vy() const override
y coordinate of vertex position
Definition: PFCandidate.h:417
void setNumbersOfRings(int iValue=1)
void setDeltaRVetoBarrelNeutrals(float fValue=-1.0)
void setDeltaRVetoEndcapNeutrals(float fValue=-1.0)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:388
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
void setDeltaRVetoBarrelCharged(float fValue=-1.0)
float isPhotonParticleVetoed(const reco::PFCandidate *pfIsoCand)
void initialize(Bool_t bApplyVeto, int iParticleType)
void setDeltaRVetoEndcapPhotons(float fValue=-1.0)
void setApplyPFPUVeto(Bool_t bValue=kFALSE)
void setRectangleVetoBarrel(Bool_t bValue=kTRUE)
void setRectangleDeltaEtaVetoBarrelNeutrals(float fValue=-1.0)
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
int pdgId() const final
PDG identifier.
double px() const final
x coordinate of momentum vector
void setUseCrystalSize(Bool_t bValue=kFALSE)
void setParticleType(int iValue)
std::vector< float > fIsolationInRingsPhoton
void setRectangleDeltaPhiVetoBarrelCharged(float fValue=-1.0)
int matchPFObject(const reco::Photon *photon, const reco::PFCandidateCollection *pfParticlesColl)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setRectangleDeltaPhiVetoEndcapNeutrals(float fValue=-1.0)
void setRectangleDeltaPhiVetoBarrelNeutrals(float fValue=-1.0)
void setRectangleDeltaEtaVetoBarrelCharged(float fValue=-1.0)
std::vector< float > fIsolationInRingsCharged
float isNeutralParticleVetoed(const reco::PFCandidate *pfIsoCand)
void initializeRings(int iNumberOfRings, float fRingSize)
double py() const final
y coordinate of momentum vector
void setDeltaRVetoBarrelPhotons(float fValue=-1.0)
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
reco::SuperClusterRef refSC
void initializeElectronIsolation(Bool_t bApplyVeto)
void setRectangleDeltaPhiVetoEndcapCharged(float fValue=-1.0)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void setRectangleDeltaEtaVetoEndcapCharged(float fValue=-1.0)
void setRectangleDeltaEtaVetoEndcapPhotons(float fValue=-1.0)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
void setDeltaRVetoEndcapCharged(float fValue=-1.0)
void setApplyVeto(Bool_t bValue=kTRUE)
void initializeElectronIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize)
void setRingSize(float fValue=0.4)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
void initializePhotonIsolation(Bool_t bApplyVeto)
void setRectangleDeltaPhiVetoEndcapPhotons(float fValue=-1.0)
float fGetIsolation(const reco::PFCandidate *pfCandidate, const reco::PFCandidateCollection *pfParticlesColl, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:437
std::vector< float > fIsolationInRingsNeutral
void setRectangleDeltaEtaVetoBarrelPhotons(float fValue=-1.0)
double vz() const override
z coordinate of vertex position
Definition: PFCandidate.h:418
Log< level::Warning, false > LogWarning
void setRectangleDeltaEtaVetoEndcapNeutrals(float fValue=-1.0)
void setConeSize(float fValue=0.4)
double phi() const final
momentum azimuthal angle
double vx() const override
x coordinate of vertex position
Definition: PFCandidate.h:416
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:587
void initializePhotonIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize)
double eta() const final
momentum pseudorapidity