CMS 3D CMS Logo

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