CMS 3D CMS Logo

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 {
49  setDzOption(dzOptionString);
50 }
51 
53 {}
54 
55 std::pair<int,double> ElectronTkIsolation::getIso(const reco::GsfElectron* electron) const {
56  return getIso(&(*(electron->gsfTrack())));
57 }
58 
59 // unified acces to isolations
60 std::pair<int,double> ElectronTkIsolation::getIso(const reco::Track* tmpTrack) const
61 {
62  int counter =0 ;
63  double ptSum =0.;
64  //Take the electron track
65  //reco::GsfTrackRef tmpTrack = electron->gsfTrack() ;
66  math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum () ;
67  double tmpElectronEtaAtVertex = (*tmpTrack).eta();
68 
69 
70  for ( reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin() ;
71  itrTr != (*trackCollection_).end() ;
72  ++itrTr ) {
73 
74  double this_pt = (*itrTr).pt();
75  if ( this_pt < ptLow_ ) continue;
76 
77 
78  double dzCut = 0;
79  switch( dzOption_ ) {
80  case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*itrTr).dz() - (*tmpTrack).dz() ); break;
81  case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
82  case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*itrTr).dz(beamPoint_) - (*tmpTrack).dz(beamPoint_) ); break;
83  case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*itrTr).dz(tmpTrack->vertex()) ); break;
84  default : dzCut = fabs( (*itrTr).vz() - (*tmpTrack).vz() ); break;
85  }
86  if (dzCut > lip_ ) continue;
87  if (fabs( (*itrTr).dxy(beamPoint_) ) > drb_ ) continue;
88  double dr = ROOT::Math::VectorUtil::DeltaR(itrTr->momentum(),tmpElectronMomentumAtVtx) ;
89  double deta = (*itrTr).eta() - tmpElectronEtaAtVertex;
90  bool isBarrel = std::abs(tmpElectronEtaAtVertex) < 1.479;
91  double intRadius = isBarrel ? intRadiusBarrel_ : intRadiusEndcap_;
92  double strip = isBarrel ? stripBarrel_ : stripEndcap_;
93  if(dr < extRadius_ && dr>=intRadius && std::abs(deta) >=strip && passAlgo(*itrTr)){
94 
95  ++counter ;
96  ptSum += this_pt;
97  }
98 
99  }//end loop over tracks
100 
101  std::pair<int,double> retval;
102  retval.first = counter;
103  retval.second = ptSum;
104 
105  return retval;
106 }
107 
108 
110 {
111  //counter for the tracks in the isolation cone
112  return getIso(electron).first ;
113 }
114 
116 {
117  return getIso(electron).second ;
118 }
119 
120 
122 {
123  int algo = trk.algo();
124  bool rejAlgo=std::binary_search(algosToReject_.begin(),algosToReject_.end(),algo);
125  return rejAlgo==false;
126 }
127 
128 
130 {
132  std::sort(algosToReject_.begin(),algosToReject_.end());
133 }
bool passAlgo(const reco::TrackBase &trk) const
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)
TrackAlgorithm algo() const
Definition: TrackBase.h:492
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:682
void setDzOption(const std::string &s)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > algosToReject_
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:185