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 }
reco::PFCandidate::trackRef
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
PFIsolationEstimator::fRectangleDeltaPhiVetoBarrelCharged
float fRectangleDeltaPhiVetoBarrelCharged
Definition: PFIsolationEstimator.h:214
PFIsolationEstimator::kElectron
Definition: PFIsolationEstimator.h:57
PFIsolationEstimator::setNumberOfCrystalEndcapPhotons
void setNumberOfCrystalEndcapPhotons(float fValue=-1)
Definition: PFIsolationEstimator.h:120
PFIsolationEstimator::fIsolationInRingsNeutral
std::vector< float > fIsolationInRingsNeutral
Definition: PFIsolationEstimator.h:184
PFIsolationEstimator::fRectangleDeltaPhiVetoEndcapNeutrals
float fRectangleDeltaPhiVetoEndcapNeutrals
Definition: PFIsolationEstimator.h:217
reco::PFCandidate::vy
double vy() const override
y coordinate of vertex position
Definition: PFCandidate.h:392
mps_fire.i
i
Definition: mps_fire.py:428
PFIsolationEstimator::fIsolationInRingsPhoton
std::vector< float > fIsolationInRingsPhoton
Definition: PFIsolationEstimator.h:183
PFIsolationEstimator::setRectangleDeltaPhiVetoBarrelNeutrals
void setRectangleDeltaPhiVetoBarrelNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:123
PFIsolationEstimator::fRectangleDeltaEtaVetoEndcapPhotons
float fRectangleDeltaEtaVetoEndcapPhotons
Definition: PFIsolationEstimator.h:224
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PFIsolationEstimator::refSC
reco::SuperClusterRef refSC
Definition: PFIsolationEstimator.h:247
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PFIsolationEstimator::setRingSize
void setRingSize(float fValue=0.4)
Definition: PFIsolationEstimator.h:164
PFIsolationEstimator::initializePhotonIsolation
void initializePhotonIsolation(Bool_t bApplyVeto)
Definition: PFIsolationEstimator.cc:134
PFIsolationEstimator::fIsolationInRingsChargedAll
std::vector< float > fIsolationInRingsChargedAll
Definition: PFIsolationEstimator.h:186
PFCandidate.h
PFIsolationEstimator::fVx
float fVx
Definition: PFIsolationEstimator.h:243
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
PFIsolationEstimator::setRectangleDeltaEtaVetoBarrelNeutrals
void setRectangleDeltaEtaVetoBarrelNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:130
PFIsolationEstimator::setDeltaRVetoEndcapNeutrals
void setDeltaRVetoEndcapNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:118
reco::PFCandidate::positionAtECALEntrance
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:363
PFIsolationEstimator::fRingSize
float fRingSize
Definition: PFIsolationEstimator.h:231
PFIsolationEstimator::setParticleType
void setParticleType(int iValue)
Definition: PFIsolationEstimator.h:99
PFIsolationEstimator::setRectangleDeltaPhiVetoEndcapPhotons
void setRectangleDeltaPhiVetoEndcapPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:125
reco::PFCandidate::vz
double vz() const override
z coordinate of vertex position
Definition: PFCandidate.h:393
PFIsolationEstimator::fVz
float fVz
Definition: PFIsolationEstimator.h:245
PFIsolationEstimator::bUseCrystalSize
Bool_t bUseCrystalSize
Definition: PFIsolationEstimator.h:194
PFIsolationEstimator::setRectangleDeltaEtaVetoEndcapCharged
void setRectangleDeltaEtaVetoEndcapCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:134
PFIsolationEstimator::setConeSize
void setConeSize(float fValue=0.4)
Definition: PFIsolationEstimator.h:97
EcalClusterLazyTools.h
PFIsolationEstimator::bApplyDzDxyVeto
Bool_t bApplyDzDxyVeto
Definition: PFIsolationEstimator.h:191
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
PFIsolationEstimator::setRectangleDeltaEtaVetoEndcapNeutrals
void setRectangleDeltaEtaVetoEndcapNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:133
PFIsolationEstimator::fDeltaRVetoBarrelCharged
float fDeltaRVetoBarrelCharged
Definition: PFIsolationEstimator.h:204
PFIsolationEstimator::initializeElectronIsolation
void initializeElectronIsolation(Bool_t bApplyVeto)
Definition: PFIsolationEstimator.cc:119
edm::Handle< reco::VertexCollection >
PFIsolationEstimator::setRectangleDeltaEtaVetoBarrelPhotons
void setRectangleDeltaEtaVetoBarrelPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:129
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
PFIsolationEstimator::setRectangleVetoEndcap
void setRectangleVetoEndcap(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:109
PFIsolationEstimator::fDeltaEta
float fDeltaEta
Definition: PFIsolationEstimator.h:234
PFIsolationEstimator::fIsolationInRings
std::vector< float > fIsolationInRings
Definition: PFIsolationEstimator.h:182
PFIsolationEstimator::fDeltaRVetoEndcapNeutrals
float fDeltaRVetoEndcapNeutrals
Definition: PFIsolationEstimator.h:207
edm::Ref< VertexCollection >
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
PFIsolationEstimator::fDeltaRVetoEndcapPhotons
float fDeltaRVetoEndcapPhotons
Definition: PFIsolationEstimator.h:206
PFIsolationEstimator::fDeltaRVetoBarrelNeutrals
float fDeltaRVetoBarrelNeutrals
Definition: PFIsolationEstimator.h:203
PFIsolationEstimator::bRectangleVetoEndcap
Bool_t bRectangleVetoEndcap
Definition: PFIsolationEstimator.h:200
PFIsolationEstimator::initializeRings
void initializeRings(int iNumberOfRings, float fRingSize)
Definition: PFIsolationEstimator.cc:152
PFIsolationEstimator::chargedHadronVertex
reco::VertexRef chargedHadronVertex(edm::Handle< reco::VertexCollection > verticies, const reco::PFCandidate &pfcand)
Definition: PFIsolationEstimator.cc:639
PFIsolationEstimator::fGetIsolationInRings
std::vector< float > fGetIsolationInRings(const reco::PFCandidate *pfCandidate, const reco::PFCandidateCollection *pfParticlesColl, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
Definition: PFIsolationEstimator.cc:190
PFIsolationEstimator::setUseCrystalSize
void setUseCrystalSize(Bool_t bValue=kFALSE)
Definition: PFIsolationEstimator.h:111
PFIsolationEstimator::setRectangleDeltaEtaVetoEndcapPhotons
void setRectangleDeltaEtaVetoEndcapPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:132
Track.h
PFIsolationEstimator::setRectangleDeltaPhiVetoEndcapNeutrals
void setRectangleDeltaPhiVetoEndcapNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:126
TrackFwd.h
Abs
T Abs(T a)
Definition: MathUtil.h:49
PFIsolationEstimator::fRectangleDeltaEtaVetoEndcapNeutrals
float fRectangleDeltaEtaVetoEndcapNeutrals
Definition: PFIsolationEstimator.h:225
PFIsolationEstimator::PFIsolationEstimator
PFIsolationEstimator()
Definition: PFIsolationEstimator.cc:24
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
PFIsolationEstimator::bDeltaRVetoEndcap
Bool_t bDeltaRVetoEndcap
Definition: PFIsolationEstimator.h:197
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
PFIsolationEstimator::setDeltaRVetoBarrelPhotons
void setDeltaRVetoBarrelPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:114
w
const double w
Definition: UKUtility.cc:23
PFIsolationEstimator::checkClosestZVertex
Bool_t checkClosestZVertex
Definition: PFIsolationEstimator.h:188
PFIsolationEstimator::setNumbersOfRings
void setNumbersOfRings(int iValue=1)
Definition: PFIsolationEstimator.h:163
PFIsolationEstimator::fDeltaPhi
float fDeltaPhi
Definition: PFIsolationEstimator.h:235
reco::SuperClusterRef
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Definition: SuperClusterFwd.h:15
metsig::electron
Definition: SignAlgoResolutions.h:48
PFIsolationEstimator::setApplyDzDxyVeto
void setApplyDzDxyVeto(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:104
PFIsolationEstimator::fVy
float fVy
Definition: PFIsolationEstimator.h:244
PFIsolationEstimator::isPhotonParticleVetoed
float isPhotonParticleVetoed(const reco::PFCandidate *pfIsoCand)
Definition: PFIsolationEstimator.cc:422
reco::GsfElectron
Definition: GsfElectron.h:35
PFIsolationEstimator::setApplyPFPUVeto
void setApplyPFPUVeto(Bool_t bValue=kFALSE)
Definition: PFIsolationEstimator.h:103
GsfElectron.h
PFIsolationEstimator::setDeltaRVetoBarrelCharged
void setDeltaRVetoBarrelCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:116
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
Vertex.h
PFIsolationEstimator::fNumberOfCrystalEndcapPhotons
float fNumberOfCrystalEndcapPhotons
Definition: PFIsolationEstimator.h:210
PFIsolationEstimator::fEta
float fEta
Definition: PFIsolationEstimator.h:237
TransientTrackBuilder.h
PFIsolationEstimator::bApplyVeto
Bool_t bApplyVeto
Definition: PFIsolationEstimator.h:190
PFIsolationEstimator::setDeltaRVetoEndcapCharged
void setDeltaRVetoEndcapCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:119
PFIsolationEstimator::fRectangleDeltaEtaVetoBarrelPhotons
float fRectangleDeltaEtaVetoBarrelPhotons
Definition: PFIsolationEstimator.h:220
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
PFIsolationEstimator::fDeltaRVetoBarrelPhotons
float fDeltaRVetoBarrelPhotons
Definition: PFIsolationEstimator.h:202
deltaR.h
PFIsolationEstimator::fConeSize
float fConeSize
Definition: PFIsolationEstimator.h:189
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
PFIsolationEstimator.h
PFIsolationEstimator::fIsolation
float fIsolation
Definition: PFIsolationEstimator.h:176
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::VertexRef
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
PFIsolationEstimator::fDeltaR
float fDeltaR
Definition: PFIsolationEstimator.h:233
PFIsolationEstimator::fGetIsolation
float fGetIsolation(const reco::PFCandidate *pfCandidate, const reco::PFCandidateCollection *pfParticlesColl, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
Definition: PFIsolationEstimator.cc:178
createfilelist.int
int
Definition: createfilelist.py:10
PFIsolationEstimator::initializePhotonIsolationInRings
void initializePhotonIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize)
Definition: PFIsolationEstimator.cc:146
RefToPtr.h
GsfTrack.h
PFIsolationEstimator::iParticleType
int iParticleType
Definition: PFIsolationEstimator.h:173
reco::PFCandidate::superClusterRef
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:558
PFIsolationEstimator::fRectangleDeltaEtaVetoBarrelCharged
float fRectangleDeltaEtaVetoBarrelCharged
Definition: PFIsolationEstimator.h:222
PFIsolationEstimator::initializeElectronIsolationInRings
void initializeElectronIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize)
Definition: PFIsolationEstimator.cc:140
PFIsolationEstimator::setRectangleDeltaPhiVetoBarrelPhotons
void setRectangleDeltaPhiVetoBarrelPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:122
PFIsolationEstimator::iMissHits
int iMissHits
Definition: PFIsolationEstimator.h:229
PFIsolationEstimator::initialize
void initialize(Bool_t bApplyVeto, int iParticleType)
Definition: PFIsolationEstimator.cc:32
PFIsolationEstimator::fRectangleDeltaPhiVetoBarrelPhotons
float fRectangleDeltaPhiVetoBarrelPhotons
Definition: PFIsolationEstimator.h:212
PFIsolationEstimator::fDeltaRVetoEndcapCharged
float fDeltaRVetoEndcapCharged
Definition: PFIsolationEstimator.h:208
PFIsolationEstimator::kPhoton
Definition: PFIsolationEstimator.h:58
PFIsolationEstimator::pivotInBarrel
bool pivotInBarrel
Definition: PFIsolationEstimator.h:248
reco::Photon
Definition: Photon.h:21
PFIsolationEstimator::bRectangleVetoBarrel
Bool_t bRectangleVetoBarrel
Definition: PFIsolationEstimator.h:199
PFIsolationEstimator::setRectangleVetoBarrel
void setRectangleVetoBarrel(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:108
PFIsolationEstimator::bApplyMissHitPhVeto
Bool_t bApplyMissHitPhVeto
Definition: PFIsolationEstimator.h:193
PFIsolationEstimator::setApplyVeto
void setApplyVeto(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:102
PFIsolationEstimator::fIsolationInRingsCharged
std::vector< float > fIsolationInRingsCharged
Definition: PFIsolationEstimator.h:185
PFIsolationEstimator::setRectangleDeltaPhiVetoBarrelCharged
void setRectangleDeltaPhiVetoBarrelCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:124
IPTools.h
PFIsolationEstimator::fRectangleDeltaPhiVetoBarrelNeutrals
float fRectangleDeltaPhiVetoBarrelNeutrals
Definition: PFIsolationEstimator.h:213
GsfTrackFwd.h
PFIsolationEstimator::setRectangleDeltaPhiVetoEndcapCharged
void setRectangleDeltaPhiVetoEndcapCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:127
PVValHelper::dxy
Definition: PVValidationHelpers.h:47
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
PVValHelper::dz
Definition: PVValidationHelpers.h:50
PFIsolationEstimator::fRectangleDeltaPhiVetoEndcapPhotons
float fRectangleDeltaPhiVetoEndcapPhotons
Definition: PFIsolationEstimator.h:216
PFIsolationEstimator::fRectangleDeltaEtaVetoEndcapCharged
float fRectangleDeltaEtaVetoEndcapCharged
Definition: PFIsolationEstimator.h:226
SuperCluster.h
PFIsolationEstimator::setApplyMissHitPhVeto
void setApplyMissHitPhVeto(Bool_t bValue=kFALSE)
Definition: PFIsolationEstimator.h:105
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
PFIsolationEstimator::~PFIsolationEstimator
~PFIsolationEstimator()
Definition: PFIsolationEstimator.cc:29
reco::PFCandidate::mva_nothing_gamma
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:335
PFIsolationEstimator::setDeltaRVetoEndcapPhotons
void setDeltaRVetoEndcapPhotons(float fValue=-1.0)
Definition: PFIsolationEstimator.h:117
PFIsolationEstimator::setDeltaRVetoBarrel
void setDeltaRVetoBarrel(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:106
edm::RefToBase< reco::Track >
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
PFIsolationEstimator::setRectangleDeltaEtaVetoBarrelCharged
void setRectangleDeltaEtaVetoBarrelCharged(float fValue=-1.0)
Definition: PFIsolationEstimator.h:131
PFIsolationEstimator::fPt
float fPt
Definition: PFIsolationEstimator.h:242
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
PFIsolationEstimator::isChargedParticleVetoed
float isChargedParticleVetoed(const reco::PFCandidate *pfIsoCand, edm::Handle< reco::VertexCollection > vertices)
Definition: PFIsolationEstimator.cc:530
PFIsolationEstimator::matchPFObject
int matchPFObject(const reco::Photon *photon, const reco::PFCandidateCollection *pfParticlesColl)
Definition: PFIsolationEstimator.cc:703
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PFIsolationEstimator::fRectangleDeltaEtaVetoBarrelNeutrals
float fRectangleDeltaEtaVetoBarrelNeutrals
Definition: PFIsolationEstimator.h:221
PFIsolationEstimator::isNeutralParticleVetoed
float isNeutralParticleVetoed(const reco::PFCandidate *pfIsoCand)
Definition: PFIsolationEstimator.cc:480
PFIsolationEstimator::setDeltaRVetoEndcap
void setDeltaRVetoEndcap(Bool_t bValue=kTRUE)
Definition: PFIsolationEstimator.h:107
PFIsolationEstimator::bApplyPFPUVeto
Bool_t bApplyPFPUVeto
Definition: PFIsolationEstimator.h:192
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
PFIsolationEstimator::bDeltaRVetoBarrel
Bool_t bDeltaRVetoBarrel
Definition: PFIsolationEstimator.h:196
PFIsolationEstimator::fRectangleDeltaPhiVetoEndcapCharged
float fRectangleDeltaPhiVetoEndcapCharged
Definition: PFIsolationEstimator.h:218
reco::PFCandidate::vx
double vx() const override
x coordinate of vertex position
Definition: PFCandidate.h:391
reco::Vertex
Definition: Vertex.h:35
PFIsolationEstimator::fPhi
float fPhi
Definition: PFIsolationEstimator.h:238
PFCandidateFwd.h
PFIsolationEstimator::iNumberOfRings
int iNumberOfRings
Definition: PFIsolationEstimator.h:228
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
PFIsolationEstimator::setDeltaRVetoBarrelNeutrals
void setDeltaRVetoBarrelNeutrals(float fValue=-1.0)
Definition: PFIsolationEstimator.h:115