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,
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 std::pair<int,double> ElectronTkIsolation::getIso(const reco::GsfElectron* electron) const {
55  return getIso(&(*(electron->gsfTrack())));
56 }
57 
58 // unified acces to isolations
59 std::pair<int,double> ElectronTkIsolation::getIso(const reco::Track* tmpTrack) const
60 {
61  int counter =0 ;
62  double ptSum =0.;
63  //Take the electron track
64  //reco::GsfTrackRef tmpTrack = electron->gsfTrack() ;
65  math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum () ;
66  double tmpElectronEtaAtVertex = (*tmpTrack).eta();
67 
68 
69  for ( reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin() ;
70  itrTr != (*trackCollection_).end() ;
71  ++itrTr ) {
72 
73  double this_pt = (*itrTr).pt();
74  if ( this_pt < ptLow_ ) continue;
75 
76 
77  double dzCut = 0;
78  switch( dzOption_ ) {
79  case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*itrTr).dz() - (*tmpTrack).dz() ); break;
80  case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
81  case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*itrTr).dz(beamPoint_) - (*tmpTrack).dz(beamPoint_) ); break;
82  case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*itrTr).dz(tmpTrack->vertex()) ); break;
83  default : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
84  }
85  if (dzCut > lip_ ) continue;
86  if (fabs( (*itrTr).dxy(beamPoint_) ) > drb_ ) continue;
87  double dr = ROOT::Math::VectorUtil::DeltaR(itrTr->momentum(),tmpElectronMomentumAtVtx) ;
88  double deta = (*itrTr).eta() - tmpElectronEtaAtVertex;
89  if (fabs(tmpElectronEtaAtVertex) < 1.479) {
90  if ( fabs(dr) < extRadius_ && fabs(dr) >= intRadiusBarrel_ && fabs(deta) >= stripBarrel_)
91  {
92  ++counter ;
93  ptSum += this_pt;
94  }
95  }
96  else {
97  if ( fabs(dr) < extRadius_ && fabs(dr) >= intRadiusEndcap_ && fabs(deta) >= stripEndcap_)
98  {
99  ++counter ;
100  ptSum += this_pt;
101  }
102  }
103 
104  }//end loop over tracks
105 
106  std::pair<int,double> retval;
107  retval.first = counter;
108  retval.second = ptSum;
109 
110  return retval;
111 }
112 
113 
115 {
116  //counter for the tracks in the isolation cone
117  return getIso(electron).first ;
118 }
119 
121 {
122  return getIso(electron).second ;
123 }
124 
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
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)
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:674
void setDzOption(const std::string &s)
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
std::pair< int, double > getIso(const reco::GsfElectron *) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
double getPtTracks(const reco::GsfElectron *) const
static std::atomic< unsigned int > counter
reco::TrackBase::Point beamPoint_
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183