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 //--------------------------------------------------------------------------------------------------
25 fisInitialized(kFALSE)
26 {
27  // Constructor.
28 }
29 
30 
31 
32 //--------------------------------------------------------------------------------------------------
34 {
35 
36 }
37 
38 //--------------------------------------------------------------------------------------------------
40 
41  setParticleType(iParticleType);
42 
43  //By default check for an option vertex association
44  checkClosestZVertex = kTRUE;
45 
46  //Apply vetoes
47  setApplyVeto(bApplyVeto);
48 
55 
56 
63 
64 
71 
72 
73  if(bApplyVeto && iParticleType==kElectron){
74 
75  //Setup veto conditions for electrons
76  setDeltaRVetoBarrel(kTRUE);
77  setDeltaRVetoEndcap(kTRUE);
78  setRectangleVetoBarrel(kFALSE);
79  setRectangleVetoEndcap(kFALSE);
80  setApplyDzDxyVeto(kFALSE);
81  setApplyPFPUVeto(kTRUE);
82  setApplyMissHitPhVeto(kTRUE); //NOTE: decided to go for this on the 26May 2012
83  //Current recommended default value for the electrons
84  setUseCrystalSize(kFALSE);
85 
86  // setDeltaRVetoBarrelPhotons(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
87  // setDeltaRVetoBarrelCharged(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
88  // setDeltaRVetoBarrelNeutrals(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
91  // setDeltaRVetoEndcapNeutrals(1E-5); //NOTE: just to be in synch with the isoDep: fixed isoDep in 26May
92 
93  setConeSize(0.4);
94 
95 
96  }else{
97  //Setup veto conditions for photons
98  setApplyDzDxyVeto(kTRUE);
99  setApplyPFPUVeto(kTRUE);
100  setApplyMissHitPhVeto(kFALSE);
101  setDeltaRVetoBarrel(kTRUE);
102  setDeltaRVetoEndcap(kTRUE);
103  setRectangleVetoBarrel(kTRUE);
104  setRectangleVetoEndcap(kFALSE);
105  setUseCrystalSize(kTRUE);
106  setConeSize(0.3);
107 
117 
128  }
129 
130 
131 }
132 
133 //--------------------------------------------------------------------------------------------------
135  initialize(bApplyVeto,kElectron);
137 
138 // std::cout << " ********* Init Entering in kElectron setup "
139 // << " bApplyVeto " << bApplyVeto
140 // << " bDeltaRVetoBarrel " << bDeltaRVetoBarrel
141 // << " bDeltaRVetoEndcap " << bDeltaRVetoEndcap
142 // << " cone size " << fConeSize
143 // << " fDeltaRVetoEndcapPhotons " << fDeltaRVetoEndcapPhotons
144 // << " fDeltaRVetoEndcapNeutrals " << fDeltaRVetoEndcapNeutrals
145 // << " fDeltaRVetoEndcapCharged " << fDeltaRVetoEndcapCharged << std::endl;
146 
147 }
148 
149 //--------------------------------------------------------------------------------------------------
151  initialize(bApplyVeto,kPhoton);
153 }
154 
155 
156 //--------------------------------------------------------------------------------------------------
158  initialize(bApplyVeto,kElectron);
159  initializeRings(iNumberOfRings, fRingSize);
160 }
161 
162 //--------------------------------------------------------------------------------------------------
164  initialize(bApplyVeto,kPhoton);
165  initializeRings(iNumberOfRings, fRingSize);
166 }
167 
168 
169 //--------------------------------------------------------------------------------------------------
171 
172  setRingSize(fRingSize);
173  setNumbersOfRings(iNumberOfRings);
174 
175  fIsolationInRings.clear();
176  for(int isoBin =0;isoBin<iNumberOfRings;isoBin++){
177  float fTemp = 0.0;
178  fIsolationInRings.push_back(fTemp);
179 
180  float fTempPhoton = 0.0;
181  fIsolationInRingsPhoton.push_back(fTempPhoton);
182 
183  float fTempNeutral = 0.0;
184  fIsolationInRingsNeutral.push_back(fTempNeutral);
185 
186  float fTempCharged = 0.0;
187  fIsolationInRingsCharged.push_back(fTempCharged);
188 
189  float fTempChargedAll = 0.0;
190  fIsolationInRingsChargedAll.push_back(fTempChargedAll);
191 
192  }
193 
194  fConeSize = fRingSize * (float)iNumberOfRings;
195 
196 }
197 
198 
199 //--------------------------------------------------------------------------------------------------
201 
202  fGetIsolationInRings( pfCandidate, pfParticlesColl, vtx, vertices);
205 
206  return fIsolation;
207 }
208 
209 
210 //--------------------------------------------------------------------------------------------------
212 
213  int isoBin;
214 
215 
216  for(isoBin =0;isoBin<iNumberOfRings;isoBin++){
217  fIsolationInRings[isoBin]=0.;
218  fIsolationInRingsPhoton[isoBin]=0.;
219  fIsolationInRingsNeutral[isoBin]=0.;
220  fIsolationInRingsCharged[isoBin]=0.;
221  fIsolationInRingsChargedAll[isoBin]=0.;
222  }
223 
224 
225 
226  fEta = pfCandidate->eta();
227  fPhi = pfCandidate->phi();
228  fPt = pfCandidate->pt();
229  fVx = pfCandidate->vx();
230  fVy = pfCandidate->vy();
231  fVz = pfCandidate->vz();
232 
233  pivotInBarrel = std::abs(pfCandidate->positionAtECALEntrance().eta())<1.479;
234 
235  for(unsigned iPF=0; iPF<pfParticlesColl->size(); iPF++) {
236 
237  const reco::PFCandidate& pfParticle= (*pfParticlesColl)[iPF];
238 
239  if(&pfParticle==(pfCandidate))
240  continue;
241 
242  if(pfParticle.pdgId()==22){
243 
244  if(isPhotonParticleVetoed( &pfParticle)>=0.){
245  isoBin = (int)(fDeltaR/fRingSize);
246  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
247  }
248 
249  }else if(std::abs(pfParticle.pdgId())==130){
250 
251  if(isNeutralParticleVetoed( &pfParticle)>=0.){
252  isoBin = (int)(fDeltaR/fRingSize);
253  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
254  }
255 
256 
257  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
258  }else if(std::abs(pfParticle.pdgId()) == 211){
259  if(isChargedParticleVetoed( &pfParticle, vtx, vertices)>=0.){
260  isoBin = (int)(fDeltaR/fRingSize);
261  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
262  }
263 
264  }
265  }
266 
267 
268  for(int isoBin =0;isoBin<iNumberOfRings;isoBin++){
270  }
271 
272  return fIsolationInRings;
273 }
274 
275 
276 //--------------------------------------------------------------------------------------------------
278 
279  fGetIsolationInRings( photon, pfParticlesColl, vtx, vertices);
281 
282  return fIsolation;
283 }
284 
285 
286 //--------------------------------------------------------------------------------------------------
288 
289  int isoBin;
290 
291  for(isoBin =0;isoBin<iNumberOfRings;isoBin++){
292  fIsolationInRings[isoBin]=0.;
293  fIsolationInRingsPhoton[isoBin]=0.;
294  fIsolationInRingsNeutral[isoBin]=0.;
295  fIsolationInRingsCharged[isoBin]=0.;
296  fIsolationInRingsChargedAll[isoBin]=0.;
297  }
298 
299  iMissHits = 0;
300 
301  refSC = photon->superCluster();
302  pivotInBarrel = std::abs((refSC->position().eta()))<1.479;
303 
304  for(unsigned iPF=0; iPF<pfParticlesColl->size(); iPF++) {
305 
306  const reco::PFCandidate& pfParticle= (*pfParticlesColl)[iPF];
307 
308  if (pfParticle.superClusterRef().isNonnull() &&
309  photon->superCluster().isNonnull() &&
310  pfParticle.superClusterRef() == photon->superCluster())
311  continue;
312 
313  if(pfParticle.pdgId()==22){
314 
315  // Set the vertex of reco::Photon to the first PV
316  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle.vx(),
317  photon->superCluster()->y() - pfParticle.vy(),
318  photon->superCluster()->z() - pfParticle.vz());
319 
320  fEta = direction.Eta();
321  fPhi = direction.Phi();
322  fVx = pfParticle.vx();
323  fVy = pfParticle.vy();
324  fVz = pfParticle.vz();
325 
326  if(isPhotonParticleVetoed(&pfParticle)>=0.){
327  isoBin = (int)(fDeltaR/fRingSize);
328  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
329  }
330 
331  }else if(std::abs(pfParticle.pdgId())==130){
332 
333  // Set the vertex of reco::Photon to the first PV
334  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - pfParticle.vx(),
335  photon->superCluster()->y() - pfParticle.vy(),
336  photon->superCluster()->z() - pfParticle.vz());
337 
338  fEta = direction.Eta();
339  fPhi = direction.Phi();
340  fVx = pfParticle.vx();
341  fVy = pfParticle.vy();
342  fVz = pfParticle.vz();
343 
344  if(isNeutralParticleVetoed( &pfParticle)>=0.){
345  isoBin = (int)(fDeltaR/fRingSize);
346  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
347  }
348 
349  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
350  }else if(std::abs(pfParticle.pdgId()) == 211){
351 
352  // Set the vertex of reco::Photon to the first PV
353  math::XYZVector direction = math::XYZVector(photon->superCluster()->x() - (*vtx).x(),
354  photon->superCluster()->y() - (*vtx).y(),
355  photon->superCluster()->z() - (*vtx).z());
356 
357  fEta = direction.Eta();
358  fPhi = direction.Phi();
359  fVx = (*vtx).x();
360  fVy = (*vtx).y();
361  fVz = (*vtx).z();
362 
363  if(isChargedParticleVetoed( &pfParticle, vtx, vertices)>=0.){
364  isoBin = (int)(fDeltaR/fRingSize);
365  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
366  }
367 
368  }
369  }
370 
371 
372  for(int isoBin =0;isoBin<iNumberOfRings;isoBin++){
374  }
375 
376  return fIsolationInRings;
377 }
378 
379 
380 
381 //--------------------------------------------------------------------------------------------------
383 
384  fGetIsolationInRings( electron, pfParticlesColl, vtx, vertices);
386 
387  return fIsolation;
388 }
389 
390 
391 //--------------------------------------------------------------------------------------------------
393 
394  int isoBin;
395 
396  for(isoBin =0;isoBin<iNumberOfRings;isoBin++){
397  fIsolationInRings[isoBin]=0.;
398  fIsolationInRingsPhoton[isoBin]=0.;
399  fIsolationInRingsNeutral[isoBin]=0.;
400  fIsolationInRingsCharged[isoBin]=0.;
401  fIsolationInRingsChargedAll[isoBin]=0.;
402  }
403 
404  // int iMatch = matchPFObject(electron,pfParticlesColl);
405 
406 
407  fEta = electron->eta();
408  fPhi = electron->phi();
409  fPt = electron->pt();
410  fVx = electron->vx();
411  fVy = electron->vy();
412  fVz = electron->vz();
413  iMissHits = electron->gsfTrack()->hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS);
414 
415  // if(electron->ecalDrivenSeed())
416  refSC = electron->superCluster();
417  pivotInBarrel = std::abs((refSC->position().eta()))<1.479;
418 
419  for(unsigned iPF=0; iPF<pfParticlesColl->size(); iPF++) {
420 
421  const reco::PFCandidate& pfParticle= (*pfParticlesColl)[iPF];
422 
423 
424  if(pfParticle.pdgId()==22){
425 
426  if(isPhotonParticleVetoed(&pfParticle)>=0.){
427  isoBin = (int)(fDeltaR/fRingSize);
428  fIsolationInRingsPhoton[isoBin] = fIsolationInRingsPhoton[isoBin] + pfParticle.pt();
429 
430  }
431 
432  }else if(std::abs(pfParticle.pdgId())==130){
433 
434  if(isNeutralParticleVetoed( &pfParticle)>=0.){
435  isoBin = (int)(fDeltaR/fRingSize);
436  fIsolationInRingsNeutral[isoBin] = fIsolationInRingsNeutral[isoBin] + pfParticle.pt();
437  }
438 
439  //}else if(std::abs(pfParticle.pdgId()) == 11 ||abs(pfParticle.pdgId()) == 13 || std::abs(pfParticle.pdgId()) == 211){
440  }else if(std::abs(pfParticle.pdgId()) == 211){
441  if(isChargedParticleVetoed( &pfParticle, vtx, vertices)>=0.){
442  isoBin = (int)(fDeltaR/fRingSize);
443 
444  fIsolationInRingsCharged[isoBin] = fIsolationInRingsCharged[isoBin] + pfParticle.pt();
445  }
446 
447  }
448  }
449 
450 
451  for(int isoBin =0;isoBin<iNumberOfRings;isoBin++){
453  }
454 
455  return fIsolationInRings;
456 }
457 
458 
459 //--------------------------------------------------------------------------------------------------
461 
462 
463  fDeltaR = deltaR(fEta,fPhi,pfIsoCand->eta(),pfIsoCand->phi());
464 
465  if(fDeltaR > fConeSize)
466  return -999.;
467 
468  fDeltaPhi = deltaPhi(fPhi,pfIsoCand->phi());
469  fDeltaEta = fEta-pfIsoCand->eta();
470 
471  if(!bApplyVeto)
472  return fDeltaR;
473 
474  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
475  // this will be changed in the future
476 
477  if(bApplyMissHitPhVeto) {
478  if(iMissHits > 0)
479  if(pfIsoCand->mva_nothing_gamma() > 0.99) {
480  if(pfIsoCand->superClusterRef().isNonnull() && refSC.isNonnull()) {
481  if(pfIsoCand->superClusterRef() == refSC)
482  return -999.;
483  }
484  }
485  }
486 
487  if(pivotInBarrel){
488  if(bDeltaRVetoBarrel){
490  return -999.;
491  }
492 
495  return -999.;
496  }
497  }
498  }else{
499  if (bUseCrystalSize == true) {
500  fDeltaRVetoEndcapPhotons = 0.00864*std::abs(sinh(refSC->position().eta()))*fNumberOfCrystalEndcapPhotons;
501  }
502 
503  if(bDeltaRVetoEndcap){
505  return -999.;
506  }
509  return -999.;
510  }
511  }
512  }
513 
514  return fDeltaR;
515 }
516 
517 //--------------------------------------------------------------------------------------------------
519 
520  fDeltaR = deltaR(fEta,fPhi,pfIsoCand->eta(),pfIsoCand->phi());
521 
522  if(fDeltaR > fConeSize)
523  return -999;
524 
525  fDeltaPhi = deltaPhi(fPhi,pfIsoCand->phi());
526  fDeltaEta = fEta-pfIsoCand->eta();
527 
528  if(!bApplyVeto)
529  return fDeltaR;
530 
531  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
532  // this will be changed in the future
533  if(pivotInBarrel){
535  return fDeltaR;
536  }
537 
538  if(bDeltaRVetoBarrel){
540  return -999.;
541  }
544  return -999.;
545  }
546  }
547 
548  }else{
550  return fDeltaR;
551  }
552  if(bDeltaRVetoEndcap){
554  return -999.;
555  }
558  return -999.;
559  }
560  }
561  }
562 
563  return fDeltaR;
564 }
565 
566 
567 //----------------------------------------------------------------------------------------------------
569  //need code to handle special conditions
570 
571  return -999;
572 }
573 
574 //-----------------------------------------------------------------------------------------------------
576 
577  reco::VertexRef vtx = chargedHadronVertex(vertices, *pfIsoCand );
578  if(vtx.isNull())
579  return -999.;
580 
581 // float fVtxMainX = (*vtxMain).x();
582 // float fVtxMainY = (*vtxMain).y();
583  float fVtxMainZ = (*vtxMain).z();
584 
585  if(bApplyPFPUVeto) {
586  if(vtx != vtxMain)
587  return -999.;
588  }
589 
590 
591  if(bApplyDzDxyVeto) {
592  if(iParticleType==kPhoton){
593 
594  float dz = std::abs( pfIsoCand->trackRef()->dz( (*vtxMain).position() ) );
595  if (dz > 0.2)
596  return -999.;
597 
598  double dxy = pfIsoCand->trackRef()->dxy( (*vtxMain).position() );
599  if (std::abs(dxy) > 0.1)
600  return -999.;
601 
602  /*
603  float dz = std::abs(vtx->z() - fVtxMainZ);
604  if (dz > 1.)
605  return -999.;
606 
607 
608  double dxy = ( -(vtx->x() - fVtxMainX)*pfIsoCand->py() + (vtx->y() - fVtxMainY)*pfIsoCand->px()) / pfIsoCand->pt();
609 
610  if(std::abs(dxy) > 0.2)
611  return -999.;
612  */
613  }else{
614 
615 
616  float dz = std::abs(vtx->z() - fVtxMainZ);
617  if (dz > 1.)
618  return -999.;
619 
620  double dxy = ( -(vtx->x() - fVx)*pfIsoCand->py() + (vtx->y() - fVy)*pfIsoCand->px()) / pfIsoCand->pt();
621  if(std::abs(dxy) > 0.1)
622  return -999.;
623  }
624  }
625 
626  fDeltaR = deltaR(pfIsoCand->eta(),pfIsoCand->phi(),fEta,fPhi);
627 
628  if(fDeltaR > fConeSize)
629  return -999.;
630 
631  fDeltaPhi = deltaPhi(fPhi,pfIsoCand->phi());
632  fDeltaEta = fEta-pfIsoCand->eta();
633 
634 
635 // std::cout << " charged hadron: DR " << fDeltaR
636 // << " pt " << pfIsoCand->pt() << " eta,phi " << pfIsoCand->eta() << ", " << pfIsoCand->phi()
637 // << " fVtxMainZ " << (*vtxMain).z() << " cand z " << vtx->z() << std::endl;
638 
639 
640  if(!bApplyVeto)
641  return fDeltaR;
642 
643  //NOTE: get the direction for the EB/EE transition region from the deposit just to be in synch with the isoDep
644  // this will be changed in the future
645  if(pivotInBarrel){
647  return fDeltaR;
648  }
649 
650  if(bDeltaRVetoBarrel){
652  return -999.;
653  }
656  return -999.;
657  }
658  }
659 
660  }else{
662  return fDeltaR;
663  }
664  if(bDeltaRVetoEndcap){
666  return -999.;
667  }
670  return -999.;
671  }
672  }
673  }
674 
675 
676 
677 
678  return fDeltaR;
679 }
680 
681 
682 //--------------------------------------------------------------------------------------------------
684 
685  //code copied from Florian's PFNoPU class
686 
687  reco::TrackBaseRef trackBaseRef( pfcand.trackRef() );
688 
689  size_t iVertex = 0;
690  unsigned index=0;
691  unsigned nFoundVertex = 0;
692 
693  float bestweight=0;
694 
695  const reco::VertexCollection& vertices = *(verticesColl.product());
696 
697  for( reco::VertexCollection::const_iterator iv=vertices.begin(); iv!=vertices.end(); ++iv, ++index) {
698 
699  const reco::Vertex& vtx = *iv;
700 
701  // loop on tracks in vertices
702  for(reco::Vertex::trackRef_iterator iTrack=vtx.tracks_begin();iTrack!=vtx.tracks_end(); ++iTrack) {
703 
704  const reco::TrackBaseRef& baseRef = *iTrack;
705 
706  // one of the tracks in the vertex is the same as
707  // the track considered in the function
708  if(baseRef == trackBaseRef ) {
709  float w = vtx.trackWeight(baseRef);
710  //select the vertex for which the track has the highest weight
711  if (w > bestweight){
712  bestweight=w;
713  iVertex=index;
714  nFoundVertex++;
715  }
716  }
717  }
718 
719  }
720 
721 
722 
723  if (nFoundVertex>0){
724  if (nFoundVertex!=1)
725  edm::LogWarning("TrackOnTwoVertex")<<"a track is shared by at least two verteces. Used to be an assert";
726  return reco::VertexRef( verticesColl, iVertex);
727  }
728  // no vertex found with this track.
729 
730  // optional: as a secondary solution, associate the closest vertex in z
731  if ( checkClosestZVertex ) {
732 
733  double dzmin = 10000.;
734  double ztrack = pfcand.vertex().z();
735  bool foundVertex = false;
736  index = 0;
737  for( reco::VertexCollection::const_iterator iv=vertices.begin(); iv!=vertices.end(); ++iv, ++index) {
738 
739  double dz = std::abs(ztrack - iv->z());
740  if(dz<dzmin) {
741  dzmin = dz;
742  iVertex = index;
743  foundVertex = true;
744  }
745  }
746 
747  if( foundVertex )
748  return reco::VertexRef( verticesColl, iVertex);
749 
750  }
751 
752  return reco::VertexRef( );
753 }
754 
755 
756 
758 
759  Int_t iMatch = -1;
760 
761  int i=0;
762  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
763  const reco::PFCandidate& pfParticle = (*iPF);
764  // if((((pfParticle.pdgId()==22 && pfParticle.mva_nothing_gamma()>0.01) || TMath::Abs(pfParticle.pdgId())==11) )){
765  if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
766 
767  if(pfParticle.superClusterRef()==photon->superCluster())
768  iMatch= i;
769 
770  }
771 
772  i++;
773  }
774 
775 /*
776  if(iMatch == -1){
777  i=0;
778  float fPt = -1;
779  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
780  const reco::PFCandidate& pfParticle = (*iPF);
781  if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
782  if(pfParticle.pt()>fPt){
783  fDeltaR = deltaR(pfParticle.eta(),pfParticle.phi(),photon->eta(),photon->phi());
784  if(fDeltaR<0.1){
785  iMatch = i;
786  fPt = pfParticle.pt();
787  }
788  }
789  }
790  i++;
791  }
792  }
793 */
794 
795  return iMatch;
796 
797 }
798 
799 
800 
801 
802 
804 
805  Int_t iMatch = -1;
806 
807  int i=0;
808  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
809  const reco::PFCandidate& pfParticle = (*iPF);
810  // if((((pfParticle.pdgId()==22 && pfParticle.mva_nothing_gamma()>0.01) || TMath::Abs(pfParticle.pdgId())==11) )){
811  if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
812 
813  if(pfParticle.superClusterRef()==electron->superCluster())
814  iMatch= i;
815 
816  }
817 
818  i++;
819  }
820 
821  if(iMatch == -1){
822  i=0;
823  float fPt = -1;
824  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
825  const reco::PFCandidate& pfParticle = (*iPF);
826  if((((pfParticle.pdgId()==22 ) || TMath::Abs(pfParticle.pdgId())==11) )){
827  if(pfParticle.pt()>fPt){
828  fDeltaR = deltaR(pfParticle.eta(),pfParticle.phi(),electron->eta(),electron->phi());
829  if(fDeltaR<0.1){
830  iMatch = i;
831  fPt = pfParticle.pt();
832  }
833  }
834  }
835  i++;
836  }
837  }
838 
839  return iMatch;
840 
841 }
842 
void setRectangleVetoEndcap(Bool_t bValue=kTRUE)
void setDeltaRVetoBarrel(Bool_t bValue=kTRUE)
virtual double pt() const final
transverse momentum
std::vector< float > fIsolationInRingsNeutral
virtual double vz() const
z coordinate of vertex position
Definition: PFCandidate.h:415
std::vector< float > fIsolationInRingsPhoton
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
void setNumberOfCrystalEndcapPhotons(float fValue=-1)
void setDeltaRVetoEndcap(Bool_t bValue=kTRUE)
const double w
Definition: UKUtility.cc:23
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
void setRectangleDeltaPhiVetoBarrelPhotons(float fValue=-1.0)
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
void setApplyMissHitPhVeto(Bool_t bValue=kFALSE)
float mva_nothing_gamma() const
mva for gamma detection
Definition: PFCandidate.h:332
virtual double eta() const final
momentum pseudorapidity
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)
void setNumbersOfRings(int iValue=1)
void setDeltaRVetoBarrelNeutrals(float fValue=-1.0)
void setDeltaRVetoEndcapNeutrals(float fValue=-1.0)
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)
std::vector< float > fIsolationInRings
void setDeltaRVetoEndcapPhotons(float fValue=-1.0)
void setApplyPFPUVeto(Bool_t bValue=kFALSE)
void setRectangleVetoBarrel(Bool_t bValue=kTRUE)
virtual double vy() const
y coordinate of vertex position
void setRectangleDeltaEtaVetoBarrelNeutrals(float fValue=-1.0)
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:367
virtual double vx() const
x coordinate of vertex position
Definition: PFCandidate.h:413
std::vector< float > fIsolationInRingsChargedAll
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:438
virtual double phi() const final
momentum azimuthal angle
void setUseCrystalSize(Bool_t bValue=kFALSE)
void setParticleType(int iValue)
virtual double px() const final
x coordinate of momentum vector
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:184
void setRectangleDeltaPhiVetoBarrelCharged(float fValue=-1.0)
virtual int pdgId() const final
PDG identifier.
T Abs(T a)
Definition: MathUtil.h:49
int matchPFObject(const reco::Photon *photon, const reco::PFCandidateCollection *pfParticlesColl)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:652
void setRectangleDeltaPhiVetoEndcapNeutrals(float fValue=-1.0)
void setRectangleDeltaPhiVetoBarrelNeutrals(float fValue=-1.0)
void setRectangleDeltaEtaVetoBarrelCharged(float fValue=-1.0)
float isNeutralParticleVetoed(const reco::PFCandidate *pfIsoCand)
void initializeRings(int iNumberOfRings, float fRingSize)
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:81
std::vector< float > fIsolationInRingsCharged
virtual double vz() const
z coordinate of vertex position
void setDeltaRVetoBarrelPhotons(float fValue=-1.0)
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
reco::SuperClusterRef refSC
bool isNull() const
Checks for null.
Definition: Ref.h:250
void initializeElectronIsolation(Bool_t bApplyVeto)
void setRectangleDeltaPhiVetoEndcapCharged(float fValue=-1.0)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void setRectangleDeltaEtaVetoEndcapCharged(float fValue=-1.0)
T const * product() const
Definition: Handle.h:81
void setRectangleDeltaEtaVetoEndcapPhotons(float fValue=-1.0)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void setDeltaRVetoEndcapCharged(float fValue=-1.0)
virtual double vy() const
y coordinate of vertex position
Definition: PFCandidate.h:414
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:39
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
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)
virtual double vx() const
x coordinate of vertex position
void setRectangleDeltaEtaVetoBarrelPhotons(float fValue=-1.0)
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
void setRectangleDeltaEtaVetoEndcapNeutrals(float fValue=-1.0)
void setConeSize(float fValue=0.4)
virtual double py() const final
y coordinate of momentum vector
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:185
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:605
void initializePhotonIsolationInRings(Bool_t bApplyVeto, int iNumberOfRings, float fRingSize)