CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
29 using namespace ROOT::Math::VectorUtil;
30 
31 
33  double intRadiusBarrel,
34  double intRadiusEndcap,
35  double stripBarrel,
36  double stripEndcap,
37  double etLow,
38  double lip,
39  double drb,
40  const reco::TrackCollection* trackCollection,
41  reco::TrackBase::Point beamPoint,
42  const std::string &dzOptionString) :
43  extRadius_(extRadius),
44  intRadiusBarrel_(intRadiusBarrel),
45  intRadiusEndcap_(intRadiusEndcap),
46  stripBarrel_(stripBarrel),
47  stripEndcap_(stripEndcap),
48  etLow_(etLow),
49  lip_(lip),
50  drb_(drb),
51  trackCollection_(trackCollection),
52  beamPoint_(beamPoint)
53 {
54  setDzOption(dzOptionString);
55 }
56 
58 {
59 }
60 
61 
62 
63 // unified acces to isolations
64 std::pair<int,double> PhotonTkIsolation::getIso(const reco::Candidate* photon ) const
65 {
66  int counter =0 ;
67  double ptSum =0.;
68 
69 
70  //Take the photon position
71  math::XYZVector mom= photon->momentum();
72  double photonEta = photon->eta();
73 
74  //loop over tracks
75  for(reco::TrackCollection::const_iterator trItr = trackCollection_->begin(); trItr != trackCollection_->end(); ++trItr){
76 
77  //check z-distance of vertex
78  double dzCut = 0;
79  switch( dzOption_ ) {
80  case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*trItr).dz() - photon->vertex().z() ); break;
81  case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
82  case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*trItr).dz(beamPoint_) - photon->vertex().z() ); break;
83  case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*trItr).dz(photon->vertex())); break;
84  default : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
85  }
86  if (dzCut > lip_ ) continue;
87 
88  math::XYZVector tmpTrackMomentumAtVtx = (*trItr).momentum () ;
89  double this_pt = (*trItr).pt();
90  if ( this_pt < etLow_ ) continue ;
91  if (fabs( (*trItr).dxy(beamPoint_) ) > drb_ ) continue;// only consider tracks from the main vertex
92  double dr = ROOT::Math::VectorUtil::DeltaR(tmpTrackMomentumAtVtx,mom) ;
93  double deta = (*trItr).eta() - photonEta ;
94  if (fabs(photonEta) < 1.479) {
95  if(fabs(dr) < extRadius_ && fabs(dr) >= intRadiusBarrel_ && fabs(deta) >= stripBarrel_)
96  {
97  ++counter;
98  ptSum += this_pt;
99  }
100  }
101  else {
102  if(fabs(dr) < extRadius_ && fabs(dr) >= intRadiusEndcap_ && fabs(deta) >= stripEndcap_)
103  {
104  ++counter;
105  ptSum += this_pt;
106  }
107  }
108 
109  }//end loop over tracks
110 
111  std::pair<int,double> retval;
112  retval.first = counter;
113  retval.second = ptSum;
114  return retval;
115 }
116 
118 {
119  //counter for the tracks in the isolation cone
120  return getIso(photon).first ;
121 }
122 
124 {
125  return getIso(photon).second ;
126 }
127 
void setDzOption(const std::string &s)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
reco::TrackBase::Point beamPoint_
PhotonTkIsolation(double extRadius, double intRadius, double etLow, double lip, double drb, const reco::TrackCollection *trackCollection, reco::TrackBase::Point beamPoint)
virtual Vector momentum() const =0
spatial momentum vector
const reco::TrackCollection * trackCollection_
virtual const Point & vertex() const =0
vertex position
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
double getPtTracks(const reco::Candidate *) const
std::pair< int, double > getIso(const reco::Candidate *) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
int getNumberTracks(const reco::Candidate *) const
virtual double eta() const =0
momentum pseudorapidity