CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronMaker.cc
Go to the documentation of this file.
11 
12 
13 using namespace reco;
14 using namespace edm;
15 using namespace std;
16 
19 
21 
22  TrackCollection_ = iCollector.consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackInputTag"));
23  GSFTrackCollection_ = iCollector.consumes<reco::GsfTrackCollection>(iConfig.getParameter<edm::InputTag>("gsftrksInputTag"));
24  GSFElectron_ = iCollector.consumes<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>("electronsInputTag"));
25  GSFElectronCollection_ = iCollector.consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronsInputTag"));
26  PFCandidateCollection_ = iCollector.consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsInputTag"));
27  thePVCollection_ = iCollector.consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertexInputTag"));
28  BeamSpot_ = iCollector.consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotTag"));
29  ConversionCollection_ = iCollector.consumes<reco::ConversionCollection>(iConfig.getParameter<edm::InputTag>("recoConversionInputTag"));
30  ClusterToken1_ = iCollector.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("cluster1InputTag"));
31  ClusterToken2_ = iCollector.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("cluster2InputTag"));
32 }
33 
34 
35 void ElectronMaker::SetVars(HWW& hww, const edm::Event& iEvent, const edm::EventSetup& iSetup) {
36 
38  hww.Load_els_type();
39  hww.Load_els_ecalEnergy();
40  hww.Load_els_trk_p4();
41  hww.Load_els_p4();
42  hww.Load_els_vertex_p4();
43  hww.Load_els_ecalIso();
44  hww.Load_els_hcalIso();
45  hww.Load_els_tkIso();
46  hww.Load_els_ecalIso04();
47  hww.Load_els_hcalIso04();
60  hww.Load_els_etaSC();
61  hww.Load_els_eSC();
62  hww.Load_els_eSCRaw();
63  hww.Load_els_eSCPresh();
64  hww.Load_els_nSeed();
65  hww.Load_els_e1x5();
66  hww.Load_els_e5x5();
68  hww.Load_els_etaSCwidth();
69  hww.Load_els_phiSCwidth();
71  hww.Load_els_e3x3();
72  hww.Load_els_hOverE();
73  hww.Load_els_eOverPIn();
76  hww.Load_els_eOverPOut();
77  hww.Load_els_fbrem();
78  hww.Load_els_dEtaIn();
79  hww.Load_els_dEtaOut();
80  hww.Load_els_dPhiIn();
81  hww.Load_els_dPhiOut();
82  hww.Load_els_chi2();
83  hww.Load_els_ndof();
84  hww.Load_els_gsftrkidx();
85  hww.Load_els_charge();
86  hww.Load_els_trk_charge();
87  hww.Load_els_sccharge();
88  hww.Load_els_d0();
89  hww.Load_els_d0corr();
90  hww.Load_els_z0corr();
91  hww.Load_els_trkidx();
92  hww.Load_els_trkshFrac();
93  hww.Load_els_ip3d();
94  hww.Load_els_ip3derr();
96  hww.Load_els_conv_dist();
97  hww.Load_els_conv_dcot();
100 
101  bool validToken;
102 
103  // access the tracker
104  edm::ESHandle<TrackerGeometry> theTrackerGeometry;
105  iSetup.get<TrackerDigiGeometryRecord>().get(theTrackerGeometry);
106 
108  // Get Tracks //
110 
111  Handle<TrackCollection> tracks_h;
112  validToken = iEvent.getByToken(TrackCollection_, tracks_h);
113  if(!validToken) return;
114 
115 
117  // GSF Tracks //
119 
120  Handle<GsfTrackCollection> gsftracks_h;
121  validToken = iEvent.getByToken(GSFTrackCollection_, gsftracks_h);
122  if(!validToken) return;
123 
124 
126  // B Field //
128 
130  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
131  float evt_bField = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
132 
133 
135  // Electrons //
137 
138  Handle<View<GsfElectron> > els_h;
139  //iEvent.getByToken(GSFElectron_, els_h);
140  validToken = iEvent.getByToken(GSFElectron_, els_h);
141  if(!validToken) return;
142  View<GsfElectron> gsfElColl = *(els_h.product());
143 
145  //iEvent.getByToken(GSFElectronCollection_, els_coll_h);
146  validToken = iEvent.getByToken(GSFElectronCollection_, els_coll_h);
147  if(!validToken) return;
148 
149 
151  // PF Cands //
153 
154  validToken = iEvent.getByToken(PFCandidateCollection_, pfCand_h);
155  if(!validToken) return;
156 
157 
159  // Vertex //
161 
163  validToken = iEvent.getByToken(thePVCollection_, vertexHandle);
164  if(!validToken) return;
165 
166 
168  // TransientTrackBuilder //
170 
171  ESHandle<TransientTrackBuilder> theTTBuilder;
172  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTBuilder);
173 
174 
176  // Get tools to get cluster shape information //
178  EcalClusterLazyTools clusterTools( iEvent, iSetup, ClusterToken1_, ClusterToken2_ );
179 
181  // Beamspot //
183 
184  Handle<reco::BeamSpot> beamspot_h;
185  validToken = iEvent.getByToken(BeamSpot_, beamspot_h);
186  if(!validToken) return;
187  const reco::BeamSpot &beamSpotreco = *(beamspot_h.product());
188 
189 
190 
191 
193  // Loop Over Electrons //
195 
196  double mass = 0.000510998918;
197  size_t elsIndex = 0;
198  for( View<GsfElectron>::const_iterator el = els_h->begin(); el != els_h->end(); el++, elsIndex++ ) {
199 
201  // References //
203 
204  const Track* el_track = (const Track*)(el->gsfTrack().get());
205  const RefToBase<GsfElectron> gsfElRef = els_h->refAt(elsIndex);
206  const TrackRef ctfTkRef = el->closestTrack();
207  const GsfTrackRef gsfTkRef = el->gsfTrack();
208  const VertexCollection* vertexCollection = vertexHandle.product();
209 
211  // Vertex //
213  VertexCollection::const_iterator firstGoodVertex = vertexCollection->end();
214  int firstGoodVertexIdx = 0;
215  for (VertexCollection::const_iterator vtx = vertexCollection->begin(); vtx != vertexCollection->end(); ++vtx, ++firstGoodVertexIdx) {
216  if ( !vtx->isFake() && vtx->ndof()>=4. && vtx->position().Rho()<=2.0 && fabs(vtx->position().Z())<=24.0) {
217  firstGoodVertex = vtx;
218  break;
219  }
220  }
221 
223  // Fiduciality Mask //
225 
226  int fiducialityMask = 0; // the enum is in interface/EgammaFiduciality.h
227  if ( el->isEB() ) fiducialityMask |= 1 << ISEB;
228  if ( el->isEBEEGap() ) fiducialityMask |= 1 << ISEBEEGAP;
229  if ( el->isEE() ) fiducialityMask |= 1 << ISEE;
230  if ( el->isEEGap() ) fiducialityMask |= 1 << ISEEGAP;
231  if ( el->isEBEtaGap() ) fiducialityMask |= 1 << ISEBETAGAP;
232  if ( el->isEBPhiGap() ) fiducialityMask |= 1 << ISEBPHIGAP;
233  if ( el->isEEDeeGap() ) fiducialityMask |= 1 << ISEEDEEGAP;
234  if ( el->isEERingGap() ) fiducialityMask |= 1 << ISEERINGGAP;
235  if ( el->isGap() ) fiducialityMask |= 1 << ISGAP;
236 
237 
239  // Corrections & Seeding //
241 
242  int electronTypeMask = 0;
243  if ( el->isEcalEnergyCorrected() ) electronTypeMask |= 1 << ISECALENERGYCORRECTED;
244  if ( el->trackerDrivenSeed() ) electronTypeMask |= 1 << ISTRACKERDRIVEN;
245  if ( el->ecalDrivenSeed() ) electronTypeMask |= 1 << ISECALDRIVEN;
246  if ( el->passingCutBasedPreselection() ) electronTypeMask |= 1 << ISCUTPRESELECTED;
247  if ( el->passingMvaPreselection() ) electronTypeMask |= 1 << ISMVAPRESELECTED;
248 
249 
251  // Lorentz Vectors //
253 
254  LorentzVector p4In;
255  LorentzVector p4Out;
256  LorentzVector trk_p4( el_track->px(), el_track->py(), el_track->pz(), el_track->p() );
257  math::XYZVectorF p3In = el->trackMomentumAtVtx();
258  math::XYZVectorF p3Out = el->trackMomentumOut();
259  p4In.SetXYZT ( p3In.x() , p3In.y() , p3In.z() , sqrt( mass*mass + p3In.R() *p3In.R() ) );
260  p4Out.SetXYZT( p3Out.x(), p3Out.y(), p3Out.z(), sqrt( mass*mass + p3Out.R()*p3Out.R() ) );
261 
262 
264  // Electron //
266 
267  hww.els_fiduciality() .push_back( fiducialityMask );
268  hww.els_type() .push_back( electronTypeMask );
269  hww.els_ecalEnergy() .push_back( el->correctedEcalEnergy() );
270  hww.els_p4() .push_back( LorentzVector( el->p4() ) );
271  hww.els_trk_p4() .push_back( trk_p4 );
272  hww.els_vertex_p4() .push_back( LorentzVector(el->vx(), el->vy(), el->vz(), 0.) );
273 
274 
276  // Isolation //
278 
279  hww.els_ecalIso() .push_back( el->dr03EcalRecHitSumEt() );
280  hww.els_hcalIso() .push_back( el->dr03HcalTowerSumEt() );
281  hww.els_tkIso() .push_back( el->dr03TkSumPt() );
282  hww.els_ecalIso04() .push_back( el->dr04EcalRecHitSumEt() );
283  hww.els_hcalIso04() .push_back( el->dr04HcalTowerSumEt() );
284 
285 
287  // PF Isolation //
289 
290  if ( firstGoodVertex!=vertexCollection->end() ) {
291 
292  hww.els_iso03_pf_ch() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.3, 99999., 0.1, 0.07, 0.025, 0.025, 0 ) );
293  hww.els_iso03_pf_gamma05() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.3, 0.5 , 0.1, 0.07, 0.025, 0.025, 22 ) );
294  hww.els_iso03_pf_nhad05() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.3, 0.5 , 0.1, 0.07, 0.025, 0.025, 130) );
295 
296  hww.els_iso04_pf_ch() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.4, 99999., 0.1, 0.07, 0.025, 0.025, 0 ) );
297  hww.els_iso04_pf_gamma05() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.4, 0.5 , 0.1, 0.07, 0.025, 0.025, 22 ) );
298  hww.els_iso04_pf_nhad05() .push_back( electronIsoValuePF( *el, *firstGoodVertex, 0.4, 0.5 , 0.1, 0.07, 0.025, 0.025, 130) );
299 
300 
301  // pf iso 2012
302  float pfiso_ch = 0.0;
303  float pfiso_em = 0.0;
304  float pfiso_nh = 0.0;
305 
306  PFIsolation2012(*el, vertexCollection, firstGoodVertexIdx, 0.3, pfiso_ch, pfiso_em, pfiso_nh);
307  hww.els_iso03_pf2012_ch() .push_back( pfiso_ch );
308  hww.els_iso03_pf2012_em() .push_back( pfiso_em );
309  hww.els_iso03_pf2012_nh() .push_back( pfiso_nh );
310 
311  PFIsolation2012(*el, vertexCollection, firstGoodVertexIdx, 0.4, pfiso_ch, pfiso_em, pfiso_nh);
312  hww.els_iso04_pf2012_ch() .push_back( pfiso_ch );
313  hww.els_iso04_pf2012_em() .push_back( pfiso_em );
314  hww.els_iso04_pf2012_nh() .push_back( pfiso_nh );
315 
316  } else {
317 
318  hww.els_iso03_pf_ch() .push_back( -9999. );
319  hww.els_iso03_pf_gamma05() .push_back( -9999. );
320  hww.els_iso03_pf_nhad05() .push_back( -9999. );
321 
322  hww.els_iso04_pf_ch() .push_back( -9999. );
323  hww.els_iso04_pf_gamma05() .push_back( -9999. );
324  hww.els_iso04_pf_nhad05() .push_back( -9999. );
325 
326  hww.els_iso03_pf2012_ch() .push_back( -9999. );
327  hww.els_iso03_pf2012_em() .push_back( -9999. );
328  hww.els_iso03_pf2012_nh() .push_back( -9999. );
329  hww.els_iso04_pf2012_ch() .push_back( -9999. );
330  hww.els_iso04_pf2012_em() .push_back( -9999. );
331  hww.els_iso04_pf2012_nh() .push_back( -9999. );
332  }
333 
335  // Supercluster //
337 
338  hww.els_etaSC() .push_back( el->superCluster()->eta() );
339  hww.els_eSC() .push_back( el->superCluster()->energy() );
340  hww.els_eSCRaw() .push_back( el->superCluster()->rawEnergy() );
341  hww.els_eSCPresh() .push_back( el->superCluster()->preshowerEnergy() );
342  hww.els_nSeed() .push_back( el->basicClustersSize() - 1 );
343  hww.els_e1x5() .push_back( el->e1x5() );
344  hww.els_e5x5() .push_back( el->e5x5() );
345  hww.els_sigmaIEtaIEta() .push_back( el->sigmaIetaIeta() );
346  hww.els_etaSCwidth() .push_back( el->superCluster()->etaWidth() );
347  hww.els_phiSCwidth() .push_back( el->superCluster()->phiWidth() );
348 
349 
351  // Get cluster info that is not stored in the object //
353 
354  if( el->superCluster()->seed().isAvailable() ) {
355 
356  const BasicCluster& clRef = *(el->superCluster()->seed());
357  const vector<float>& lcovs = clusterTools.localCovariances(clRef); // get the local covariances computed in a 5x5 around the seed
358  const vector<float> localCovariancesSC = clusterTools.scLocalCovariances(*(el->superCluster())); // get the local covariances computed using all crystals in the SC
359 
360  hww.els_sigmaIPhiIPhi() .push_back( isfinite(lcovs[2]) ? lcovs[2] > 0 ? sqrt(lcovs[2]) : -1 * sqrt(-1 * lcovs[2]) : -9999. );
361  hww.els_e3x3() .push_back( clusterTools.e3x3(clRef) );
362  }
363  else {
364 
365  hww.els_sigmaIPhiIPhi() .push_back(-9999.);
366  hww.els_e3x3() .push_back(-9999.);
367 
368  }
369 
370 
372  // ID //
374 
375  hww.els_hOverE() .push_back( el->hcalOverEcal() );
376  hww.els_eOverPIn() .push_back( el->eSuperClusterOverP() );
377  hww.els_eSeedOverPOut() .push_back( el->eSeedClusterOverPout() );
378  hww.els_eSeedOverPIn() .push_back( el->eSeedClusterOverP() );
379  hww.els_eOverPOut() .push_back( el->eEleClusterOverPout() );
380  hww.els_fbrem() .push_back( el->fbrem() );
381 
382  hww.els_dEtaIn() .push_back( el->deltaEtaSuperClusterTrackAtVtx() );
383  hww.els_dEtaOut() .push_back( el->deltaEtaSeedClusterTrackAtCalo() );
384  hww.els_dPhiIn() .push_back( el->deltaPhiSuperClusterTrackAtVtx() );
385  hww.els_dPhiOut() .push_back( el->deltaPhiSeedClusterTrackAtCalo() );
386 
388  // Tracks //
390 
391  hww.els_chi2() .push_back( el_track->chi2() );
392  hww.els_ndof() .push_back( el_track->ndof() );
393  hww.els_gsftrkidx() .push_back( static_cast<int>((el->gsfTrack()).key()) );
394  hww.els_charge() .push_back( el->charge() );
395  hww.els_trk_charge() .push_back( el_track->charge() );
396  hww.els_sccharge() .push_back( el->scPixCharge() );
397  hww.els_d0() .push_back( el_track->d0() );
398  hww.els_d0corr() .push_back( -1*(el_track->dxy(beamSpotreco)) );
399  hww.els_z0corr() .push_back( el_track->dz(beamSpotreco.position(el_track->vz())) );
400 
401 
403  // CTF //
405 
406  if( ctfTkRef.isNonnull() ) {
407  hww.els_trkidx() . push_back( static_cast<int> ( ctfTkRef.key() ) );
408  hww.els_trkshFrac() . push_back( static_cast<float>( el->ctfGsfOverlap() ) );
409  }
410  else {
411  hww.els_trkidx() . push_back(-9999.);
412  hww.els_trkshFrac() . push_back(-9999.);
413  }
414 
415 
417  // Regular Vertex //
419  TransientTrack tt = theTTBuilder->build(el->gsfTrack());
420 
421  if ( firstGoodVertex!=vertexCollection->end() ) {
422  Measurement1D ip3D_regular = IPTools::absoluteImpactParameter3D(tt, *firstGoodVertex).second;
423 
424  hww.els_ip3d() . push_back( ip3D_regular.value() );
425  hww.els_ip3derr() . push_back( ip3D_regular.error() );
426  } else {
427 
428  hww.els_ip3d() . push_back( -999. );
429  hww.els_ip3derr() . push_back( -999. );
430  }
431 
432 
434  // Hit Pattern //
436 
438 
439 
441  // Conversions //
443 
444  ConversionFinder convFinder; //vector of conversion infos - all the candidate conversion tracks
445  vector<ConversionInfo> v_convInfos = convFinder.getConversionInfos(*(el->core()), tracks_h, gsftracks_h, evt_bField);
446 
447  vector<int> v_tkidx;
448  vector<int> v_gsftkidx;
449  vector<int> v_delmisshits;
450  vector<int> v_flag;
451  vector<float> v_dist;
452  vector<float> v_dcot;
453  vector<float> v_rad;
454  vector<LorentzVector> v_pos_p4;
455 
456  for(unsigned int i_conv = 0; i_conv < v_convInfos.size(); i_conv++) {
457 
458  math::XYZPoint convPoint = v_convInfos.at(i_conv).pointOfConversion();
459  float convPointX = isfinite(convPoint.x()) ? convPoint.x() : -9999.;
460  float convPointY = isfinite(convPoint.y()) ? convPoint.y() : -9999.;
461  float convPointZ = isfinite(convPoint.z()) ? convPoint.z() : -9999.;
462 
463  v_dist .push_back( isfinite(v_convInfos.at(i_conv).dist()) ? v_convInfos.at(i_conv).dist() : -9999. );
464  v_dcot .push_back( v_convInfos.at(i_conv).dcot() );
465  v_rad .push_back( v_convInfos.at(i_conv).radiusOfConversion() );
466  v_delmisshits .push_back( v_convInfos.at(i_conv).deltaMissingHits() );
467  v_flag .push_back( v_convInfos.at(i_conv).flag() );
468  v_pos_p4 .push_back( LorentzVector(convPointX, convPointY, convPointZ, 0) );
469 
470  if( v_convInfos.at(i_conv).conversionPartnerCtfTk().isNonnull() ) {
471  v_tkidx.push_back(v_convInfos.at(i_conv).conversionPartnerCtfTk().key());
472  }
473  else {
474  v_tkidx.push_back(-9999);
475  }
476 
477  //
478  if( v_convInfos.at(i_conv).conversionPartnerGsfTk().isNonnull() ) {
479  v_gsftkidx.push_back(v_convInfos.at(i_conv).conversionPartnerGsfTk().key());
480  }
481  else {
482  v_gsftkidx.push_back(-9999);
483  }
484 
485  } // end for loop
486 
487 
488  ConversionInfo convInfo = convFinder.getConversionInfo( *el, tracks_h, gsftracks_h, evt_bField );
489 
490  hww.els_conv_dist().push_back( isfinite(convInfo.dist()) ? convInfo.dist() : -9999. );
491  hww.els_conv_dcot().push_back( convInfo.dcot() );
492 
493 
495  // Flag For Vertex Fit Conversion Rejection //
497 
499  iEvent.getByToken(ConversionCollection_, convs_h);
500 
501 
503  // Old Conversion Rejection //
505 
506  hww.els_conv_old_dist() . push_back( isfinite(el->convDist()) ? el->convDist() : -9999. );
507  hww.els_conv_old_dcot() . push_back( isfinite(el->convDcot()) ? el->convDcot() : -9999. );
508 
509 
511  // 2012 Electron ID //
513 
514  GsfElectronRef ele(els_coll_h, elsIndex);
515 
516  } // end Loop on Electrons
517 
518 }
519 
520 
521 double ElectronMaker::electronIsoValuePF(const GsfElectron& el, const Vertex& vtx, float coner, float minptn, float dzcut,
522  float footprintdr, float gammastripveto, float elestripveto, int filterId){
523 
524  float pfciso = 0.;
525  float pfniso = 0.;
526  float pffootprint = 0.;
527  float pfjurveto = 0.;
528  float pfjurvetoq = 0.;
529 
530  TrackRef siTrack = el.closestTrack();
531  GsfTrackRef gsfTrack = el.gsfTrack();
532 
533  if (gsfTrack.isNull() && siTrack.isNull()) return -9999.;
534 
535  float eldz = gsfTrack.isNonnull() ? gsfTrack->dz(vtx.position()) : siTrack->dz(vtx.position());
536  float eleta = el.eta();
537 
538  for (PFCandidateCollection::const_iterator pf=pfCand_h->begin(); pf<pfCand_h->end(); ++pf){
539 
540  float pfeta = pf->eta();
541  float dR = deltaR(pfeta, pf->phi(), eleta, el.phi());
542  if (dR>coner) continue;
543 
544  float deta = fabs(pfeta - eleta);
545  int pfid = abs(pf->pdgId());
546  float pfpt = pf->pt();
547 
548  if (filterId!=0 && filterId!=pfid) continue;
549 
550  if (pf->charge()==0) {
551  //neutrals
552  if (pfpt>minptn) {
553  pfniso+=pfpt;
554  if (dR<footprintdr && pfid==130) pffootprint+=pfpt;
555  if (deta<gammastripveto && pfid==22) pfjurveto+=pfpt;
556  }
557  } else {
558  //charged
559  //avoid double counting of electron itself
560  //if either the gsf or the ctf track are shared with the candidate, skip it
561  const TrackRef pfTrack = pf->trackRef();
562  if (siTrack.isNonnull() && pfTrack.isNonnull() && siTrack.key()==pfTrack.key()) continue;
563  //below pfid==1 is commented out: in some cases the pfCand has a gsf even if it is not an electron... this is to improve the sync with MIT
564  if (/*pfid==11 &&*/ pf->gsfTrackRef().isNonnull()) {
565  if (gsfTrack.isNonnull() && gsfTrack.key()==pf->gsfTrackRef().key()) continue;
566  }
567  //check electrons with gsf track
568  if (pfid==11 && pf->gsfTrackRef().isNonnull()) {
569  if(fabs(pf->gsfTrackRef()->dz(vtx.position()) - eldz )<dzcut) {//dz cut
570  pfciso+=pfpt;
571  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
572  }
573  continue;//and avoid double counting
574  }
575  //then check anything that has a ctf track
576  if (pfTrack.isNonnull()) {//charged (with a ctf track)
577  if(fabs( pfTrack->dz(vtx.position()) - eldz )<dzcut) {//dz cut
578  pfciso+=pfpt;
579  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
580  }
581  }
582  }
583  }
584  return pfciso+pfniso-pffootprint-pfjurveto-pfjurvetoq;
585 }
586 
587 
589  const int vertexIndex, const float &R, float &pfiso_ch, float &pfiso_em, float &pfiso_nh)
590 {
591 
592  // isolation sums
593  pfiso_ch = 0.0;
594  pfiso_em = 0.0;
595  pfiso_nh = 0.0;
596 
597  // loop on pfcandidates
598  reco::PFCandidateCollection::const_iterator pf = pfCand_h->begin();
599  for (pf = pfCand_h->begin(); pf != pfCand_h->end(); ++pf) {
600 
601  // skip electrons and muons
602  if (pf->particleId() == reco::PFCandidate::e) continue;
603  if (pf->particleId() == reco::PFCandidate::mu) continue;
604 
605  // deltaR between electron and cadidate
606  const float dR = deltaR(pf->eta(), pf->phi(), el.eta(), el.phi());
607  if (dR > R) continue;
608 
609  PFPileUpAlgo *pfPileUpAlgo_ = new PFPileUpAlgo();
610 
611  if (pf->particleId() == reco::PFCandidate::h) {
612  int pfVertexIndex = pfPileUpAlgo_->chargedHadronVertex(*vertexCollection, *pf);
613  if (pfVertexIndex != vertexIndex) continue;
614  }
615 
616  // endcap region
617  if (!el.isEB()) {
618  if (pf->particleId() == reco::PFCandidate::h && dR <= 0.015) continue;
619  if (pf->particleId() == reco::PFCandidate::gamma && dR <= 0.08) continue;
620  }
621 
622  // add to isolation sum
623  if (pf->particleId() == reco::PFCandidate::h) pfiso_ch += pf->pt();
624  if (pf->particleId() == reco::PFCandidate::gamma) pfiso_em += pf->pt();
625  if (pf->particleId() == reco::PFCandidate::h0) pfiso_nh += pf->pt();
626 
627  }
628 
629 }
630 
void Load_els_conv_old_dist()
Definition: HWW.cc:1004
std::vector< float > & els_ip3derr()
Definition: HWW.cc:181
double p() const
momentum vector magnitude
Definition: TrackBase.h:663
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< float > & els_iso03_pf2012_ch()
Definition: HWW.cc:301
std::vector< float > & els_iso04_pf_nhad05()
Definition: HWW.cc:233
T getParameter(std::string const &) const
void Load_els_e5x5()
Definition: HWW.cc:974
void Load_els_p4()
Definition: HWW.cc:869
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::vector< float > & els_conv_dcot()
Definition: HWW.cc:277
void Load_els_dPhiOut()
Definition: HWW.cc:941
void Load_els_ip3d()
Definition: HWW.cc:926
std::vector< float > & els_tkIso()
Definition: HWW.cc:137
std::vector< int > & els_exp_innerlayers()
Definition: HWW.cc:337
void Load_els_hOverE()
Definition: HWW.cc:893
void Load_els_e3x3()
Definition: HWW.cc:980
void Load_els_trk_p4()
Definition: HWW.cc:872
void Load_els_type()
Definition: HWW.cc:1052
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:645
std::vector< float > & els_e3x3()
Definition: HWW.cc:249
std::vector< float > & els_ndof()
Definition: HWW.cc:189
void Load_els_conv_old_dcot()
Definition: HWW.cc:1007
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void Load_els_sccharge()
Definition: HWW.cc:1058
void Load_els_ecalIso()
Definition: HWW.cc:989
void Load_els_trkidx()
Definition: HWW.cc:1049
std::vector< LorentzVector > & els_vertex_p4()
Definition: HWW.cc:109
void Load_els_nSeed()
Definition: HWW.cc:1034
std::vector< float > & els_hOverE()
Definition: HWW.cc:133
std::vector< float > & els_d0corr()
Definition: HWW.cc:141
tuple pfTrack
Definition: pfTrack_cfi.py:3
std::vector< float > & els_ecalEnergy()
Definition: HWW.cc:253
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
std::vector< int > & els_nSeed()
Definition: HWW.cc:321
std::vector< float > & els_d0()
Definition: HWW.cc:145
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
double dist() const
std::vector< float > & els_iso04_pf2012_nh()
Definition: HWW.cc:297
double error() const
Definition: Measurement1D.h:30
std::vector< float > & els_eOverPOut()
Definition: HWW.cc:257
std::vector< int > & els_sccharge()
Definition: HWW.cc:353
std::vector< float > & els_iso04_pf2012_em()
Definition: HWW.cc:293
void Load_els_fbrem()
Definition: HWW.cc:908
std::vector< float > & els_ip3d()
Definition: HWW.cc:177
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::vector< float > & els_fbrem()
Definition: HWW.cc:153
void Load_els_ip3derr()
Definition: HWW.cc:929
void Load_els_iso03_pf_ch()
Definition: HWW.cc:956
void Load_els_eOverPOut()
Definition: HWW.cc:986
void Load_els_eOverPIn()
Definition: HWW.cc:911
std::vector< float > & els_conv_dist()
Definition: HWW.cc:273
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
key_type key() const
Accessor for product key.
Definition: Ref.h:266
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:675
void Load_els_iso04_pf2012_em()
Definition: HWW.cc:1013
float electronIsoValuePF(HWW &, const unsigned int iel, unsigned int ivtx, float coner=0.4, float minptn=1.0, float dzcut=0.1, float footprintdr=0.07, float gammastripveto=0.025, float elestripveto=-999., int filterId=0)
void Load_els_eSeedOverPOut()
Definition: HWW.cc:914
std::pair< double, double > Point
Definition: CaloEllipse.h:18
void Load_els_ndof()
Definition: HWW.cc:935
const Point & position() const
position
Definition: Vertex.h:106
tuple vertexCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
virtual double eta() const
momentum pseudorapidity
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
std::vector< float > & els_iso04_pf2012_ch()
Definition: HWW.cc:289
bool isEB() const
Definition: GsfElectron.h:350
void Load_els_iso04_pf_nhad05()
Definition: HWW.cc:968
std::vector< int > & els_gsftrkidx()
Definition: HWW.cc:333
void Load_els_e1x5()
Definition: HWW.cc:977
std::vector< float > & els_iso03_pf2012_nh()
Definition: HWW.cc:309
std::vector< float > & els_eOverPIn()
Definition: HWW.cc:157
std::vector< float > & els_iso03_pf_ch()
Definition: HWW.cc:217
std::vector< float > & els_iso03_pf_gamma05()
Definition: HWW.cc:225
void Load_els_trk_charge()
Definition: HWW.cc:1061
int iEvent
Definition: GenABIO.cc:230
void Load_els_iso03_pf_nhad05()
Definition: HWW.cc:959
std::vector< int > & els_trk_charge()
Definition: HWW.cc:357
void Load_els_conv_dist()
Definition: HWW.cc:998
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:597
void Load_els_d0()
Definition: HWW.cc:902
std::vector< float > & els_ecalIso()
Definition: HWW.cc:261
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:603
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< float > & els_eSeedOverPOut()
Definition: HWW.cc:161
std::vector< float > & els_chi2()
Definition: HWW.cc:185
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
void Load_els_tkIso()
Definition: HWW.cc:896
void Load_els_exp_innerlayers()
Definition: HWW.cc:1046
void Load_els_eSC()
Definition: HWW.cc:923
void Load_els_trkshFrac()
Definition: HWW.cc:995
std::vector< float > & els_eSC()
Definition: HWW.cc:173
void Load_els_sigmaIEtaIEta()
Definition: HWW.cc:884
std::vector< float > & els_conv_old_dist()
Definition: HWW.cc:281
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void Load_els_etaSCwidth()
Definition: HWW.cc:947
std::vector< float > & els_dEtaOut()
Definition: HWW.cc:193
void Load_els_dPhiIn()
Definition: HWW.cc:890
void Load_els_hcalIso04()
Definition: HWW.cc:1031
void Load_els_eSCRaw()
Definition: HWW.cc:944
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
std::vector< float > & els_dPhiOut()
Definition: HWW.cc:197
std::vector< float > & els_hcalIso()
Definition: HWW.cc:265
std::vector< LorentzVector > & els_p4()
Definition: HWW.cc:101
std::vector< float > & els_etaSC()
Definition: HWW.cc:117
void Load_els_sigmaIPhiIPhi()
Definition: HWW.cc:920
bool isNull() const
Checks for null.
Definition: Ref.h:247
std::vector< float > & els_eSCPresh()
Definition: HWW.cc:213
Definition: HWW.h:12
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:687
std::vector< float > & els_iso03_pf_nhad05()
Definition: HWW.cc:221
void Load_els_iso03_pf2012_nh()
Definition: HWW.cc:1025
void Load_els_ecalIso04()
Definition: HWW.cc:1028
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
double electronIsoValuePF(const reco::GsfElectron &el, const reco::Vertex &vtx, float coner, float minptn, float dzcut, float footprintdr, float gammastripveto, float elestripveto, int filterId)
void Load_els_charge()
Definition: HWW.cc:1040
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:657
void Load_els_iso04_pf2012_nh()
Definition: HWW.cc:1016
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:717
std::vector< float > & els_iso04_pf_gamma05()
Definition: HWW.cc:237
void Load_els_z0corr()
Definition: HWW.cc:905
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< float > & els_e5x5()
Definition: HWW.cc:241
std::vector< float > & els_etaSCwidth()
Definition: HWW.cc:205
std::vector< float > & els_trkshFrac()
Definition: HWW.cc:269
void Load_els_eSCPresh()
Definition: HWW.cc:953
T const * product() const
Definition: Handle.h:81
void Load_els_iso04_pf_gamma05()
Definition: HWW.cc:971
void Load_els_fiduciality()
Definition: HWW.cc:1055
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:384
std::vector< float > & els_eSCRaw()
Definition: HWW.cc:201
std::vector< float > & els_ecalIso04()
Definition: HWW.cc:313
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void Load_els_hcalIso()
Definition: HWW.cc:992
std::vector< float > & els_conv_old_dcot()
Definition: HWW.cc:285
std::vector< int > & els_charge()
Definition: HWW.cc:329
const T & get() const
Definition: EventSetup.h:55
void Load_els_ecalEnergy()
Definition: HWW.cc:983
void Load_els_dEtaOut()
Definition: HWW.cc:938
std::vector< float > & els_hcalIso04()
Definition: HWW.cc:317
int chargedHadronVertex(const reco::VertexCollection &vertices, const reco::PFCandidate &pfcand) const
Definition: PFPileUpAlgo.cc:43
void Load_els_eSeedOverPIn()
Definition: HWW.cc:917
ElectronMaker(const edm::ParameterSet &, edm::ConsumesCollector)
double value() const
Definition: Measurement1D.h:28
std::vector< float > & els_dPhiIn()
Definition: HWW.cc:129
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
void Load_els_iso04_pf_ch()
Definition: HWW.cc:965
std::vector< int > & els_type()
Definition: HWW.cc:345
std::vector< float > & els_e1x5()
Definition: HWW.cc:245
std::vector< float > & els_iso04_pf_ch()
Definition: HWW.cc:229
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void Load_els_iso03_pf2012_em()
Definition: HWW.cc:1022
void Load_els_etaSC()
Definition: HWW.cc:881
void Load_els_iso04_pf2012_ch()
Definition: HWW.cc:1010
std::vector< float > & els_dEtaIn()
Definition: HWW.cc:125
int charge() const
track electric charge
Definition: TrackBase.h:615
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< float > & els_phiSCwidth()
Definition: HWW.cc:209
double dcot() const
std::vector< float > & els_iso03_pf2012_em()
Definition: HWW.cc:305
void Load_els_iso03_pf2012_ch()
Definition: HWW.cc:1019
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
std::vector< float > & els_eSeedOverPIn()
Definition: HWW.cc:165
void Load_els_vertex_p4()
Definition: HWW.cc:875
void Load_els_dEtaIn()
Definition: HWW.cc:887
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:639
void Load_els_conv_dcot()
Definition: HWW.cc:1001
virtual double phi() const
momentum azimuthal angle
std::vector< float > & els_sigmaIEtaIEta()
Definition: HWW.cc:121
void PFIsolation2012(const reco::GsfElectron &el, const reco::VertexCollection *vertexCollection, const int vertexIndex, const float &R, float &pfiso_ch, float &pfiso_em, float &pfiso_nh)
void Load_els_gsftrkidx()
Definition: HWW.cc:1043
void Load_els_d0corr()
Definition: HWW.cc:899
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:681
void Load_els_chi2()
Definition: HWW.cc:932
std::vector< LorentzVector > & els_trk_p4()
Definition: HWW.cc:105
math::PtEtaPhiELorentzVectorF LorentzVector
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:718
std::vector< float > & els_sigmaIPhiIPhi()
Definition: HWW.cc:169
virtual TrackRef closestTrack() const
Definition: GsfElectron.h:184
std::vector< int > & els_trkidx()
Definition: HWW.cc:341
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
std::vector< int > & els_fiduciality()
Definition: HWW.cc:349
std::vector< float > & els_z0corr()
Definition: HWW.cc:149
void Load_els_iso03_pf_gamma05()
Definition: HWW.cc:962
void Load_els_phiSCwidth()
Definition: HWW.cc:950