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