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