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 
31  float intRadiusBarrel,
32  float intRadiusEndcap,
33  float stripBarrel,
34  float stripEndcap,
35  float etLow,
36  float lip,
37  float drb,
38  const reco::TrackCollection* trackCollection,
39  reco::TrackBase::Point beamPoint,
40  const std::string &dzOptionString) :
41  extRadius2_(extRadius*extRadius),
42  intRadiusBarrel2_(intRadiusBarrel*intRadiusBarrel),
43  intRadiusEndcap2_(intRadiusEndcap*intRadiusEndcap),
44  stripBarrel_(stripBarrel),
45  stripEndcap_(stripEndcap),
46  etLow_(etLow),
47  lip_(lip),
48  drb_(drb),
49  trackCollection_(trackCollection),
50  beamPoint_(beamPoint)
51 {
52  setDzOption(dzOptionString);
53 }
54 
56  if( ! s.compare("dz") ) dzOption_ = egammaisolation::EgammaTrackSelector::dz;
57  else if( ! s.compare("vz") ) dzOption_ = egammaisolation::EgammaTrackSelector::vz;
58  else if( ! s.compare("bs") ) dzOption_ = egammaisolation::EgammaTrackSelector::bs;
59  else if( ! s.compare("vtx") )dzOption_ = egammaisolation::EgammaTrackSelector::vtx;
61 }
62 
63 
64 
66 {
67 }
68 
69 
70 
71 // unified acces to isolations
72 std::pair<int,float> PhotonTkIsolation::getIso(const reco::Candidate* photon ) const
73 {
74  int counter =0 ;
75  float ptSum =0.;
76 
77 
78  //Take the photon position
79  float photonEta = photon->eta();
80 
81  //loop over tracks
82  for(reco::TrackCollection::const_iterator trItr = trackCollection_->begin(); trItr != trackCollection_->end(); ++trItr){
83 
84  //check z-distance of vertex
85  float dzCut = 0;
86  switch( dzOption_ ) {
87  case egammaisolation::EgammaTrackSelector::dz : dzCut = fabs( (*trItr).dz() - photon->vertex().z() ); break;
88  case egammaisolation::EgammaTrackSelector::vz : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
89  case egammaisolation::EgammaTrackSelector::bs : dzCut = fabs( (*trItr).dz(beamPoint_) - photon->vertex().z() ); break;
90  case egammaisolation::EgammaTrackSelector::vtx: dzCut = fabs( (*trItr).dz(photon->vertex())); break;
91  default : dzCut = fabs( (*trItr).vz() - photon->vertex().z() ); break;
92  }
93  if (dzCut > lip_ ) continue;
94 
95  float this_pt = (*trItr).pt();
96  if ( this_pt < etLow_ ) continue ;
97  if (fabs( (*trItr).dxy(beamPoint_) ) > drb_ ) continue;// only consider tracks from the main vertex
98  float dr2 = reco::deltaR2(*trItr,*photon) ;
99  float deta = (*trItr).eta() - photonEta ;
100  if (fabs(photonEta) < 1.479) {
101  if(dr2 < extRadius2_ && dr2 >= intRadiusBarrel2_ && fabs(deta) >= stripBarrel_)
102  {
103  ++counter;
104  ptSum += this_pt;
105  }
106  }
107  else {
108  if(dr2 < extRadius2_ && dr2 >= intRadiusEndcap2_ && fabs(deta) >= stripEndcap_)
109  {
110  ++counter;
111  ptSum += this_pt;
112  }
113  }
114 
115  }//end loop over tracks
116 
117  std::pair<int,float> retval;
118  retval.first = counter;
119  retval.second = ptSum;
120  return retval;
121 }
122 
void setDzOption(const std::string &s)
virtual float eta() const =0
momentum pseudorapidity
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
reco::TrackBase::Point beamPoint_
const reco::TrackCollection * trackCollection_
virtual const Point & vertex() const =0
vertex position
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
std::pair< int, float > getIso(const reco::Candidate *) const
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
PhotonTkIsolation(float extRadius, float intRadius, float etLow, float lip, float drb, const reco::TrackCollection *trackCollection, reco::TrackBase::Point beamPoint)