CMS 3D CMS Logo

PhotonTkIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: PhotonTkIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 //C++ includes
9 #include <vector>
10 #include <functional>
11 
12 //ROOT includes
13 #include <Math/VectorUtil.h>
14 
15 //CMSSW includes
28 
30  float intRadiusBarrel,
31  float intRadiusEndcap,
32  float stripBarrel,
33  float stripEndcap,
34  float etLow,
35  float lip,
36  float drb,
38  reco::TrackBase::Point beamPoint,
39  const std::string& dzOptionString)
40  : extRadius2_(extRadius * extRadius),
41  intRadiusBarrel2_(intRadiusBarrel * intRadiusBarrel),
42  intRadiusEndcap2_(intRadiusEndcap * intRadiusEndcap),
43  stripBarrel_(stripBarrel),
44  stripEndcap_(stripEndcap),
45  etLow_(etLow),
46  lip_(lip),
47  drb_(drb),
48  trackCollection_(trackCollection),
49  beamPoint_(beamPoint) {
50  setDzOption(dzOptionString);
51 }
52 
54  if (!s.compare("dz"))
56  else if (!s.compare("vz"))
58  else if (!s.compare("bs"))
60  else if (!s.compare("vtx"))
62  else
64 }
65 
67 
68 // unified acces to isolations
69 std::pair<int, float> PhotonTkIsolation::getIso(const reco::Candidate* photon) const {
70  int counter = 0;
71  float ptSum = 0.;
72 
73  //Take the photon position
74  float photonEta = photon->eta();
75 
76  //loop over tracks
77  for (reco::TrackCollection::const_iterator trItr = trackCollection_->begin(); trItr != trackCollection_->end();
78  ++trItr) {
79  //check z-distance of vertex
80  float dzCut = 0;
81  switch (dzOption_) {
83  dzCut = fabs((*trItr).dz() - photon->vertex().z());
84  break;
86  dzCut = fabs((*trItr).vz() - photon->vertex().z());
87  break;
89  dzCut = fabs((*trItr).dz(beamPoint_) - photon->vertex().z());
90  break;
92  dzCut = fabs((*trItr).dz(photon->vertex()));
93  break;
94  default:
95  dzCut = fabs((*trItr).vz() - photon->vertex().z());
96  break;
97  }
98  if (dzCut > lip_)
99  continue;
100 
101  float this_pt = (*trItr).pt();
102  if (this_pt < etLow_)
103  continue;
104  if (fabs((*trItr).dxy(beamPoint_)) > drb_)
105  continue; // only consider tracks from the main vertex
106  float dr2 = reco::deltaR2(*trItr, *photon);
107  float deta = (*trItr).eta() - photonEta;
108  if (fabs(photonEta) < 1.479) {
109  if (dr2 < extRadius2_ && dr2 >= intRadiusBarrel2_ && fabs(deta) >= stripBarrel_) {
110  ++counter;
111  ptSum += this_pt;
112  }
113  } else {
114  if (dr2 < extRadius2_ && dr2 >= intRadiusEndcap2_ && fabs(deta) >= stripEndcap_) {
115  ++counter;
116  ptSum += this_pt;
117  }
118  }
119 
120  } //end loop over tracks
121 
122  std::pair<int, float> retval;
123  retval.first = counter;
124  retval.second = ptSum;
125  return retval;
126 }
void setDzOption(const std::string &s)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
reco::TrackBase::Point beamPoint_
const reco::TrackCollection * trackCollection_
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
std::pair< int, float > getIso(const reco::Candidate *) const
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
virtual double eta() const =0
momentum pseudorapidity
static std::atomic< unsigned int > counter
virtual const Point & vertex() const =0
vertex position
PhotonTkIsolation(float extRadius, float intRadius, float etLow, float lip, float drb, const reco::TrackCollection *trackCollection, reco::TrackBase::Point beamPoint)