CMS 3D CMS Logo

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