CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
688 
689  reco::TrackBaseRef trackBaseRef( pfcand.trackRef() );
690 
691  size_t iVertex = 0;
692  unsigned index=0;
693  unsigned nFoundVertex = 0;
694 
695  float bestweight=0;
696 
697  const reco::VertexCollection& vertices = *(verticesColl.product());
698 
699  for( reco::VertexCollection::const_iterator iv=vertices.begin(); iv!=vertices.end(); ++iv, ++index) {
700 
701  const reco::Vertex& vtx = *iv;
702 
703  // loop on tracks in vertices
704  for(reco::Vertex::trackRef_iterator iTrack=vtx.tracks_begin();iTrack!=vtx.tracks_end(); ++iTrack) {
705  const reco::TrackBaseRef& baseRef = *iTrack;
706 
707  // one of the tracks in the vertex is the same as
708  // the track considered in the function
709  if(baseRef == trackBaseRef ) {
710  float w = vtx.trackWeight(baseRef);
711  //select the vertex for which the track has the highest weight
712  if (w > bestweight){
713  bestweight=w;
714  iVertex=index;
715  nFoundVertex++;
716  }
717  }
718  }
719 
720  }
721 
722 
723 
724  if (nFoundVertex>0){
725  if (nFoundVertex!=1)
726  edm::LogWarning("TrackOnTwoVertex")<<"a track is shared by at least two verteces. Used to be an assert";
727  return reco::VertexRef( verticesColl, iVertex);
728  }
729  // no vertex found with this track.
730 
731  // optional: as a secondary solution, associate the closest vertex in z
732  if ( bCheckClosestZVertex_ ) {
733 
734  double dzmin = 10000.;
735  double ztrack = pfcand.vertex().z();
736  bool foundVertex = false;
737  index = 0;
738  for( reco::VertexCollection::const_iterator iv=vertices.begin(); iv!=vertices.end(); ++iv, ++index) {
739 
740  double dz = std::fabs(ztrack - iv->z());
741  if(dz<dzmin) {
742  dzmin = dz;
743  iVertex = index;
744  foundVertex = true;
745  }
746  }
747 
748  if( foundVertex )
749  return reco::VertexRef( verticesColl, iVertex);
750 
751  }
752 
753  return reco::VertexRef( );
754 }
755 
756 
757 
759 
760  Int_t iMatch = -1;
761 
762  int i=0;
763  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
764  const reco::PFCandidate& pfParticle = (*iPF);
765  if((((pfParticle.pdgId()==22 ) || std::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 ) || std::abs(pfParticle.pdgId())==11) )){
811 
812  if(pfParticle.superClusterRef()==electron->superCluster())
813  iMatch= i;
814 
815  }
816 
817  i++;
818  }
819 
820  if(iMatch == -1){
821  i=0;
822  float fPt = -1;
823  for(reco::PFCandidateCollection::const_iterator iPF=Candidates->begin();iPF !=Candidates->end();iPF++){
824  const reco::PFCandidate& pfParticle = (*iPF);
825  if((((pfParticle.pdgId()==22 ) || std::abs(pfParticle.pdgId())==11) )){
826  if(pfParticle.pt()>fPt){
827  float fDeltaR = deltaR(pfParticle.eta(),pfParticle.phi(),electron->eta(),electron->phi());
828  if(fDeltaR<0.1){
829  iMatch = i;
830  fPt = pfParticle.pt();
831  }
832  }
833  }
834  i++;
835  }
836  }
837 
838  return iMatch;
839 
840 }
841 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
float isNeutralParticleVetoed(const reco::PFCandidate *pfIsoCand)
int matchPFObject(const reco::Photon *photon, const reco::PFCandidateCollection *pfParticlesColl)
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
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:314
virtual int pdgId() const GCC11_FINAL
PDG identifier.
std::vector< float > fIsolationInRingsCharged_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:58
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
void setup(const edm::ParameterSet &conf)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:429
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
bool isNull() const
Checks for null.
Definition: Ref.h:247
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
T sqrt(T t)
Definition: SSEVec.h:48
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:169
std::vector< float > fIsolationInRingsChargedAll_
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:643
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
tuple conf
Definition: dbtoconf.py:185
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T const * product() const
Definition: Handle.h:81
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
std::vector< float > fIsolationInRingsNeutral_
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
float fGetIsolation(const reco::Photon *photon, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
T w() const
float isPhotonParticleVetoed(const reco::PFCandidateRef pfIsoCand)
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
void initializeRings(int iNumberOfRings, float fRingSize)
float isChargedParticleVetoed(const reco::PFCandidate *pfIsoCand, edm::Handle< reco::VertexCollection > vertices)
virtual float pt() const GCC11_FINAL
transverse momentum
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:596