CMS 3D CMS Logo

CaloTower.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_CALOTOWERS_CALOTOWER_H
2 #define DATAFORMATS_CALOTOWERS_CALOTOWER_H 1
3 
9 #include "Rtypes.h"
10 #include <vector>
11 #include <cmath>
12 
14 
20 // Original author: J. Mans - Minnesota
21 //
22 // Modified: Anton Anastassov (Northwestern)
23 // Make CaloTower inherit from LeafCandidate,
24 // add new members and accessors.
25 
27 public:
28  typedef CaloTowerDetId key_type; // for SortedCollection
29 
30  // Default constructor
31  CaloTower();
32 
33  // Constructors from values
34 
35  CaloTower(const CaloTowerDetId& id,
36  double emE,
37  double hadE,
38  double outerE,
39  int ecal_tp,
40  int hcal_tp,
41  const PolarLorentzVector& p4,
42  const GlobalPoint& emPosition,
43  const GlobalPoint& hadPosition);
44 
45  CaloTower(const CaloTowerDetId& id,
46  double emE,
47  double hadE,
48  double outerE,
49  int ecal_tp,
50  int hcal_tp,
51  const LorentzVector& p4,
52  const GlobalPoint& emPosition,
53  const GlobalPoint& hadPosition);
54 
56  float emE,
57  float hadE,
58  float outerE,
59  int ecal_tp,
60  int hcal_tp,
62  float iEnergy,
63  bool massless,
66 
68  float emE,
69  float hadE,
70  float outerE,
71  int ecal_tp,
72  int hcal_tp,
74  float iEnergy,
75  float imass,
78 
79  // setters
80  void addConstituent(DetId id) { constituents_.push_back(id); }
81  void addConstituents(const std::vector<DetId>& ids);
82  void setConstituents(std::vector<DetId>&& ids) { constituents_ = std::move(ids); }
83  void setEcalTime(int t) { ecalTime_ = t; };
84  void setHcalTime(int t) { hcalTime_ = t; };
85  void setHcalSubdet(int lastHB, int lastHE, int lastHF, int lastHO) {
86  int ct_ieta = ietaAbs();
87  if (ct_ieta <= lastHB)
89  else if (ct_ieta <= lastHE)
91  else if (ct_ieta <= lastHF)
93 
94  //account for HO separately
95  if (ct_ieta <= lastHO)
96  inHO_ = true;
97  else
98  inHO_ = false;
99 
100  //account for gap/crossover tower separately
101  if (ct_ieta == lastHB)
102  inHBHEgap_ = true;
103  else
104  inHBHEgap_ = false;
105  }
106 
107  // set CaloTower status based on the number of
108  // bad/recovered/problematic cells in ECAL and HCAL
109 
110  void setCaloTowerStatus(unsigned int numBadHcalChan,
111  unsigned int numBadEcalChan,
112  unsigned int numRecHcalChan,
113  unsigned int numRecEcalChan,
114  unsigned int numProbHcalChan,
115  unsigned int numProbEcalChan);
116 
117  void setCaloTowerStatus(uint32_t s) { twrStatusWord_ = s; }
118 
119  // set the hottest cell energy in the tower
120  void setHottestCellE(double e) { hottestCellE_ = e; }
121 
122  // getters
123  CaloTowerDetId id() const { return id_; }
124  const std::vector<DetId>& constituents() const { return constituents_; }
125  size_t constituentsSize() const { return constituents_.size(); }
126  DetId constituent(size_t i) const { return constituents_[i]; }
127 
128  // energy contributions from different detectors
129  // energy in HO ("outerEnergy")is not included in "hadEnergy"
130  double emEnergy() const { return emE_; }
131  double hadEnergy() const { return hadE_; }
132  double outerEnergy() const { return (inHO_) ? outerE_ : 0.0; }
133 
134  // transverse energies wrt to vtx (0,0,0)
135  double emEt() const { return emE_ * sin(theta()); }
136  double hadEt() const { return hadE_ * sin(theta()); }
137  double outerEt() const { return (inHO_) ? outerE_ * sin(theta()) : 0.0; }
138 
139  // preserve the inherited default accessors where applicable
140  // (user gets default p4 wrt to vtx (0,0,0) using p4(), etc.
141 
142  using LeafCandidate::et;
143  using LeafCandidate::p;
144  using LeafCandidate::p4;
145 
146  // recalculated wrt user provided vertex Z position;
147 
148  math::PtEtaPhiMLorentzVector p4(double vtxZ) const;
149  double p(double vtxZ) const { return p4(vtxZ).P(); }
150  double et(double vtxZ) const { return p4(vtxZ).Et(); }
151 
152  double emEt(double vtxZ) const { return emE_ * sin(p4(vtxZ).theta()); }
153  double hadEt(double vtxZ) const { return hadE_ * sin(p4(vtxZ).theta()); }
154  double outerEt(double vtxZ) const { return (inHO_) ? outerE_ * sin(p4(vtxZ).theta()) : 0.0; }
155 
156  // recalculated wrt vertex provided as 3D point
157 
158  math::PtEtaPhiMLorentzVector p4(const Point& v) const;
159  double p(const Point& v) const { return p4(v).P(); }
160  double et(const Point& v) const { return p4(v).Et(); }
161 
162  double emEt(const Point& v) const { return emE_ * sin(p4(v).theta()); }
163  double hadEt(const Point& v) const { return hadE_ * sin(p4(v).theta()); }
164  double outerEt(const Point& v) const { return (inHO_) ? outerE_ * sin(p4(v).theta()) : 0.0; }
165 
166  double hottestCellE() const { return hottestCellE_; }
167 
168  // Access to p4 comming from HO alone: requested by JetMET to add/subtract HO contributions
169  // to the tower for cases when the tower collection was created without/with HO
170 
172  math::PtEtaPhiMLorentzVector p4_HO(double vtxZ) const;
174 
175  // the reference poins in ECAL and HCAL for direction determination
176  // algorithm and parameters for selecting these points are set in the CaloTowersCreator
177  const GlobalPoint& emPosition() const { return emPosition_; }
178  const GlobalPoint& hadPosition() const { return hadPosition_; }
179 
180  int emLvl1() const { return emLvl1_; }
181  int hadLv11() const { return hadLvl1_; }
182 
183  // energy contained in depths>1 in the HE for 18<|iEta|<29
184  double hadEnergyHeOuterLayer() const { return (subdet_ == HcalEndcap) ? outerE_ : 0; }
185  double hadEnergyHeInnerLayer() const { return (subdet_ == HcalEndcap) ? hadE_ - outerE_ : 0; }
186 
187  // energy in the tower by HCAL subdetector
188  // This is trivial except for tower 16
189  // needed by JetMET cleanup in AOD.
190  double energyInHB() const; // { return (id_.ietaAbs()<16)? outerE_ : 0.0; }
191  double energyInHE() const;
192  double energyInHF() const;
193  double energyInHO() const;
194 
195  // time (ns) in ECAL/HCAL components of the tower based on weigted sum of the times in the contributing RecHits
196  float ecalTime() const { return float(ecalTime_) * 0.01; }
197  float hcalTime() const { return float(hcalTime_) * 0.01; }
198 
199  // position information on the tower
200  int ieta() const { return id_.ieta(); }
201  int ietaAbs() const { return id_.ietaAbs(); }
202  int iphi() const { return id_.iphi(); }
203  int zside() const { return id_.zside(); }
204 
205  int numCrystals() const;
206 
207  // methods to retrieve status information from the CaloTower:
208  // number of bad/recovered/problematic cells in the tower
209  // separately for ECAL and HCAL
210 
211  unsigned int numBadEcalCells() const { return (twrStatusWord_ & 0x1F); }
212  unsigned int numRecoveredEcalCells() const { return ((twrStatusWord_ >> 5) & 0x1F); }
213  unsigned int numProblematicEcalCells() const { return ((twrStatusWord_ >> 10) & 0x1F); }
214 
215  unsigned int numBadHcalCells() const { return ((twrStatusWord_ >> 15) & 0x7); }
216  unsigned int numRecoveredHcalCells() const { return ((twrStatusWord_ >> 18) & 0x7); }
217  unsigned int numProblematicHcalCells() const { return ((twrStatusWord_ >> 21) & 0x7); }
218 
219  // the status word itself
220  uint32_t towerStatusWord() const { return twrStatusWord_; }
221 
222 private:
224 
225  uint32_t twrStatusWord_;
226 
227  // positions of assumed EM and HAD shower positions
230 
231  //hcal subdetector info
233  bool inHO_{false}, inHBHEgap_{false};
234 
235  // time
238 
239  float emE_, hadE_, outerE_;
240  // for Jet ID use: hottest cell (ECAl or HCAL)
242 
244  std::vector<DetId> constituents_;
245 
246  // vertex correction of EM and HAD momentum components:
247  // internally used in the transformation of the CaloTower p4
248 
249  // for 3D vertex
252 
253  // taking only z-component
254  math::PtEtaPhiMLorentzVector hadP4(double vtxZ) const;
255  math::PtEtaPhiMLorentzVector emP4(double vtxZ) const;
256 };
257 
258 std::ostream& operator<<(std::ostream& s, const CaloTower& ct);
259 
260 inline bool operator==(const CaloTower& t1, const CaloTower& t2) { return t1.id() == t2.id(); }
261 
262 #endif
float hcalTime() const
Definition: CaloTower.h:197
unsigned int numProblematicEcalCells() const
Definition: CaloTower.h:213
double emEt(double vtxZ) const
Definition: CaloTower.h:152
float outerE_
Definition: CaloTower.h:239
double energyInHO() const
Definition: CaloTower.cc:273
float hottestCellE_
Definition: CaloTower.h:241
double outerEnergy() const
Definition: CaloTower.h:132
double hadEnergyHeInnerLayer() const
Definition: CaloTower.h:185
int ietaAbs() const
get the absolute value of the tower ieta
const std::vector< DetId > & constituents() const
Definition: CaloTower.h:124
double energyInHE() const
Definition: CaloTower.cc:252
CaloTowerDetId id_
Definition: CaloTower.h:223
CaloTowerDetId key_type
Definition: CaloTower.h:28
float emE_
Definition: CaloTower.h:239
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
Definition: CaloTower.cc:221
double et(const Point &v) const
Definition: CaloTower.h:160
double hadEt(double vtxZ) const
Definition: CaloTower.h:153
CaloTower()
Definition: CaloTower.cc:3
math::PtEtaPhiMLorentzVector emP4(const Point &v) const
Definition: CaloTower.cc:145
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int hcalTime_
Definition: CaloTower.h:237
double hadEt(const Point &v) const
Definition: CaloTower.h:163
math::PtEtaPhiMLorentzVector hadP4(const Point &v) const
Definition: CaloTower.cc:127
double hadEt() const
Definition: CaloTower.h:136
double p(double vtxZ) const
Definition: CaloTower.h:149
void setHcalSubdet(int lastHB, int lastHE, int lastHF, int lastHO)
Definition: CaloTower.h:85
const LorentzVector & p4() const final
four-momentum Lorentz vector
float hadE_
Definition: CaloTower.h:239
void setHottestCellE(double e)
Definition: CaloTower.h:120
double outerEt() const
Definition: CaloTower.h:137
bool operator==(const CaloTower &t1, const CaloTower &t2)
Definition: CaloTower.h:260
uint32_t twrStatusWord_
Definition: CaloTower.h:225
unsigned int numProblematicHcalCells() const
Definition: CaloTower.h:217
unsigned int numRecoveredHcalCells() const
Definition: CaloTower.h:216
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double emEt(const Point &v) const
Definition: CaloTower.h:162
double et(double vtxZ) const
Definition: CaloTower.h:150
double p(const Point &v) const
Definition: CaloTower.h:159
const GlobalPoint & emPosition() const
Definition: CaloTower.h:177
double energyInHB() const
Definition: CaloTower.cc:243
double theta() const final
momentum polar angle
void addConstituents(const std::vector< DetId > &ids)
Definition: CaloTower.cc:199
uint32_t towerStatusWord() const
Definition: CaloTower.h:220
GlobalPoint hadPosition_
Definition: CaloTower.h:229
double outerEt(double vtxZ) const
Definition: CaloTower.h:154
HcalSubdetector
Definition: HcalAssistant.h:31
int ietaAbs() const
Definition: CaloTower.h:201
void setConstituents(std::vector< DetId > &&ids)
Definition: CaloTower.h:82
DetId constituent(size_t i) const
Definition: CaloTower.h:126
std::ostream & operator<<(std::ostream &s, const CaloTower &ct)
Definition: CaloTower.cc:280
unsigned int numBadEcalCells() const
Definition: CaloTower.h:211
unsigned int numRecoveredEcalCells() const
Definition: CaloTower.h:212
int zside() const
Definition: CaloTower.h:203
Definition: DetId.h:17
math::PtEtaPhiMLorentzVector p4_HO() const
Definition: CaloTower.cc:193
double hadEnergyHeOuterLayer() const
Definition: CaloTower.h:184
double hottestCellE() const
Definition: CaloTower.h:166
int emLvl1_
Definition: CaloTower.h:243
const GlobalPoint & hadPosition() const
Definition: CaloTower.h:178
int iphi() const
get the tower iphi
double emEnergy() const
Definition: CaloTower.h:130
size_t constituentsSize() const
Definition: CaloTower.h:125
int iphi() const
Definition: CaloTower.h:202
double hadEnergy() const
Definition: CaloTower.h:131
int ieta() const
get the tower ieta
double emEt() const
Definition: CaloTower.h:135
int ieta() const
Definition: CaloTower.h:200
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
bool inHBHEgap_
Definition: CaloTower.h:233
int ecalTime_
Definition: CaloTower.h:236
int emLvl1() const
Definition: CaloTower.h:180
float ecalTime() const
Definition: CaloTower.h:196
void setEcalTime(int t)
Definition: CaloTower.h:83
int hadLv11() const
Definition: CaloTower.h:181
Structure Point Contains parameters of Gaussian fits to DMRs.
int hadLvl1_
Definition: CaloTower.h:243
int zside() const
get the z-side of the tower (1/-1)
int numCrystals() const
Definition: CaloTower.cc:204
double outerEt(const Point &v) const
Definition: CaloTower.h:164
bool inHO_
Definition: CaloTower.h:233
unsigned int numBadHcalCells() const
Definition: CaloTower.h:215
void setCaloTowerStatus(uint32_t s)
Definition: CaloTower.h:117
void setHcalTime(int t)
Definition: CaloTower.h:84
HcalSubdetector subdet_
Definition: CaloTower.h:232
CaloTowerDetId id() const
Definition: CaloTower.h:123
GlobalPoint emPosition_
Definition: CaloTower.h:228
def move(src, dest)
Definition: eostools.py:511
double energyInHF() const
Definition: CaloTower.cc:261
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::vector< DetId > constituents_
Definition: CaloTower.h:244
void addConstituent(DetId id)
Definition: CaloTower.h:80