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