CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloTower.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_CALOTOWERS_CALOTOWER_H
2 #define DATAFORMATS_CALOTOWERS_CALOTOWER_H 1
3 
8 #include "Rtypes.h"
9 #include <vector>
10 #include <cmath>
11 
13 
19 // Original author: J. Mans - Minnesota
20 //
21 // Modified: Anton Anastassov (Northwestern)
22 // Make CaloTower inherit from LeafCandidate,
23 // add new members and accessors.
24 
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, double hadE, double outerE,
37  int ecal_tp, int hcal_tp,
38  const PolarLorentzVector& p4,
40 
41  CaloTower(const CaloTowerDetId& id,
42  double emE, double hadE, double outerE,
43  int ecal_tp, int hcal_tp,
44  const LorentzVector& p4,
46 
47 
48  // setters
49  void addConstituent( DetId id ) { constituents_.push_back( id ); }
50  void addConstituents( const std::vector<DetId>& ids );
51  void setEcalTime(int t) { ecalTime_ = t; };
52  void setHcalTime(int t) { hcalTime_ = t; };
53 
54  // set CaloTower status based on the number of
55  // bad/recovered/problematic cells in ECAL and HCAL
56 
57  void setCaloTowerStatus(unsigned int numBadHcalChan,unsigned int numBadEcalChan,
58  unsigned int numRecHcalChan,unsigned int numRecEcalChan,
59  unsigned int numProbHcalChan,unsigned int numProbEcalChan);
60 
61  void setCaloTowerStatus(uint32_t s) { twrStatusWord_ = s; }
62 
63  // set the hottest cell energy in the tower
64  void setHottestCellE(double e) { hottestCellE_ = e; }
65 
66 
67 
68 
69  // getters
70  CaloTowerDetId id() const { return id_; }
71  const std::vector<DetId>& constituents() const { return constituents_; }
72  size_t constituentsSize() const { return constituents_.size(); }
73  DetId constituent( size_t i ) const { return constituents_[ i ]; }
74 
75  // energy contributions from different detectors
76  // energy in HO ("outerEnergy")is not included in "hadEnergy"
77  double emEnergy() const { return emE_ ; }
78  double hadEnergy() const { return hadE_ ; }
79  double outerEnergy() const { return (id_.ietaAbs()<16)? outerE_ : 0.0; }
80 
81  // transverse energies wrt to vtx (0,0,0)
82  double emEt() const { return emE_ * sin( theta() ); }
83  double hadEt() const { return hadE_ * sin( theta() ); }
84  double outerEt() const { return (id_.ietaAbs()<16)? outerE_ * sin( theta() ) : 0.0; }
85 
86 
87  // preserve the inherited default accessors where applicable
88  // (user gets default p4 wrt to vtx (0,0,0) using p4(), etc.
89 
90  using LeafCandidate::p4;
91  using LeafCandidate::p;
92  using LeafCandidate::et;
93 
94 
95  // recalculated wrt user provided vertex Z position;
96 
97  math::PtEtaPhiMLorentzVector p4(double vtxZ) const;
98  double p (double vtxZ) const { return p4(vtxZ).P(); }
99  double et(double vtxZ) const { return p4(vtxZ).Et(); }
100 
101  double emEt(double vtxZ) const { return emE_ * sin(p4(vtxZ).theta()); }
102  double hadEt(double vtxZ) const { return hadE_ * sin(p4(vtxZ).theta()); }
103  double outerEt(double vtxZ) const { return (id_.ietaAbs()<16)? outerE_ * sin(p4(vtxZ).theta()) : 0.0; }
104 
105  // recalculated wrt vertex provided as 3D point
106 
107  math::PtEtaPhiMLorentzVector p4(const Point& v) const;
108  double p (const Point& v) const { return p4(v).P(); }
109  double et(const Point& v) const { return p4(v).Et(); }
110 
111  double emEt(const Point& v) const { return emE_ * sin(p4(v).theta()); }
112  double hadEt(const Point& v) const { return hadE_ * sin(p4(v).theta()); }
113  double outerEt(const Point& v) const { return (id_.ietaAbs()<16)? outerE_ * sin(p4(v).theta()) : 0.0; }
114 
115  double hottestCellE() const { return hottestCellE_; }
116 
117  // Access to p4 comming from HO alone: requested by JetMET to add/subtract HO contributions
118  // to the tower for cases when the tower collection was created without/with HO
119 
121  math::PtEtaPhiMLorentzVector p4_HO(double vtxZ) const;
123 
124 
125  // the reference poins in ECAL and HCAL for direction determination
126  // algorithm and parameters for selecting these points are set in the CaloTowersCreator
127  const GlobalPoint& emPosition() const { return emPosition_ ; }
128  const GlobalPoint& hadPosition() const { return hadPosition_ ; }
129 
130  int emLvl1() const { return emLvl1_; }
131  int hadLv11() const { return hadLvl1_; }
132 
133  // energy contained in depths>1 in the HE for 18<|iEta|<29
134  double hadEnergyHeOuterLayer() const { return (id_.ietaAbs()<18 || id_.ietaAbs()>29)? 0 : outerE_; }
135  double hadEnergyHeInnerLayer() const { return (id_.ietaAbs()<18 || id_.ietaAbs()>29)? 0 : hadE_ - outerE_; }
136 
137  // energy in the tower by HCAL subdetector
138  // This is trivial except for tower 16
139  // needed by JetMET cleanup in AOD.
140  double energyInHB() const; // { return (id_.ietaAbs()<16)? outerE_ : 0.0; }
141  double energyInHE() const;
142  double energyInHF() const;
143  double energyInHO() const;
144 
145 
146 
147  // time (ns) in ECAL/HCAL components of the tower based on weigted sum of the times in the contributing RecHits
148  float ecalTime() const { return float(ecalTime_) * 0.01; }
149  float hcalTime() const { return float(hcalTime_) * 0.01; }
150 
151  // position information on the tower
152  int ieta() const { return id_.ieta(); }
153  int ietaAbs() const { return id_.ietaAbs(); }
154  int iphi() const { return id_.iphi(); }
155  int zside() const { return id_.zside(); }
156 
157  int numCrystals() const;
158 
159  // methods to retrieve status information from the CaloTower:
160  // number of bad/recovered/problematic cells in the tower
161  // separately for ECAL and HCAL
162 
163  unsigned int numBadEcalCells() const { return (twrStatusWord_ & 0x1F); }
164  unsigned int numRecoveredEcalCells() const { return ((twrStatusWord_ >> 5) & 0x1F); }
165  unsigned int numProblematicEcalCells() const { return ((twrStatusWord_ >> 10) & 0x1F); }
166 
167  unsigned int numBadHcalCells() const { return ( (twrStatusWord_ >> 15)& 0x7); }
168  unsigned int numRecoveredHcalCells() const { return ((twrStatusWord_ >> 18) & 0x7); }
169  unsigned int numProblematicHcalCells() const { return ((twrStatusWord_ >> 21) & 0x7); }
170 
171  // the status word itself
172  uint32_t towerStatusWord() const { return twrStatusWord_; }
173 
174 
175 private:
177 
178  uint32_t twrStatusWord_;
179 
180  // positions of assumed EM and HAD shower positions
183 
184  // time
187 
188  float emE_, hadE_, outerE_;
189  // for Jet ID use: hottest cell (ECAl or HCAL)
191 
193  std::vector<DetId> constituents_;
194 
195  // vertex correction of EM and HAD momentum components:
196  // internally used in the transformation of the CaloTower p4
197 
198  // for 3D vertex
201 
202  // taking only z-component
203  math::PtEtaPhiMLorentzVector hadP4(double vtxZ) const;
204  math::PtEtaPhiMLorentzVector emP4(double vtxZ) const;
205 };
206 
207 std::ostream& operator<<(std::ostream& s, const CaloTower& ct);
208 
209 inline bool operator==( const CaloTower & t1, const CaloTower & t2 ) {
210  return t1.id() == t2.id();
211 }
212 
213 #endif
unsigned int numRecoveredEcalCells() const
Definition: CaloTower.h:164
int i
Definition: DBlmapReader.cc:9
float outerE_
Definition: CaloTower.h:188
double energyInHO() const
Definition: CaloTower.cc:220
float hottestCellE_
Definition: CaloTower.h:190
double energyInHF() const
Definition: CaloTower.cc:210
double emEt(const Point &v) const
Definition: CaloTower.h:111
size_t constituentsSize() const
Definition: CaloTower.h:72
double hadEt(const Point &v) const
Definition: CaloTower.h:112
int zside() const
Definition: CaloTower.h:155
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:176
CaloTowerDetId key_type
Definition: CaloTower.h:28
int ieta() const
Definition: CaloTower.h:152
DetId constituent(size_t i) const
Definition: CaloTower.h:73
double hadEt() const
Definition: CaloTower.h:83
float emE_
Definition: CaloTower.h:188
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
Definition: CaloTower.cc:175
float ecalTime() const
Definition: CaloTower.h:148
CaloTower()
Definition: CaloTower.cc:4
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int hcalTime_
Definition: CaloTower.h:186
double outerEt() const
Definition: CaloTower.h:84
math::PtEtaPhiMLorentzVector hadP4(const Point &v) const
Definition: CaloTower.cc:76
int iphi() const
Definition: CaloTower.h:154
unsigned int numRecoveredHcalCells() const
Definition: CaloTower.h:168
unsigned int numBadHcalCells() const
Definition: CaloTower.h:167
bool operator==(const CaloTower &t1, const CaloTower &t2)
Definition: CaloTower.h:209
double hottestCellE() const
Definition: CaloTower.h:115
virtual double theta() const GCC11_FINAL
momentum polar angle
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const GlobalPoint & emPosition() const
Definition: CaloTower.h:127
double p(double vtxZ) const
Definition: CaloTower.h:98
double hadEnergyHeInnerLayer() const
Definition: CaloTower.h:135
float hadE_
Definition: CaloTower.h:188
void setHottestCellE(double e)
Definition: CaloTower.h:64
uint32_t twrStatusWord_
Definition: CaloTower.h:178
double energyInHB() const
Definition: CaloTower.cc:198
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
unsigned int numBadEcalCells() const
Definition: CaloTower.h:163
void addConstituents(const std::vector< DetId > &ids)
Definition: CaloTower.cc:153
double et(const Point &v) const
Definition: CaloTower.h:109
double hadEnergyHeOuterLayer() const
Definition: CaloTower.h:134
double emEnergy() const
Definition: CaloTower.h:77
int emLvl1() const
Definition: CaloTower.h:130
const GlobalPoint & hadPosition() const
Definition: CaloTower.h:128
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
GlobalPoint hadPosition_
Definition: CaloTower.h:182
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
int iphi() const
get the tower iphi
double outerEt(const Point &v) const
Definition: CaloTower.h:113
const std::vector< DetId > & constituents() const
Definition: CaloTower.h:71
double emEt(double vtxZ) const
Definition: CaloTower.h:101
int numCrystals() const
Definition: CaloTower.cc:158
double hadEnergy() const
Definition: CaloTower.h:78
Definition: DetId.h:18
math::PtEtaPhiMLorentzVector p4_HO() const
Definition: CaloTower.cc:146
CaloTowerDetId id() const
Definition: CaloTower.h:70
unsigned int numProblematicEcalCells() const
Definition: CaloTower.h:165
int emLvl1_
Definition: CaloTower.h:192
float hcalTime() const
Definition: CaloTower.h:149
uint32_t towerStatusWord() const
Definition: CaloTower.h:172
unsigned int numProblematicHcalCells() const
Definition: CaloTower.h:169
double energyInHE() const
Definition: CaloTower.cc:204
double outerEt(double vtxZ) const
Definition: CaloTower.h:103
int zside() const
get the z-side of the tower (1/-1)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
math::PtEtaPhiMLorentzVector emP4(const Point &v) const
Definition: CaloTower.cc:93
int ecalTime_
Definition: CaloTower.h:185
int ietaAbs() const
Definition: CaloTower.h:153
void setEcalTime(int t)
Definition: CaloTower.h:51
double p(const Point &v) const
Definition: CaloTower.h:108
int hadLvl1_
Definition: CaloTower.h:192
int hadLv11() const
Definition: CaloTower.h:131
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
double et(double vtxZ) const
Definition: CaloTower.h:99
void setCaloTowerStatus(uint32_t s)
Definition: CaloTower.h:61
int ieta() const
get the tower ieta
void setHcalTime(int t)
Definition: CaloTower.h:52
double emEt() const
Definition: CaloTower.h:82
double hadEt(double vtxZ) const
Definition: CaloTower.h:102
GlobalPoint emPosition_
Definition: CaloTower.h:181
double outerEnergy() const
Definition: CaloTower.h:79
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43
std::vector< DetId > constituents_
Definition: CaloTower.h:193
void addConstituent(DetId id)
Definition: CaloTower.h:49