CMS 3D CMS Logo

CaloTower.cc
Go to the documentation of this file.
2 
4  emE_ = 0;
5  hadE_ = 0;
6  outerE_ = 0;
7  emLvl1_ = 0;
8  hadLvl1_ = 0;
9 }
10 
12  double emE,
13  double hadE,
14  double outerE,
15  int ecal_tp,
16  int hcal_tp,
17  const PolarLorentzVector& p4,
18  const GlobalPoint& emPos,
19  const GlobalPoint& hadPos)
20  : LeafCandidate(0, p4, Point(0, 0, 0)),
21  id_(id),
22  emPosition_(emPos),
23  hadPosition_(hadPos),
24  emE_(emE),
25  hadE_(hadE),
26  outerE_(outerE),
27  emLvl1_(ecal_tp),
28  hadLvl1_(hcal_tp) {}
29 
31  double emE,
32  double hadE,
33  double outerE,
34  int ecal_tp,
35  int hcal_tp,
36  const LorentzVector& p4,
37  const GlobalPoint& emPos,
38  const GlobalPoint& hadPos)
39  : LeafCandidate(0, p4, Point(0, 0, 0)),
40  id_(id),
41  emPosition_(emPos),
42  hadPosition_(hadPos),
43  emE_(emE),
44  hadE_(hadE),
45  outerE_(outerE),
46  emLvl1_(ecal_tp),
47  hadLvl1_(hcal_tp) {}
48 
50  float emE,
51  float hadE,
52  float outerE,
53  int ecal_tp,
54  int hcal_tp,
56  float iEnergy,
57  bool massless,
58  GlobalPoint emPos,
59  GlobalPoint hadPos)
60  : LeafCandidate(0, p3, iEnergy, massless, Point(0, 0, 0)),
61  id_(id),
62  emPosition_(emPos),
63  hadPosition_(hadPos),
64  emE_(emE),
65  hadE_(hadE),
66  outerE_(outerE),
67  emLvl1_(ecal_tp),
68  hadLvl1_(hcal_tp) {}
69 
71  float emE,
72  float hadE,
73  float outerE,
74  int ecal_tp,
75  int hcal_tp,
77  float iEnergy,
78  float imass,
79  GlobalPoint emPos,
80  GlobalPoint hadPos)
81  : LeafCandidate(0, p3, iEnergy, imass, Point(0, 0, 0)),
82  id_(id),
83  emPosition_(emPos),
84  hadPosition_(hadPos),
85  emE_(emE),
86  hadE_(hadE),
87  outerE_(outerE),
88  emLvl1_(ecal_tp),
89  hadLvl1_(hcal_tp) {}
90 
91 // recalculated momentum-related quantities wrt user provided vertex Z position
92 
94  // note: for now we use the same position for HO as for the other detectors
95 
96  double hcalTot;
97  if (inHO_)
98  hcalTot = (energy() - emE_);
99  else
100  hcalTot = hadE_;
101 
102  if (hcalTot > 0) {
103  double ctgTheta = (hadPosition_.z() - vtxZ) / hadPosition_.perp();
104  double newEta = asinh(ctgTheta);
105  double pf = 1.0 / cosh(newEta);
106 
107  return PolarLorentzVector(hcalTot * pf, newEta, hadPosition_.phi(), 0.0);
108  }
109 
110  return math::PtEtaPhiMLorentzVector(0, 0, 0, 0);
111 }
112 
114  if (emE_ > 0) {
115  double ctgTheta = (emPosition_.z() - vtxZ) / emPosition_.perp();
116  double newEta = asinh(ctgTheta);
117  double pf = 1.0 / cosh(newEta);
118 
119  return math::PtEtaPhiMLorentzVector(emE_ * pf, newEta, emPosition_.phi(), 0.0);
120  }
121 
122  return math::PtEtaPhiMLorentzVector(0, 0, 0, 0);
123 }
124 
125 // recalculated momentum-related quantities wrt user provided 3D vertex
126 
128  // note: for now we use the same position for HO as for the other detectors
129 
130  double hcalTot;
131  if (inHO_)
132  hcalTot = (energy() - emE_);
133  else
134  hcalTot = hadE_;
135 
136  if (hcalTot > 0) {
137  GlobalPoint p(v.x(), v.y(), v.z());
139  return math::PtEtaPhiMLorentzVector(hcalTot * sin(dir.theta()), dir.eta(), dir.phi(), 0.0);
140  }
141 
142  return math::PtEtaPhiMLorentzVector(0, 0, 0, 0);
143 }
144 
146  if (emE_ > 0) {
147  GlobalPoint p(v.x(), v.y(), v.z());
149  return math::PtEtaPhiMLorentzVector(emE_ * sin(dir.theta()), dir.eta(), dir.phi(), 0.0);
150  }
151 
152  return math::PtEtaPhiMLorentzVector(0, 0, 0, 0);
153 }
154 
156  if (subdet_ == HcalBarrel || subdet_ == HcalEndcap) {
157  return (emP4(vtxZ) + hadP4(vtxZ));
158  }
159  // em and had energy in HF are defined in a special way
160  double ctgTheta =
161  (emPosition_.z() - vtxZ) / emPosition_.perp(); // em and had positions in HF are forced to be the same
162  double newEta = asinh(ctgTheta);
163  double pf = 1.0 / cosh(newEta);
164  return math::PtEtaPhiMLorentzVector(p4().energy() * pf, newEta, emPosition_.phi(), 0.0);
165 }
166 
168  if (subdet_ == HcalBarrel || subdet_ == HcalEndcap) {
169  return emP4(v) + hadP4(v);
170  }
171  // em and had energy in HF are defined in a special way
172  GlobalPoint p(v.x(), v.y(), v.z());
173  math::XYZVector dir = math::XYZVector(emPosition_ - p); // em and had positions in HF are forced to be the same
174  return math::PtEtaPhiMLorentzVector(p4().energy() * sin(dir.theta()), dir.eta(), dir.phi(), 0.0);
175 }
176 
177 // p4 contribution from HO alone (note: direction is always taken to be the same as used for HB.)
178 
180  if (!inHO_ || outerE_ < 0)
181  return math::PtEtaPhiMLorentzVector(0, 0, 0, 0);
182 
183  GlobalPoint p(v.x(), v.y(), v.z());
185  return math::PtEtaPhiMLorentzVector(outerE_ * sin(dir.theta()), dir.eta(), dir.phi(), 0.0);
186 }
187 
189  Point p(0, 0, vtxZ);
190  return p4_HO(p);
191 }
192 
194  if (!inHO_ || outerE_ < 0)
195  return math::PtEtaPhiMLorentzVector(0.0, 0.0, 0.0, 0.0);
197 }
198 
199 void CaloTower::addConstituents(const std::vector<DetId>& ids) {
200  constituents_.reserve(constituents_.size() + ids.size());
201  constituents_.insert(constituents_.end(), ids.begin(), ids.end());
202 }
203 
205  if (subdet_ == HcalForward)
206  return 0;
207 
208  int nC = 0;
209  std::vector<DetId>::const_iterator it = constituents_.begin();
210  for (; it != constituents_.end(); ++it) {
211  if (it->det() == DetId::Ecal)
212  ++nC;
213  }
214 
215  return nC;
216 }
217 
218 // Set the CaloTower status word from the number of bad/recovered/problematic
219 // cells in HCAL and ECAL.
220 
221 void CaloTower::setCaloTowerStatus(unsigned int numBadHcalChan,
222  unsigned int numBadEcalChan,
223  unsigned int numRecHcalChan,
224  unsigned int numRecEcalChan,
225  unsigned int numProbHcalChan,
226  unsigned int numProbEcalChan) {
227  twrStatusWord_ = 0x0;
228 
229  twrStatusWord_ |= (numBadEcalChan & 0x1F);
230  twrStatusWord_ |= ((numRecEcalChan & 0x1F) << 5);
231  twrStatusWord_ |= ((numProbEcalChan & 0x1F) << 10);
232  twrStatusWord_ |= ((numBadHcalChan & 0x7) << 15);
233  twrStatusWord_ |= ((numRecHcalChan & 0x7) << 18);
234  twrStatusWord_ |= ((numProbHcalChan & 0x7) << 21);
235 
236  return;
237 }
238 
239 // energy in the tower by HCAL subdetector
240 // This is trivia except for tower 16
241 // needed by JetMET cleanup in AOD.
242 
243 double CaloTower::energyInHB() const {
244  if (inHBHEgap_)
245  return hadE_ - outerE_;
246  else if (subdet_ == HcalBarrel)
247  return hadE_;
248  else
249  return 0.0;
250 }
251 
252 double CaloTower::energyInHE() const {
253  if (inHBHEgap_)
254  return outerE_;
255  else if (subdet_ == HcalEndcap)
256  return hadE_;
257  else
258  return 0.0;
259 }
260 
261 double CaloTower::energyInHF() const {
262  if (subdet_ == HcalForward)
263  return energy();
264  else
265  return 0.0;
266 }
267 
268 // this is actual energy contributed to the tower
269 // (outerEnergy() returns HO energy regardless if it is used or not)
270 // Note: rounding error may lead to values not identically equal to zero
271 // when HO was not used
272 
273 double CaloTower::energyInHO() const {
274  if (inHO_)
275  return (energy() - hadE_ - emE_);
276  else
277  return 0.0;
278 }
279 
280 std::ostream& operator<<(std::ostream& s, const CaloTower& ct) {
281  return s << ct.id() << ":" << ct.et() << " GeV ET (EM=" << ct.emEt() << " HAD=" << ct.hadEt()
282  << " OUTER=" << ct.outerEt() << ") (" << ct.eta() << "," << ct.phi() << ")";
283 }
float outerE_
Definition: CaloTower.h:239
double energyInHO() const
Definition: CaloTower.cc:273
T perp() const
Definition: PV3DBase.h:69
double energyInHE() const
Definition: CaloTower.cc:252
T z() const
Definition: PV3DBase.h:61
float emE_
Definition: CaloTower.h:239
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
Definition: CaloTower.cc:221
CaloTower()
Definition: CaloTower.cc:3
math::PtEtaPhiMLorentzVector emP4(const Point &v) const
Definition: CaloTower.cc:145
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: LeafCandidate.h:25
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
math::PtEtaPhiMLorentzVector hadP4(const Point &v) const
Definition: CaloTower.cc:127
const LorentzVector & p4() const final
four-momentum Lorentz vector
float hadE_
Definition: CaloTower.h:239
uint32_t twrStatusWord_
Definition: CaloTower.h:225
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double energyInHB() const
Definition: CaloTower.cc:243
void addConstituents(const std::vector< DetId > &ids)
Definition: CaloTower.cc:199
double p() const final
magnitude of momentum vector
std::ostream & operator<<(std::ostream &s, const CaloTower &ct)
Definition: CaloTower.cc:280
GlobalPoint hadPosition_
Definition: CaloTower.h:229
math::PtEtaPhiMLorentzVector p4_HO() const
Definition: CaloTower.cc:193
int emLvl1_
Definition: CaloTower.h:243
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
bool inHBHEgap_
Definition: CaloTower.h:233
Structure Point Contains parameters of Gaussian fits to DMRs.
int hadLvl1_
Definition: CaloTower.h:243
int numCrystals() const
Definition: CaloTower.cc:204
bool inHO_
Definition: CaloTower.h:233
HcalSubdetector subdet_
Definition: CaloTower.h:232
GlobalPoint emPosition_
Definition: CaloTower.h:228
double energyInHF() const
Definition: CaloTower.cc:261
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
double energy() const final
energy
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::vector< DetId > constituents_
Definition: CaloTower.h:244