CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RxCalculator.cc
Go to the documentation of this file.
2 
4 
8 
12 
13 
14 using namespace edm;
15 using namespace reco;
16 
17 #define PI 3.141592653589793238462643383279502884197169399375105820974945
18 
19 
20 RxCalculator::RxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup,const edm::InputTag& hbheLabel,const edm::InputTag& hfLabel,const edm::InputTag& hoLabel)
21 {
23  iEvent.getByLabel(hfLabel, hfhandle);
24  if(hfhandle.isValid())
25  fHFRecHits_ = hfhandle.product();
26  else
27  fHFRecHits_ = NULL;
28 
30  iEvent.getByLabel(hoLabel, hohandle);
31  if(hohandle.isValid())
32  fHORecHits_ = hohandle.product();
33  else
34  fHORecHits_ = NULL;
35 
37  iEvent.getByLabel(hbheLabel, hehbhandle);
38  if(hehbhandle.isValid())
39  fHBHERecHits_ = hehbhandle.product();
40  else
41  fHBHERecHits_ = NULL;
42 
43  ESHandle<CaloGeometry> geometryHandle;
44  iSetup.get<CaloGeometryRecord>().get(geometryHandle);
45  if(geometryHandle.isValid())
46  geometry_ = geometryHandle.product();
47  else
48  geometry_ = NULL;
49 
50 }
51 
52 
53 double RxCalculator::getRx(const reco::SuperClusterRef cluster, double x, double threshold, double innerR )
54 {
55  using namespace edm;
56  using namespace reco;
57 
58  if(!fHBHERecHits_) {
59 // LogError("RxCalculator") << "Error! Can't get HBHERecHits for event.";
60  return -100;
61  }
62 
63  double SClusterEta = cluster->eta();
64  double SClusterPhi = cluster->phi();
65  double TotalEt = 0;
66 
67  for(size_t index = 0; index < fHBHERecHits_->size(); index++) {
68  const HBHERecHit &rechit = (*fHBHERecHits_)[index];
69  const DetId &detid = rechit.id();
70  const GlobalPoint& hitpoint = geometry_->getPosition(detid);
71  double eta = hitpoint.eta();
72  double phi = hitpoint.phi();
73  double dEta = fabs(eta-SClusterEta);
74  double dPhi = fabs(phi-SClusterPhi);
75  while (dPhi>2*PI) dPhi-=2*PI;
76  if (dPhi>PI) dPhi=2*PI-dPhi;
77 
78  if (dPhi>PI) dPhi=2*PI-dPhi;
79 
80  double dR = sqrt(dEta * dEta + dPhi * dPhi);
81  // veto inner cone///////////////
82  if ( dR < innerR ) continue;
84  if (dR<x*0.1) {
85  double et = rechit.energy()/cosh(eta);
86  if (et<threshold) et=0;
87  TotalEt += et;
88  }
89  }
90 
91  return TotalEt;
92 }
93 
94 double RxCalculator::getROx(const reco::SuperClusterRef cluster, double x,double threshold)
95 {
96  using namespace edm;
97  using namespace reco;
98 
99  if(!fHORecHits_) {
100 // LogError("RxCalculator") << "Error! Can't get HORecHits for event.";
101  return -100;
102  }
103 
104  double SClusterEta = cluster->eta();
105  double SClusterPhi = cluster->phi();
106  double TotalEt = 0;
107 
108  for(size_t index = 0; index < fHORecHits_->size(); index++) {
109  const HORecHit &rechit = (*fHORecHits_)[index];
110  const DetId &detid = rechit.id();
111  const GlobalPoint& hitpoint = geometry_->getPosition(detid);
112  double eta = hitpoint.eta();
113  double phi = hitpoint.phi();
114  double dEta = fabs(eta-SClusterEta);
115  double dPhi = fabs(phi-SClusterPhi);
116  while (dPhi>2*PI) dPhi-=2*PI;
117  if (dPhi>PI) dPhi=2*PI-dPhi;
118 
119  double dR = sqrt(dEta * dEta + dPhi * dPhi);
120  if (dR<x*0.1) {
121  double et = rechit.energy()/cosh(eta);
122  if (et<threshold) et=0;
123  TotalEt += et;
124  }
125  }
126  return TotalEt;
127 }
128 
129 double RxCalculator::getRFx(const reco::SuperClusterRef cluster, double x, double threshold)
130 {
131  using namespace edm;
132  using namespace reco;
133 
134  if(!fHFRecHits_) {
135  LogError("RxCalculator") << "Error! Can't get HFRecHits for event.";
136  return -100;
137  }
138 
139  double SClusterEta = cluster->eta();
140  double SClusterPhi = cluster->phi();
141  double TotalEt = 0;
142 
143  for(size_t index = 0; index < fHFRecHits_->size(); index++) {
144  const HFRecHit &rechit = (*fHFRecHits_)[index];
145  const DetId &detid = rechit.id();
146  const GlobalPoint& hitpoint = geometry_->getPosition(detid);
147  double eta = hitpoint.eta();
148  double phi = hitpoint.phi();
149  double dEta = fabs(eta-SClusterEta);
150  double dPhi = fabs(phi-SClusterPhi);
151  while (dPhi>2*PI) dPhi-=2*PI;
152  if (dPhi>PI) dPhi=2*PI-dPhi;
153 
154 
155  double dR = sqrt(dEta * dEta + dPhi * dPhi);
156  if (dR<x*0.1) {
157  double et = rechit.energy()/cosh(eta);
158  if (et<threshold) et=0;
159  TotalEt += et;
160  }
161  }
162 
163 
164 
165  return TotalEt;
166 }
167 
168 
169 double RxCalculator::getCRx(const reco::SuperClusterRef cluster, double x, double threshold, double innerR )
170 {
171  using namespace edm;
172  using namespace reco;
173 
174 
175  if(!fHBHERecHits_) {
176 // LogError("RxCalculator") << "Error! Can't get HBHERecHits for event.";
177  return -100;
178  }
179 
180  double SClusterEta = cluster->eta();
181  double SClusterPhi = cluster->phi();
182  double TotalEt = 0;
183 
184  for(size_t index = 0; index < fHBHERecHits_->size(); index++) {
185  const HBHERecHit &rechit = (*fHBHERecHits_)[index];
186  const DetId &detid = rechit.id();
187  const GlobalPoint& hitpoint = geometry_->getPosition(detid);
188  double eta = hitpoint.eta();
189  double phi = hitpoint.phi();
190  double dEta = fabs(eta-SClusterEta);
191  double dPhi = fabs(phi-SClusterPhi);
192  while (dPhi>2*PI) dPhi-=2*PI;
193  if (dPhi>PI) dPhi=2*PI-dPhi;
194 
195  if (dEta<x*0.1) {
196  double et = rechit.energy()/cosh(eta);
197  if (et<threshold) et=0;
198  TotalEt += et;
199  }
200  }
201 
202  double Rx = getRx(cluster,x,threshold,innerR);
203  double CRx = Rx - TotalEt * (0.01*x*x - innerR*innerR) / (2 * 2 * 0.1 * x) ;
204 
205  return CRx;
206 }
#define PI
HcalDetId id() const
get the id
Definition: HBHERecHit.h:23
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
double getRx(const reco::SuperClusterRef clus, double i, double threshold, double innerR=0.0)
Definition: RxCalculator.cc:53
#define NULL
Definition: scimark2.h:8
T eta() const
int iEvent
Definition: GenABIO.cc:230
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
float energy() const
Definition: CaloRecHit.h:17
T sqrt(T t)
Definition: SSEVec.h:48
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
RxCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::InputTag &hbheLabel, const edm::InputTag &hfLabel, const edm::InputTag &hoLabel)
Definition: RxCalculator.cc:20
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
double getCRx(const reco::SuperClusterRef clus, double i, double threshold, double innerR=0.0)
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
double getROx(const reco::SuperClusterRef clus, double i, double threshold)
Definition: RxCalculator.cc:94
T eta() const
Definition: PV3DBase.h:76
double getRFx(const reco::SuperClusterRef clus, double i, double threshold)
HcalDetId id() const
Definition: HFRecHit.h:23
Definition: DDAxes.h:10
bool isValid() const
Definition: ESHandle.h:37
HcalDetId id() const
get the id
Definition: HORecHit.h:19
Definition: DDAxes.h:10