CMS 3D CMS Logo

HGCalClusterT.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1Trigger_HGCalClusterT_h
2 #define DataFormats_L1Trigger_HGCalClusterT_h
3 
10 #include "Math/Vector3D.h"
11 
12 
13 namespace l1t
14 {
15  template <class C> class HGCalClusterT : public L1Candidate
16  {
17 
18  public:
20 
21  public:
24  int pt=0,
25  int eta=0,
26  int phi=0
27  )
28  : L1Candidate(p4, pt, eta, phi),
29  valid_(true),
30  detId_(0),
31  centre_(0, 0, 0),
32  centreProj_(0., 0., 0.),
33  mipPt_(0),
34  seedMipPt_(0){}
35 
37  valid_(true)
38  {
39  addConstituent(c);
40  }
41 
43 
44  const edm::PtrVector<C>& constituents() const {return constituents_;}
45  const_iterator constituents_begin() const {return constituents_.begin();}
46  const_iterator constituents_end() const {return constituents_.end();}
47  unsigned size() const { return constituents_.size(); }
48 
49  void addConstituent( const edm::Ptr<C>& c )
50  {
51  if( constituents_.empty() )
52  {
53  detId_ = HGCalDetId(c->detId());
54  seedMipPt_ = c->mipPt();
55  }
56 
57  /* update cluster positions */
58  Basic3DVector<float> constituentCentre( c->position() );
59  Basic3DVector<float> clusterCentre( centre_ );
60 
61  clusterCentre = clusterCentre*mipPt_ + constituentCentre*c->mipPt();
62  if( mipPt_ + c->mipPt()!=0 )
63  {
64  clusterCentre /= ( mipPt_ + c->mipPt() ) ;
65  }
66  centre_ = GlobalPoint( clusterCentre );
67 
68  if( clusterCentre.z()!=0 )
69  {
70  centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() );
71  }
72  /* update cluster energies */
73  mipPt_ += c->mipPt();
74 
75  int updatedPt = hwPt() + c->hwPt();
76  setHwPt(updatedPt);
77 
78  math::PtEtaPhiMLorentzVector updatedP4 ( p4() );
79  updatedP4 += c->p4();
80  setP4( updatedP4 );
81 
83 
84  }
85 
86  bool valid() const { return valid_;}
87  void setValid(bool valid) { valid_ = valid;}
88 
89  double mipPt() const { return mipPt_; }
90  double seedMipPt() const { return seedMipPt_; }
91  uint32_t detId() const { return detId_.rawId(); }
92 
93  /* distance in 'cm' */
94  double distance( const l1t::HGCalTriggerCell &tc ) const
95  {
96  return ( tc.position() - centre_ ).mag();
97  }
98 
99  const GlobalPoint& position() const { return centre_; }
100  const GlobalPoint& centre() const { return centre_; }
101  const GlobalPoint& centreProj() const { return centreProj_; }
102 
103  // FIXME: will need to fix places where the shapes are directly accessed
104  // Right now keep shapes() getter as non-const
106  double hOverE() const
107  {
108  double pt_em = 0.;
109  double pt_had = 0.;
110  double hOe = 0.;
111 
112  for(const auto& constituent : constituents())
113  {
114  switch( constituent->subdetId() )
115  {
116  case HGCEE:
117  pt_em += constituent->pt();
118  break;
119  case HGCHEF:
120  pt_had += constituent->pt();
121  break;
122  case HGCHEB:
123  pt_had += constituent->pt();
124  break;
125  default:
126  break;
127  }
128  }
129  if(pt_em>0) hOe = pt_had / pt_em ;
130  else hOe = -1.;
131  return hOe;
132  }
133 
134  uint32_t subdetId() const {return detId_.subdetId();}
135  uint32_t layer() const {return detId_.layer();}
136  int32_t zside() const {return detId_.zside();}
137 
138 
139  /* operators */
140  bool operator<(const HGCalClusterT<C>& cl) const {return mipPt() < cl.mipPt();}
141  bool operator>(const HGCalClusterT<C>& cl) const { return cl<*this; }
142  bool operator<=(const HGCalClusterT<C>& cl) const { return !(cl>*this); }
143  bool operator>=(const HGCalClusterT<C>& cl) const { return !(cl<*this); }
144 
145  private:
146 
147  bool valid_;
151  GlobalPoint centreProj_; // centre projected onto the first HGCal layer
152 
153  double mipPt_;
154  double seedMipPt_;
155 
157 
158  };
159 
160 }
161 
162 #endif
virtual double pt() const final
transverse momentum
double distance(const l1t::HGCalTriggerCell &tc) const
Definition: HGCalClusterT.h:94
const_iterator constituents_end() const
Definition: HGCalClusterT.h:46
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:74
virtual double eta() const final
momentum pseudorapidity
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
unsigned size() const
Definition: HGCalClusterT.h:47
HGCalClusterT(const LorentzVector p4, int pt=0, int eta=0, int phi=0)
Definition: HGCalClusterT.h:23
double hOverE() const
bool empty() const
Is the RefVector empty.
Definition: PtrVectorBase.h:71
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
uint32_t subdetId() const
ClusterShapes shapes_
ClusterShapes & shapes()
delete x;
Definition: CaloConfig.h:22
const GlobalPoint & centreProj() const
const GlobalPoint & position() const
const_iterator begin() const
Definition: PtrVector.h:130
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual double phi() const final
momentum azimuthal angle
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
const_iterator constituents_begin() const
Definition: HGCalClusterT.h:45
int zside() const
get the z-side of the cell (1/-1)
Definition: HGCalDetId.h:51
T z() const
Cartesian z coordinate.
bool operator>(const HGCalClusterT< C > &cl) const
GlobalPoint centreProj_
double seedMipPt() const
Definition: HGCalClusterT.h:90
bool valid() const
Definition: HGCalClusterT.h:86
const GlobalPoint & centre() const
const_iterator end() const
Definition: PtrVector.h:135
double mipPt() const
Definition: HGCalClusterT.h:89
uint32_t detId() const
Definition: HGCalClusterT.h:91
HGCalClusterT(const edm::Ptr< C > &c)
Definition: HGCalClusterT.h:36
edm::PtrVector< C >::const_iterator const_iterator
Definition: HGCalClusterT.h:19
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
GlobalPoint centre_
uint32_t layer() const
void addConstituent(const edm::Ptr< C > &c)
Definition: HGCalClusterT.h:49
int hwPt() const
Definition: L1Candidate.h:48
const edm::PtrVector< C > & constituents() const
Definition: HGCalClusterT.h:44
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
void setHwPt(int pt)
Definition: L1Candidate.h:41
const GlobalPoint & position() const
Definition: HGCalClusterT.h:99
int32_t zside() const
edm::PtrVector< C > constituents_
bool operator>=(const HGCalClusterT< C > &cl) const
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
void setValid(bool valid)
Definition: HGCalClusterT.h:87
int layer() const
get the layer #
Definition: HGCalDetId.h:48