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 
11 
12 #include <Math/VectorUtil.h>
13 
15  double intRadiusBarrel,
16  double intRadiusEndcap,
17  double stripBarrel,
18  double stripEndcap,
19  double ptLow,
20  double lip,
21  double drb,
23  reco::TrackBase::Point beamPoint,
24  const std::string& dzOptionString)
25  : extRadius_(extRadius),
26  intRadiusBarrel_(intRadiusBarrel),
27  intRadiusEndcap_(intRadiusEndcap),
28  stripBarrel_(stripBarrel),
29  stripEndcap_(stripEndcap),
30  ptLow_(ptLow),
31  lip_(lip),
32  drb_(drb),
33  trackCollection_(trackCollection),
34  beamPoint_(beamPoint) {
36  setDzOption(dzOptionString);
37 }
38 
40 
41 std::pair<int, double> ElectronTkIsolation::getIso(const reco::GsfElectron* electron) const {
42  return getIso(&(*(electron->gsfTrack())));
43 }
44 
45 // unified acces to isolations
46 std::pair<int, double> ElectronTkIsolation::getIso(const reco::Track* tmpTrack) const {
47  int counter = 0;
48  double ptSum = 0.;
49  //Take the electron track
50  math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum();
51  double tmpElectronEtaAtVertex = (*tmpTrack).eta();
52 
53  for (reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin(); itrTr != (*trackCollection_).end();
54  ++itrTr) {
55  double this_pt = (*itrTr).pt();
56  if (this_pt < ptLow_)
57  continue;
58 
59  double dzCut = 0;
60  switch (dzOption_) {
62  dzCut = fabs((*itrTr).dz() - (*tmpTrack).dz());
63  break;
65  dzCut = fabs((*itrTr).vz() - (*tmpTrack).vz());
66  break;
68  dzCut = fabs((*itrTr).dz(beamPoint_) - (*tmpTrack).dz(beamPoint_));
69  break;
71  dzCut = fabs((*itrTr).dz(tmpTrack->vertex()));
72  break;
73  default:
74  dzCut = fabs((*itrTr).vz() - (*tmpTrack).vz());
75  break;
76  }
77  if (dzCut > lip_)
78  continue;
79  if (fabs((*itrTr).dxy(beamPoint_)) > drb_)
80  continue;
81  double dr = ROOT::Math::VectorUtil::DeltaR(itrTr->momentum(), tmpElectronMomentumAtVtx);
82  double deta = (*itrTr).eta() - tmpElectronEtaAtVertex;
83  bool isBarrel = std::abs(tmpElectronEtaAtVertex) < 1.479;
86  if (dr < extRadius_ && dr >= intRadius && std::abs(deta) >= strip && passAlgo(*itrTr)) {
87  ++counter;
88  ptSum += this_pt;
89  }
90 
91  } //end loop over tracks
92 
93  std::pair<int, double> retval;
94  retval.first = counter;
95  retval.second = ptSum;
96 
97  return retval;
98 }
99 
101  //counter for the tracks in the isolation cone
102  return getIso(electron).first;
103 }
104 
106 
108  int algo = trk.algo();
109  bool rejAlgo = std::binary_search(algosToReject_.begin(), algosToReject_.end(), algo);
110  //check also the originalAlgo in case the track is reconstructed by more than one
111  algo = trk.originalAlgo();
112  //reject only if both algo and originalAlgo are not acceptable
113  rejAlgo &= std::binary_search(algosToReject_.begin(), algosToReject_.end(), algo);
114  return !rejAlgo;
115 }
116 
119  std::sort(algosToReject_.begin(), algosToReject_.end());
120 }
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
ElectronTkIsolation(double extRadius, double intRadius, double ptLow, double lip, double drb, const reco::TrackCollection *trackCollection, reco::TrackBase::Point beamPoint)
TrackAlgorithm originalAlgo() const
Definition: TrackBase.h:548
bool passAlgo(const reco::TrackBase &trk) const
void setDzOption(const std::string &s)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
std::vector< int > algosToReject_
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
trackCollection
Definition: JetHT_cfg.py:50
TrackAlgorithm algo() const
Definition: TrackBase.h:547
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
int getNumberTracks(const reco::GsfElectron *) const
static std::atomic< unsigned int > counter
std::pair< int, double > getIso(const reco::GsfElectron *) const
reco::TrackBase::Point beamPoint_
double getPtTracks(const reco::GsfElectron *) const