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 
129  ESHandle<MagneticField> magneticField;
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 
437  const HitPattern& p_inner = el_track->trackerExpectedHitsInner();
438 
439  hww.els_exp_innerlayers().push_back(p_inner.numberOfHits());
440 
441 
443  // Conversions //
445 
446  ConversionFinder convFinder; //vector of conversion infos - all the candidate conversion tracks
447  vector<ConversionInfo> v_convInfos = convFinder.getConversionInfos(*(el->core()), tracks_h, gsftracks_h, evt_bField);
448 
449  vector<int> v_tkidx;
450  vector<int> v_gsftkidx;
451  vector<int> v_delmisshits;
452  vector<int> v_flag;
453  vector<float> v_dist;
454  vector<float> v_dcot;
455  vector<float> v_rad;
456  vector<LorentzVector> v_pos_p4;
457 
458  for(unsigned int i_conv = 0; i_conv < v_convInfos.size(); i_conv++) {
459 
460  math::XYZPoint convPoint = v_convInfos.at(i_conv).pointOfConversion();
461  float convPointX = isfinite(convPoint.x()) ? convPoint.x() : -9999.;
462  float convPointY = isfinite(convPoint.y()) ? convPoint.y() : -9999.;
463  float convPointZ = isfinite(convPoint.z()) ? convPoint.z() : -9999.;
464 
465  v_dist .push_back( isfinite(v_convInfos.at(i_conv).dist()) ? v_convInfos.at(i_conv).dist() : -9999. );
466  v_dcot .push_back( v_convInfos.at(i_conv).dcot() );
467  v_rad .push_back( v_convInfos.at(i_conv).radiusOfConversion() );
468  v_delmisshits .push_back( v_convInfos.at(i_conv).deltaMissingHits() );
469  v_flag .push_back( v_convInfos.at(i_conv).flag() );
470  v_pos_p4 .push_back( LorentzVector(convPointX, convPointY, convPointZ, 0) );
471 
472  if( v_convInfos.at(i_conv).conversionPartnerCtfTk().isNonnull() ) {
473  v_tkidx.push_back(v_convInfos.at(i_conv).conversionPartnerCtfTk().key());
474  }
475  else {
476  v_tkidx.push_back(-9999);
477  }
478 
479  //
480  if( v_convInfos.at(i_conv).conversionPartnerGsfTk().isNonnull() ) {
481  v_gsftkidx.push_back(v_convInfos.at(i_conv).conversionPartnerGsfTk().key());
482  }
483  else {
484  v_gsftkidx.push_back(-9999);
485  }
486 
487  } // end for loop
488 
489 
490  ConversionInfo convInfo = convFinder.getConversionInfo( *el, tracks_h, gsftracks_h, evt_bField );
491 
492  hww.els_conv_dist().push_back( isfinite(convInfo.dist()) ? convInfo.dist() : -9999. );
493  hww.els_conv_dcot().push_back( convInfo.dcot() );
494 
495 
497  // Flag For Vertex Fit Conversion Rejection //
499 
501  iEvent.getByToken(ConversionCollection_, convs_h);
502 
503 
505  // Old Conversion Rejection //
507 
508  hww.els_conv_old_dist() . push_back( isfinite(el->convDist()) ? el->convDist() : -9999. );
509  hww.els_conv_old_dcot() . push_back( isfinite(el->convDcot()) ? el->convDcot() : -9999. );
510 
511 
513  // 2012 Electron ID //
515 
516  GsfElectronRef ele(els_coll_h, elsIndex);
517 
518  } // end Loop on Electrons
519 
520 }
521 
522 
523 double ElectronMaker::electronIsoValuePF(const GsfElectron& el, const Vertex& vtx, float coner, float minptn, float dzcut,
524  float footprintdr, float gammastripveto, float elestripveto, int filterId){
525 
526  float pfciso = 0.;
527  float pfniso = 0.;
528  float pffootprint = 0.;
529  float pfjurveto = 0.;
530  float pfjurvetoq = 0.;
531 
532  TrackRef siTrack = el.closestTrack();
533  GsfTrackRef gsfTrack = el.gsfTrack();
534 
535  if (gsfTrack.isNull() && siTrack.isNull()) return -9999.;
536 
537  float eldz = gsfTrack.isNonnull() ? gsfTrack->dz(vtx.position()) : siTrack->dz(vtx.position());
538  float eleta = el.eta();
539 
540  for (PFCandidateCollection::const_iterator pf=pfCand_h->begin(); pf<pfCand_h->end(); ++pf){
541 
542  float pfeta = pf->eta();
543  float dR = deltaR(pfeta, pf->phi(), eleta, el.phi());
544  if (dR>coner) continue;
545 
546  float deta = fabs(pfeta - eleta);
547  int pfid = abs(pf->pdgId());
548  float pfpt = pf->pt();
549 
550  if (filterId!=0 && filterId!=pfid) continue;
551 
552  if (pf->charge()==0) {
553  //neutrals
554  if (pfpt>minptn) {
555  pfniso+=pfpt;
556  if (dR<footprintdr && pfid==130) pffootprint+=pfpt;
557  if (deta<gammastripveto && pfid==22) pfjurveto+=pfpt;
558  }
559  } else {
560  //charged
561  //avoid double counting of electron itself
562  //if either the gsf or the ctf track are shared with the candidate, skip it
563  const TrackRef pfTrack = pf->trackRef();
564  if (siTrack.isNonnull() && pfTrack.isNonnull() && siTrack.key()==pfTrack.key()) continue;
565  //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
566  if (/*pfid==11 &&*/ pf->gsfTrackRef().isNonnull()) {
567  if (gsfTrack.isNonnull() && gsfTrack.key()==pf->gsfTrackRef().key()) continue;
568  }
569  //check electrons with gsf track
570  if (pfid==11 && pf->gsfTrackRef().isNonnull()) {
571  if(fabs(pf->gsfTrackRef()->dz(vtx.position()) - eldz )<dzcut) {//dz cut
572  pfciso+=pfpt;
573  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
574  }
575  continue;//and avoid double counting
576  }
577  //then check anything that has a ctf track
578  if (pfTrack.isNonnull()) {//charged (with a ctf track)
579  if(fabs( pfTrack->dz(vtx.position()) - eldz )<dzcut) {//dz cut
580  pfciso+=pfpt;
581  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
582  }
583  }
584  }
585  }
586  return pfciso+pfniso-pffootprint-pfjurveto-pfjurvetoq;
587 }
588 
589 
591  const int vertexIndex, const float &R, float &pfiso_ch, float &pfiso_em, float &pfiso_nh)
592 {
593 
594  // isolation sums
595  pfiso_ch = 0.0;
596  pfiso_em = 0.0;
597  pfiso_nh = 0.0;
598 
599  // loop on pfcandidates
600  reco::PFCandidateCollection::const_iterator pf = pfCand_h->begin();
601  for (pf = pfCand_h->begin(); pf != pfCand_h->end(); ++pf) {
602 
603  // skip electrons and muons
604  if (pf->particleId() == reco::PFCandidate::e) continue;
605  if (pf->particleId() == reco::PFCandidate::mu) continue;
606 
607  // deltaR between electron and cadidate
608  const float dR = deltaR(pf->eta(), pf->phi(), el.eta(), el.phi());
609  if (dR > R) continue;
610 
611  PFPileUpAlgo *pfPileUpAlgo_ = new PFPileUpAlgo();
612 
613  if (pf->particleId() == reco::PFCandidate::h) {
614  int pfVertexIndex = pfPileUpAlgo_->chargedHadronVertex(*vertexCollection, *pf);
615  if (pfVertexIndex != vertexIndex) continue;
616  }
617 
618  // endcap region
619  if (!el.isEB()) {
620  if (pf->particleId() == reco::PFCandidate::h && dR <= 0.015) continue;
621  if (pf->particleId() == reco::PFCandidate::gamma && dR <= 0.08) continue;
622  }
623 
624  // add to isolation sum
625  if (pf->particleId() == reco::PFCandidate::h) pfiso_ch += pf->pt();
626  if (pf->particleId() == reco::PFCandidate::gamma) pfiso_em += pf->pt();
627  if (pf->particleId() == reco::PFCandidate::h0) pfiso_nh += pf->pt();
628 
629  }
630 
631 }
632 
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:127
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
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
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:121
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:434
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
virtual float phi() const
momentum azimuthal angle
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:10
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
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:131
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
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:347
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
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void Load_els_trk_charge()
Definition: HWW.cc:1061
int iEvent
Definition: GenABIO.cc:230
bool isNull() const
Checks for null.
Definition: Ref.h:247
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:105
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:107
virtual float eta() const
momentum pseudorapidity
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
int numberOfHits() const
Definition: HitPattern.cc:211
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
const HitPattern & trackerExpectedHitsInner() const
Access the hit pattern counting (in the Tracker) the number of expected crossed layers before the fir...
Definition: TrackBase.h:223
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
std::vector< float > & els_eSCPresh()
Definition: HWW.cc:213
Definition: HWW.h:11
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
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:125
void Load_els_iso04_pf2012_nh()
Definition: HWW.cc:1016
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:145
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
void Load_els_iso04_pf_gamma05()
Definition: HWW.cc:971
void Load_els_fiduciality()
Definition: HWW.cc:1055
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
key_type key() const
Accessor for product key.
Definition: Ref.h:266
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
T const * product() const
Definition: Handle.h:81
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
list key
Definition: combine.py:13
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:111
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:119
void Load_els_conv_dcot()
Definition: HWW.cc:1001
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:133
void Load_els_chi2()
Definition: HWW.cc:932
std::vector< LorentzVector > & els_trk_p4()
Definition: HWW.cc:105
math::PtEtaPhiELorentzVectorF LorentzVector
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