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