CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
61  GlobalVector p3,
62  float iEnergy,
63  bool massless,
66 
68  float emE,
69  float hadE,
70  float outerE,
71  int ecal_tp,
72  int hcal_tp,
73  GlobalVector p3,
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
unsigned int numRecoveredEcalCells() const
Definition: CaloTower.h:212
float outerE_
Definition: CaloTower.h:239
double energyInHO() const
Definition: CaloTower.cc:273
float hottestCellE_
Definition: CaloTower.h:241
double energyInHF() const
Definition: CaloTower.cc:261
double emEt(const Point &v) const
Definition: CaloTower.h:162
size_t constituentsSize() const
Definition: CaloTower.h:125
double hadEt(const Point &v) const
Definition: CaloTower.h:163
int zside() const
Definition: CaloTower.h:203
int ietaAbs() const
get the absolute value of the tower ieta
CaloTowerDetId id_
Definition: CaloTower.h:223
CaloTowerDetId key_type
Definition: CaloTower.h:28
int ieta() const
Definition: CaloTower.h:200
DetId constituent(size_t i) const
Definition: CaloTower.h:126
double hadEt() const
Definition: CaloTower.h:136
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
float ecalTime() const
Definition: CaloTower.h:196
CaloTower()
Definition: CaloTower.cc:3
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int hcalTime_
Definition: CaloTower.h:237
double outerEt() const
Definition: CaloTower.h:137
math::PtEtaPhiMLorentzVector hadP4(const Point &v) const
Definition: CaloTower.cc:127
int iphi() const
Definition: CaloTower.h:202
unsigned int numRecoveredHcalCells() const
Definition: CaloTower.h:216
unsigned int numBadHcalCells() const
Definition: CaloTower.h:215
double hottestCellE() const
Definition: CaloTower.h:166
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
const GlobalPoint & emPosition() const
Definition: CaloTower.h:177
double p(double vtxZ) const
Definition: CaloTower.h:149
double hadEnergyHeInnerLayer() const
Definition: CaloTower.h:185
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
uint32_t twrStatusWord_
Definition: CaloTower.h:225
double energyInHB() const
Definition: CaloTower.cc:243
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
unsigned int numBadEcalCells() const
Definition: CaloTower.h:211
double theta() const final
momentum polar angle
void addConstituents(const std::vector< DetId > &ids)
Definition: CaloTower.cc:199
double et(const Point &v) const
Definition: CaloTower.h:160
double hadEnergyHeOuterLayer() const
Definition: CaloTower.h:184
double emEnergy() const
Definition: CaloTower.h:130
int emLvl1() const
Definition: CaloTower.h:180
const GlobalPoint & hadPosition() const
Definition: CaloTower.h:178
GlobalPoint hadPosition_
Definition: CaloTower.h:229
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
def move
Definition: eostools.py:511
int iphi() const
get the tower iphi
HcalSubdetector
Definition: HcalAssistant.h:31
double outerEt(const Point &v) const
Definition: CaloTower.h:164
const std::vector< DetId > & constituents() const
Definition: CaloTower.h:124
void setConstituents(std::vector< DetId > &&ids)
Definition: CaloTower.h:82
double emEt(double vtxZ) const
Definition: CaloTower.h:152
int numCrystals() const
Definition: CaloTower.cc:204
double hadEnergy() const
Definition: CaloTower.h:131
Definition: DetId.h:17
math::PtEtaPhiMLorentzVector p4_HO() const
Definition: CaloTower.cc:193
CaloTowerDetId id() const
Definition: CaloTower.h:123
unsigned int numProblematicEcalCells() const
Definition: CaloTower.h:213
int emLvl1_
Definition: CaloTower.h:243
float hcalTime() const
Definition: CaloTower.h:197
uint32_t towerStatusWord() const
Definition: CaloTower.h:220
unsigned int numProblematicHcalCells() const
Definition: CaloTower.h:217
double energyInHE() const
Definition: CaloTower.cc:252
double outerEt(double vtxZ) const
Definition: CaloTower.h:154
int zside() const
get the z-side of the tower (1/-1)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
bool inHBHEgap_
Definition: CaloTower.h:233
math::PtEtaPhiMLorentzVector emP4(const Point &v) const
Definition: CaloTower.cc:145
int ecalTime_
Definition: CaloTower.h:236
int ietaAbs() const
Definition: CaloTower.h:201
void setEcalTime(int t)
Definition: CaloTower.h:83
double p(const Point &v) const
Definition: CaloTower.h:159
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
int hadLvl1_
Definition: CaloTower.h:243
int hadLv11() const
Definition: CaloTower.h:181
double et(double vtxZ) const
Definition: CaloTower.h:150
bool inHO_
Definition: CaloTower.h:233
void setCaloTowerStatus(uint32_t s)
Definition: CaloTower.h:117
int ieta() const
get the tower ieta
void setHcalTime(int t)
Definition: CaloTower.h:84
HcalSubdetector subdet_
Definition: CaloTower.h:232
double emEt() const
Definition: CaloTower.h:135
double hadEt(double vtxZ) const
Definition: CaloTower.h:153
GlobalPoint emPosition_
Definition: CaloTower.h:228
double outerEnergy() const
Definition: CaloTower.h:132
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