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