CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerIsolationPt.cc
Go to the documentation of this file.
1 //
2 // $Id: TrackerIsolationPt.cc,v 1.6 2010/02/11 00:13:22 wmtan Exp $
3 //
4 
10 #include "CLHEP/Vector/LorentzVector.h"
17 #include <vector>
18 
19 using namespace pat;
20 
23 }
24 
27 }
28 
30 float TrackerIsolationPt::calculate(const Electron & theElectron, const edm::View<reco::Track> & theTracks, float isoConeElectron) const {
31  return this->calculate(*theElectron.gsfTrack(), theTracks, isoConeElectron);
32 }
33 
34 float TrackerIsolationPt::calculate(const Muon & theMuon, const edm::View<reco::Track> & theTracks, float isoConeMuon) const {
35  return this->calculate(*theMuon.track(), theTracks, isoConeMuon);
36 }
37 
39 float TrackerIsolationPt::calculate(const reco::Track & theTrack, const edm::View<reco::Track> & theTracks, float isoCone) const {
40  // initialize some variables
41  float isoPtLepton = 0;
42  const reco::Track * closestTrackDRPt = 0, * closestTrackDR = 0;
43  float closestDRPt = 10000, closestDR = 10000;
44  // use all these pointless vector conversions because the momenta from tracks
45  // are completely unusable; bah, these math-vectors are worthless!
46  CLHEP::HepLorentzVector lepton(theTrack.px(), theTrack.py(), theTrack.pz(), theTrack.p());
47  for (edm::View<reco::Track>::const_iterator itTrack = theTracks.begin(); itTrack != theTracks.end(); itTrack++) {
48  CLHEP::HepLorentzVector track(itTrack->px(), itTrack->py(), itTrack->pz(), itTrack->p());
49  float dR = lepton.deltaR(track);
50  if (dR < isoCone) {
51  isoPtLepton += track.perp();
52  // find the closest matching track
53  // FIXME: we could association by hits or chi2 to match
54  float pRatio = track.perp()/lepton.perp();
55  if (dR < closestDRPt && pRatio > 0.5 && pRatio < 1.5) {
56  closestDRPt = dR;
57  closestTrackDRPt = &*itTrack;
58  }
59  if (dR < closestDR) {
60  closestDR = dR;
61  closestTrackDR = &*itTrack;
62  }
63  }
64  }
65  if (closestTrackDRPt) {
66  GlobalVector closestTrackVector(closestTrackDRPt->px(), closestTrackDRPt->py(), closestTrackDRPt->pz());
67  isoPtLepton -= closestTrackVector.perp();
68  } else if (closestTrackDR) {
69  GlobalVector closestTrackVector(closestTrackDR->px(), closestTrackDR->py(), closestTrackDR->pz());
70  isoPtLepton -= closestTrackVector.perp();
71  }
72  // back to normal sum - S.L. 30/10/2007
73  if (isoPtLepton<0) isoPtLepton = 0;
74  // isoPtLepton <= 0.01 ? isoPtLepton = -1 : isoPtLepton = log(isoPtLepton);
75  return isoPtLepton;
76 }
77 
double p() const
momentum vector magnitude
Definition: TrackBase.h:129
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
T perp() const
Definition: PV3DBase.h:72
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:131
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
virtual ~TrackerIsolationPt()
destructor
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
Analysis-level electron class.
Definition: Electron.h:52
float calculate(const Electron &theElectron, const edm::View< reco::Track > &theTracks, float isoConeElectron=0.3) const
calculate the TrackIsoPt for the lepton object
const_iterator begin() const
const_iterator end() const
Analysis-level muon class.
Definition: Muon.h:51
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:142
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135