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