CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronTkIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: ElectronTkIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 //C++ includes
9 #include <vector>
10 #include <functional>
11 //ROOT includes
12 #include <Math/VectorUtil.h>
13 
14 //CMSSW includes
22 
23 using namespace ROOT::Math::VectorUtil ;
24 
25 
27  double intRadiusBarrel,
28  double intRadiusEndcap,
29  double stripBarrel,
30  double stripEndcap,
31  double ptLow,
32  double lip,
33  double drb,
34  const reco::TrackCollection* trackCollection,
35  reco::TrackBase::Point beamPoint,
36  const std::string &dzOptionString) :
37  extRadius_(extRadius),
38  intRadiusBarrel_(intRadiusBarrel),
39  intRadiusEndcap_(intRadiusEndcap),
40  stripBarrel_(stripBarrel),
41  stripEndcap_(stripEndcap),
42  ptLow_(ptLow),
43  lip_(lip),
44  drb_(drb),
45  trackCollection_(trackCollection),
46  beamPoint_(beamPoint)
47 {
48  setDzOption(dzOptionString);
49 }
50 
52 {
53 }
54 
55 // unified acces to isolations
56 std::pair<int,double> ElectronTkIsolation::getIso(const reco::GsfElectron* electron) const
57 {
58  int counter =0 ;
59  double ptSum =0.;
60  //Take the electron track
61  reco::GsfTrackRef tmpTrack = electron->gsfTrack() ;
62  math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum () ;
63  double tmpElectronEtaAtVertex = (*tmpTrack).eta();
64 
65 
66  for ( reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin() ;
67  itrTr != (*trackCollection_).end() ;
68  ++itrTr ) {
69 
70  math::XYZVector tmpTrackMomentumAtVtx = (*itrTr).momentum () ;
71 
72  double this_pt = (*itrTr).pt();
73  if ( this_pt < ptLow_ ) continue;
74 
75 
76  double dzCut = 0;
77  switch( dzOption_ ) {
78  case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*itrTr).dz() - (*tmpTrack).dz() ); break;
79  case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
80  case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*itrTr).dz(beamPoint_) - (*tmpTrack).dz(beamPoint_) ); break;
81  case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*itrTr).dz(tmpTrack->vertex()) ); break;
82  default : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
83  }
84  if (dzCut > lip_ ) continue;
85  if (fabs( (*itrTr).dxy(beamPoint_) ) > drb_ ) continue;
86  double dr = ROOT::Math::VectorUtil::DeltaR(itrTr->momentum(),tmpElectronMomentumAtVtx) ;
87  double deta = (*itrTr).eta() - tmpElectronEtaAtVertex;
88  if (fabs(tmpElectronEtaAtVertex) < 1.479) {
89  if ( fabs(dr) < extRadius_ && fabs(dr) >= intRadiusBarrel_ && fabs(deta) >= stripBarrel_)
90  {
91  ++counter ;
92  ptSum += this_pt;
93  }
94  }
95  else {
96  if ( fabs(dr) < extRadius_ && fabs(dr) >= intRadiusEndcap_ && fabs(deta) >= stripEndcap_)
97  {
98  ++counter ;
99  ptSum += this_pt;
100  }
101  }
102 
103  }//end loop over tracks
104 
105  std::pair<int,double> retval;
106  retval.first = counter;
107  retval.second = ptSum;
108 
109  return retval;
110 }
111 
112 
114 {
115  //counter for the tracks in the isolation cone
116  return getIso(electron).first ;
117 }
118 
120 {
121  return getIso(electron).second ;
122 }
123 
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
int getNumberTracks(const reco::GsfElectron *) const
ElectronTkIsolation(double extRadius, double intRadius, double ptLow, double lip, double drb, const reco::TrackCollection *trackCollection, reco::TrackBase::Point beamPoint)
void setDzOption(const std::string &s)
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
std::pair< int, double > getIso(const reco::GsfElectron *) const
GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double getPtTracks(const reco::GsfElectron *) const
reco::TrackBase::Point beamPoint_