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