File indexing completed on 2024-04-06 12:03:48
0001 #ifndef DATAFORMATS_CALOTOWERS_CALOTOWER_H
0002 #define DATAFORMATS_CALOTOWERS_CALOTOWER_H 1
0003
0004 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0007 #include "DataFormats/Math/interface/Vector3D.h"
0008 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0009 #include "Rtypes.h"
0010 #include <vector>
0011 #include <cmath>
0012
0013 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 class CaloTower : public reco::LeafCandidate {
0027 public:
0028 typedef CaloTowerDetId key_type;
0029
0030
0031 CaloTower();
0032
0033
0034
0035 CaloTower(const CaloTowerDetId& id,
0036 double emE,
0037 double hadE,
0038 double outerE,
0039 int ecal_tp,
0040 int hcal_tp,
0041 const PolarLorentzVector& p4,
0042 const GlobalPoint& emPosition,
0043 const GlobalPoint& hadPosition);
0044
0045 CaloTower(const CaloTowerDetId& id,
0046 double emE,
0047 double hadE,
0048 double outerE,
0049 int ecal_tp,
0050 int hcal_tp,
0051 const LorentzVector& p4,
0052 const GlobalPoint& emPosition,
0053 const GlobalPoint& hadPosition);
0054
0055 CaloTower(CaloTowerDetId id,
0056 float emE,
0057 float hadE,
0058 float outerE,
0059 int ecal_tp,
0060 int hcal_tp,
0061 GlobalVector p3,
0062 float iEnergy,
0063 bool massless,
0064 GlobalPoint emPosition,
0065 GlobalPoint hadPosition);
0066
0067 CaloTower(CaloTowerDetId id,
0068 float emE,
0069 float hadE,
0070 float outerE,
0071 int ecal_tp,
0072 int hcal_tp,
0073 GlobalVector p3,
0074 float iEnergy,
0075 float imass,
0076 GlobalPoint emPosition,
0077 GlobalPoint hadPosition);
0078
0079
0080 void addConstituent(DetId id) { constituents_.push_back(id); }
0081 void addConstituents(const std::vector<DetId>& ids);
0082 void setConstituents(std::vector<DetId>&& ids) { constituents_ = std::move(ids); }
0083 void setEcalTime(int t) { ecalTime_ = t; };
0084 void setHcalTime(int t) { hcalTime_ = t; };
0085 void setHcalSubdet(int lastHB, int lastHE, int lastHF, int lastHO) {
0086 int ct_ieta = ietaAbs();
0087 if (ct_ieta <= lastHB)
0088 subdet_ = HcalBarrel;
0089 else if (ct_ieta <= lastHE)
0090 subdet_ = HcalEndcap;
0091 else if (ct_ieta <= lastHF)
0092 subdet_ = HcalForward;
0093
0094
0095 if (ct_ieta <= lastHO)
0096 inHO_ = true;
0097 else
0098 inHO_ = false;
0099
0100
0101 if (ct_ieta == lastHB)
0102 inHBHEgap_ = true;
0103 else
0104 inHBHEgap_ = false;
0105 }
0106
0107
0108
0109
0110 void setCaloTowerStatus(unsigned int numBadHcalChan,
0111 unsigned int numBadEcalChan,
0112 unsigned int numRecHcalChan,
0113 unsigned int numRecEcalChan,
0114 unsigned int numProbHcalChan,
0115 unsigned int numProbEcalChan);
0116
0117 void setCaloTowerStatus(uint32_t s) { twrStatusWord_ = s; }
0118
0119
0120 void setHottestCellE(double e) { hottestCellE_ = e; }
0121
0122
0123 CaloTowerDetId id() const { return id_; }
0124 const std::vector<DetId>& constituents() const { return constituents_; }
0125 size_t constituentsSize() const { return constituents_.size(); }
0126 DetId constituent(size_t i) const { return constituents_[i]; }
0127
0128
0129
0130 double emEnergy() const { return emE_; }
0131 double hadEnergy() const { return hadE_; }
0132 double outerEnergy() const { return (inHO_) ? outerE_ : 0.0; }
0133
0134
0135 double emEt() const { return emE_ * sin(theta()); }
0136 double hadEt() const { return hadE_ * sin(theta()); }
0137 double outerEt() const { return (inHO_) ? outerE_ * sin(theta()) : 0.0; }
0138
0139
0140
0141
0142 using LeafCandidate::et;
0143 using LeafCandidate::p;
0144 using LeafCandidate::p4;
0145
0146
0147
0148 math::PtEtaPhiMLorentzVector p4(double vtxZ) const;
0149 double p(double vtxZ) const { return p4(vtxZ).P(); }
0150 double et(double vtxZ) const { return p4(vtxZ).Et(); }
0151
0152 double emEt(double vtxZ) const { return emE_ * sin(p4(vtxZ).theta()); }
0153 double hadEt(double vtxZ) const { return hadE_ * sin(p4(vtxZ).theta()); }
0154 double outerEt(double vtxZ) const { return (inHO_) ? outerE_ * sin(p4(vtxZ).theta()) : 0.0; }
0155
0156
0157
0158 math::PtEtaPhiMLorentzVector p4(const Point& v) const;
0159 double p(const Point& v) const { return p4(v).P(); }
0160 double et(const Point& v) const { return p4(v).Et(); }
0161
0162 double emEt(const Point& v) const { return emE_ * sin(p4(v).theta()); }
0163 double hadEt(const Point& v) const { return hadE_ * sin(p4(v).theta()); }
0164 double outerEt(const Point& v) const { return (inHO_) ? outerE_ * sin(p4(v).theta()) : 0.0; }
0165
0166 double hottestCellE() const { return hottestCellE_; }
0167
0168
0169
0170
0171 math::PtEtaPhiMLorentzVector p4_HO() const;
0172 math::PtEtaPhiMLorentzVector p4_HO(double vtxZ) const;
0173 math::PtEtaPhiMLorentzVector p4_HO(const Point& v) const;
0174
0175
0176
0177 const GlobalPoint& emPosition() const { return emPosition_; }
0178 const GlobalPoint& hadPosition() const { return hadPosition_; }
0179
0180 int emLvl1() const { return emLvl1_; }
0181 int hadLv11() const { return hadLvl1_; }
0182
0183
0184 double hadEnergyHeOuterLayer() const { return (subdet_ == HcalEndcap) ? outerE_ : 0; }
0185 double hadEnergyHeInnerLayer() const { return (subdet_ == HcalEndcap) ? hadE_ - outerE_ : 0; }
0186
0187
0188
0189
0190 double energyInHB() const;
0191 double energyInHE() const;
0192 double energyInHF() const;
0193 double energyInHO() const;
0194
0195
0196 float ecalTime() const { return float(ecalTime_) * 0.01; }
0197 float hcalTime() const { return float(hcalTime_) * 0.01; }
0198
0199
0200 int ieta() const { return id_.ieta(); }
0201 int ietaAbs() const { return id_.ietaAbs(); }
0202 int iphi() const { return id_.iphi(); }
0203 int zside() const { return id_.zside(); }
0204
0205 int numCrystals() const;
0206
0207
0208
0209
0210
0211 unsigned int numBadEcalCells() const { return (twrStatusWord_ & 0x1F); }
0212 unsigned int numRecoveredEcalCells() const { return ((twrStatusWord_ >> 5) & 0x1F); }
0213 unsigned int numProblematicEcalCells() const { return ((twrStatusWord_ >> 10) & 0x1F); }
0214
0215 unsigned int numBadHcalCells() const { return ((twrStatusWord_ >> 15) & 0x7); }
0216 unsigned int numRecoveredHcalCells() const { return ((twrStatusWord_ >> 18) & 0x7); }
0217 unsigned int numProblematicHcalCells() const { return ((twrStatusWord_ >> 21) & 0x7); }
0218
0219
0220 uint32_t towerStatusWord() const { return twrStatusWord_; }
0221
0222 private:
0223 CaloTowerDetId id_;
0224
0225 uint32_t twrStatusWord_;
0226
0227
0228 GlobalPoint emPosition_;
0229 GlobalPoint hadPosition_;
0230
0231
0232 HcalSubdetector subdet_{HcalEmpty};
0233 bool inHO_{false}, inHBHEgap_{false};
0234
0235
0236 int ecalTime_;
0237 int hcalTime_;
0238
0239 float emE_, hadE_, outerE_;
0240
0241 float hottestCellE_;
0242
0243 int emLvl1_, hadLvl1_;
0244 std::vector<DetId> constituents_;
0245
0246
0247
0248
0249
0250 math::PtEtaPhiMLorentzVector hadP4(const Point& v) const;
0251 math::PtEtaPhiMLorentzVector emP4(const Point& v) const;
0252
0253
0254 math::PtEtaPhiMLorentzVector hadP4(double vtxZ) const;
0255 math::PtEtaPhiMLorentzVector emP4(double vtxZ) const;
0256 };
0257
0258 std::ostream& operator<<(std::ostream& s, const CaloTower& ct);
0259
0260 inline bool operator==(const CaloTower& t1, const CaloTower& t2) { return t1.id() == t2.id(); }
0261
0262 #endif