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 
26  double intRadiusBarrel,
27  double intRadiusEndcap,
28  double stripBarrel,
29  double stripEndcap,
30  double ptLow,
31  double lip,
32  double drb,
34  reco::TrackBase::Point beamPoint,
35  const std::string& dzOptionString)
36  : extRadius_(extRadius),
37  intRadiusBarrel_(intRadiusBarrel),
38  intRadiusEndcap_(intRadiusEndcap),
39  stripBarrel_(stripBarrel),
40  stripEndcap_(stripEndcap),
41  ptLow_(ptLow),
42  lip_(lip),
43  drb_(drb),
44  trackCollection_(trackCollection),
45  beamPoint_(beamPoint) {
47  setDzOption(dzOptionString);
48 }
49 
51 
52 std::pair<int, double> ElectronTkIsolation::getIso(const reco::GsfElectron* electron) const {
53  return getIso(&(*(electron->gsfTrack())));
54 }
55 
56 // unified acces to isolations
57 std::pair<int, double> ElectronTkIsolation::getIso(const reco::Track* tmpTrack) const {
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  for (reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin(); itrTr != (*trackCollection_).end();
66  ++itrTr) {
67  double this_pt = (*itrTr).pt();
68  if (this_pt < ptLow_)
69  continue;
70 
71  double dzCut = 0;
72  switch (dzOption_) {
74  dzCut = fabs((*itrTr).dz() - (*tmpTrack).dz());
75  break;
77  dzCut = fabs((*itrTr).vz() - (*tmpTrack).vz());
78  break;
80  dzCut = fabs((*itrTr).dz(beamPoint_) - (*tmpTrack).dz(beamPoint_));
81  break;
83  dzCut = fabs((*itrTr).dz(tmpTrack->vertex()));
84  break;
85  default:
86  dzCut = fabs((*itrTr).vz() - (*tmpTrack).vz());
87  break;
88  }
89  if (dzCut > lip_)
90  continue;
91  if (fabs((*itrTr).dxy(beamPoint_)) > drb_)
92  continue;
93  double dr = ROOT::Math::VectorUtil::DeltaR(itrTr->momentum(), tmpElectronMomentumAtVtx);
94  double deta = (*itrTr).eta() - tmpElectronEtaAtVertex;
95  bool isBarrel = std::abs(tmpElectronEtaAtVertex) < 1.479;
96  double intRadius = isBarrel ? intRadiusBarrel_ : intRadiusEndcap_;
97  double strip = isBarrel ? stripBarrel_ : stripEndcap_;
98  if (dr < extRadius_ && dr >= intRadius && std::abs(deta) >= strip && passAlgo(*itrTr)) {
99  ++counter;
100  ptSum += this_pt;
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 
113  //counter for the tracks in the isolation cone
114  return getIso(electron).first;
115 }
116 
117 double ElectronTkIsolation::getPtTracks(const reco::GsfElectron* electron) const { return getIso(electron).second; }
118 
120  int algo = trk.algo();
121  bool rejAlgo = std::binary_search(algosToReject_.begin(), algosToReject_.end(), algo);
122  return rejAlgo == false;
123 }
124 
127  std::sort(algosToReject_.begin(), algosToReject_.end());
128 }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
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:526
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:641
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:80
std::pair< int, double > getIso(const reco::GsfElectron *) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double getPtTracks(const reco::GsfElectron *) const
static std::atomic< unsigned int > counter
reco::TrackBase::Point beamPoint_