CMS 3D CMS Logo

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