CMS 3D CMS Logo

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