CMS 3D CMS Logo

ElectronSqPtTkIsolation.cc
Go to the documentation of this file.
1 //C++ includes
2 #include <vector>
3 #include <functional>
4 
5 //ROOT includes
6 #include <Math/VectorUtil.h>
7 
8 //CMSSW includes
16 
17 using namespace ROOT::Math::VectorUtil;
18 
20  double extRadius, double intRadius, double ptLow, double lip, const reco::TrackCollection* trackCollection)
21  : extRadius_(extRadius), intRadius_(intRadius), ptLow_(ptLow), lip_(lip), trackCollection_(trackCollection) {}
22 
24 
25 // unified acces to isolations
26 std::pair<int, double> ElectronSqPtTkIsolation::getIso(const reco::GsfElectron* electron) const {
27  int counter = 0;
28  double ptSum = 0.;
29  //Take the electron track
30  reco::GsfTrackRef tmpTrack = electron->gsfTrack();
31  math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum();
32 
33  for (reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin(); itrTr != (*trackCollection_).end();
34  ++itrTr) {
35  math::XYZVector tmpTrackMomentumAtVtx = (*itrTr).momentum();
36  double this_pt = (*itrTr).pt();
37  if (this_pt < ptLow_)
38  continue;
39  if (fabs((*itrTr).dz() - (*tmpTrack).dz()) > lip_)
40  continue;
41  double dr = DeltaR(tmpTrackMomentumAtVtx, tmpElectronMomentumAtVtx);
42  if (fabs(dr) < extRadius_ && fabs(dr) >= intRadius_) {
43  ++counter;
44  ptSum += this_pt * this_pt; // sum of squared pT
45  }
46  } //end loop over tracks
47 
48  std::pair<int, double> retval;
49  retval.first = counter;
50  retval.second = ptSum;
51 
52  return retval;
53 }
54 
56  //counter for the tracks in the isolation cone
57  return getIso(electron).first;
58 }
59 
60 double ElectronSqPtTkIsolation::getPtTracks(const reco::GsfElectron* electron) const { return getIso(electron).second; }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
double getPtTracks(const reco::GsfElectron *) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::pair< int, double > getIso(const reco::GsfElectron *) const
ElectronSqPtTkIsolation(double extRadius, double intRadius, double ptLow, double lip, const reco::TrackCollection *)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
static std::atomic< unsigned int > counter
int getNumberTracks(const reco::GsfElectron *) const