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