CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalClusterIsoCalculator.cc
Go to the documentation of this file.
1 // ROOT includes
2 #include <Math/VectorUtil.h>
3 
6 
9 
14 
15 
16 using namespace edm;
17 using namespace reco;
18 using namespace std;
19 
21 {
22  if(pEBclusters.isValid())
23  fEBclusters_ = pEBclusters.product();
24  else
25  fEBclusters_ = nullptr;
26 
27  if(pEEclusters.isValid())
28  fEEclusters_ = pEEclusters.product();
29  else
30  fEEclusters_ = nullptr;
31 
32  ESHandle<CaloGeometry> geometryHandle;
33  iSetup.get<CaloGeometryRecord>().get(geometryHandle);
34  if(geometryHandle.isValid())
35  geometry_ = geometryHandle.product();
36  else
37  geometry_ = nullptr;
38 }
39 
40 double EcalClusterIsoCalculator::getEcalClusterIso(const reco::SuperClusterRef cluster, const double x, const double threshold)
41 {
42  if(!fEBclusters_) {
43  return -100;
44  }
45 
46  if(!fEEclusters_) {
47  return -100;
48  }
49 
50  math::XYZVector SClusPoint(cluster->position().x(),
51  cluster->position().y(),
52  cluster->position().z());
53 
54  double TotalEt = 0;
55 
56  TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
57 
58  // Loop over barrel basic clusters
59  for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
60  iclu != fEBclusters_->end(); ++iclu) {
61  const BasicCluster *clu = &(*iclu);
62  math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
63  double eta = ClusPoint.eta();
64 
65  double dR2 = reco::deltaR2(*clu, *cluster);
66 
67  if (dR2 < (x*x*0.01)) {
68  double et = clu->energy()/cosh(eta);
69  if (et<threshold) et=0;
70  TotalEt += et;
71  }
72  }
73 
74  for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
75  iclu != fEEclusters_->end(); ++iclu) {
76  const BasicCluster *clu = &(*iclu);
77  const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
78  math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
79  double eta = ClusPoint.eta();
80 
81  double dR2 = reco::deltaR2(*clu, *cluster);
82 
83  if (dR2 < (x*x*0.01)) {
84  double et = clu->energy()/cosh(eta);
85  if (et<threshold) et=0;
86  TotalEt += et;
87  }
88  }
89 
90  return TotalEt;
91 }
92 
93 double EcalClusterIsoCalculator::getBkgSubEcalClusterIso(const reco::SuperClusterRef cluster, const double x, double const threshold)
94 {
95  if(!fEBclusters_) {
96  return -100;
97  }
98 
99  if(!fEEclusters_) {
100  return -100;
101  }
102 
103  double SClusterEta = cluster->eta();
104  double TotalEt = 0;
105 
106  TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
107 
108  for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
109  iclu != fEBclusters_->end(); ++iclu) {
110  const BasicCluster *clu = &(*iclu);
111  math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
112  double eta = ClusPoint.eta();
113 
114  double dEta = fabs(eta-SClusterEta);
115 
116  if (dEta<x*0.1) {
117  double et = clu->energy()/cosh(eta);
118  if (et<threshold) et=0;
119  TotalEt += et;
120  }
121  }
122 
123  for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
124  iclu != fEEclusters_->end(); ++iclu) {
125  const BasicCluster *clu = &(*iclu);
126  math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
127  double eta = ClusPoint.eta();
128  double dEta = fabs(eta-SClusterEta);
129 
130  if (dEta<x*0.1) {
131  double et = clu->energy()/cosh(eta);
132  if (et<threshold) et=0;
133  TotalEt += et;
134  }
135  }
136 
137  double Cx = getEcalClusterIso(cluster,x,threshold);
138  double CCx = (Cx - TotalEt / 40.0 * x) * (1/(1-x/40.));
139 
140  return CCx;
141 }
double getBkgSubEcalClusterIso(const reco::SuperClusterRef clus, const double radius, const double threshold)
Return the background-subtracted ecal cluster energy in a cone around the SC.
EcalClusterIsoCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::Handle< reco::BasicClusterCollection > barrel, const edm::Handle< reco::BasicClusterCollection > endcap)
int iEvent
Definition: GenABIO.cc:230
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
bool isValid() const
Definition: HandleBase.h:75
double getEcalClusterIso(const reco::SuperClusterRef clus, const double radius, const double threshold)
Return the ecal cluster energy in a cone around the SC.
T const * product() const
Definition: Handle.h:81
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
bool isValid() const
Definition: ESHandle.h:47