CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaTowerIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaTowerIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 //C++ includes
9 #include <vector>
10 #include <functional>
11 #include <math.h>
12 
13 //ROOT includes
14 #include <Math/VectorUtil.h>
15 
16 
17 //CMSSW includes
24 
25 using namespace ROOT::Math::VectorUtil ;
26 
28  double intRadius,
29  double etLow,
30  signed int depth,
31  const CaloTowerCollection* towercollection) :
32  extRadius_(extRadius),
33  intRadius_(intRadius),
34  etLow_(etLow),
35  depth_(depth),
36  towercollection_(towercollection)
37 {
38 }
39 
41 {
42 }
43 
44 
45 
46 
48 {
49  return getTowerEtSum( photon->get<reco::SuperClusterRef>().get() );
50 }
51 
53 {
54  math::XYZPoint theCaloPosition = sc->position();
55  double candEta=sc->eta();
56  double candPhi=sc->phi();
57  double ptSum =0.;
58 
59  //loop over tracks
61 
62  double this_pt=0;
63  switch(depth_){
64  case AllDepths: this_pt = trItr->hadEt();break;
65  case Depth1: this_pt = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEt() : trItr->hadEnergyHeInnerLayer()*sin(trItr->p4().theta());break;
66  case Depth2: this_pt = trItr->hadEnergyHeOuterLayer()*sin(trItr->p4().theta());break;
67  default: throw cms::Exception("Configuration Error") << "EgammaTowerIsolation: Depth " << depth_ << " not known. "; break;
68  }
69 
70  if ( this_pt < etLow_ )
71  continue ;
72 
73  double towerEta=trItr->eta();
74  double towerPhi=trItr->phi();
75  double twoPi= 2*M_PI;
76  if(towerPhi<0) towerPhi+=twoPi;
77  if(candPhi<0) candPhi+=twoPi;
78  double deltaPhi=fabs(towerPhi-candPhi);
79  if(deltaPhi>twoPi) deltaPhi-=twoPi;
80  if(deltaPhi>M_PI) deltaPhi=twoPi-deltaPhi;
81  double deltaEta = towerEta - candEta;
82 
83 
84  double dr = deltaEta*deltaEta + deltaPhi*deltaPhi;
85  if( dr < extRadius_*extRadius_ &&
86  dr >= intRadius_*intRadius_ )
87  {
88  ptSum += this_pt;
89  }
90 
91  }//end loop over tracks
92 
93  return ptSum;
94 }
95 
96 
98 {
99  return getTowerESum( photon->get<reco::SuperClusterRef>().get() );
100 }
101 
103 {
104  math::XYZPoint theCaloPosition = sc->position();
105  double candEta=sc->eta();
106  double candPhi=sc->phi();
107  double eSum =0.;
108 
109  //loop over tracks
110  for(CaloTowerCollection::const_iterator trItr = towercollection_->begin(); trItr != towercollection_->end(); ++trItr){
111 
112  double this_e=0;
113  switch(depth_){
114  case AllDepths: this_e = trItr->hadEnergy();break;
115  case Depth1: this_e = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEnergy() : trItr->hadEnergyHeInnerLayer();break;
116  case Depth2: this_e = trItr->hadEnergyHeOuterLayer();break;
117  default: throw cms::Exception("Configuration Error") << "EgammaTowerIsolation: Depth " << depth_ << " not known. "; break;
118  }
119 
120  if ( this_e*sin(trItr->p4().theta()) < etLow_ )
121  continue ;
122 
123  double towerEta=trItr->eta();
124  double towerPhi=trItr->phi();
125  double twoPi= 2*M_PI;
126  if(towerPhi<0) towerPhi+=twoPi;
127  if(candPhi<0) candPhi+=twoPi;
128  double deltaPhi=fabs(towerPhi-candPhi);
129  if(deltaPhi>twoPi) deltaPhi-=twoPi;
130  if(deltaPhi>M_PI) deltaPhi=twoPi-deltaPhi;
131  double deltaEta = towerEta - candEta;
132 
133 
134  double dr = deltaEta*deltaEta + deltaPhi*deltaPhi;
135  if( dr < extRadius_*extRadius_ &&
136  dr >= intRadius_*intRadius_ )
137  {
138  eSum += this_e;
139  }
140 
141  }//end loop over tracks
142 
143  return eSum;
144 }
145 
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:123
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
double getTowerESum(const reco::Candidate *) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< CaloTower >::const_iterator const_iterator
EgammaTowerIsolation(double extRadius, double intRadius, double etLow, signed int depth, const CaloTowerCollection *)
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:160
const_iterator end() const
#define M_PI
Definition: BFit3D.cc:3
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const CaloTowerCollection * towercollection_
double twoPi()
Definition: Pi.h:32
T get() const
get a component
Definition: Candidate.h:217
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:163
double getTowerEtSum(const reco::Candidate *) const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:241
const_iterator begin() const