CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFRecHit.h
Go to the documentation of this file.
1 #ifndef ParticleFlowReco_PFRecHit_h
2 #define ParticleFlowReco_PFRecHit_h
3 
5 #include <vector>
6 #include <map>
7 #include <memory>
8 #include <iostream>
9 
12 #include "Math/GenVector/PositionVector3D.h"
15 
18 
20 
21 namespace reco {
22 
31  class PFRecHit {
32  public:
38 
39  struct Neighbours {
40  using Pointer = unsigned int const*;
42  Neighbours(Pointer ib, unsigned int n) : b(ib), e(ib + n) {}
44  Pointer begin() const { return b; }
45  Pointer end() const { return e; }
46  unsigned int size() const { return e - b; }
47  };
48 
49  enum { NONE = 0 };
51  PFRecHit() {}
52 
53  PFRecHit(std::shared_ptr<const CaloCellGeometry> caloCell,
54  unsigned int detId,
56  float energy,
57  uint32_t flags = 0)
58  : caloCell_(std::move(caloCell)), detId_(detId), layer_(layer), energy_(energy), flags_(flags) {}
59 
61  PFRecHit(const PFRecHit& other) = default;
62  PFRecHit(PFRecHit&& other) = default;
63  PFRecHit& operator=(const PFRecHit& other) = default;
64  PFRecHit& operator=(PFRecHit&& other) = default;
65 
67  ~PFRecHit() = default;
68 
69  void setEnergy(float energy) { energy_ = energy; }
70 
71  void addNeighbour(short x, short y, short z, unsigned int);
72  unsigned int getNeighbour(short x, short y, short z) const;
73  void setTime(double time) { time_ = time; }
74  void setDepth(int depth) { depth_ = depth; }
75  void clearNeighbours() {
76  neighbours_.clear();
77  neighbourInfos_.clear();
79  }
80 
83 
84  Neighbours neighbours() const { return buildNeighbours(neighbours_.size()); }
85 
86  const std::vector<unsigned short>& neighbourInfos() { return neighbourInfos_; }
87 
89  CaloCellGeometry const& caloCell() const { return *(caloCell_.get()); }
90  bool hasCaloCell() const { return (caloCell_ != nullptr); }
91 
93  unsigned detId() const { return detId_; }
94 
96  PFLayer::Layer layer() const { return layer_; }
97 
99  float energy() const { return energy_; }
100 
102  float time() const { return time_; }
103 
105  int depth() const { return depth_; }
106 
108  double pt2() const { return energy_ * energy_ * (position().perp2() / position().mag2()); }
109 
110  // Detector-dependent status flag
111  uint32_t flags() const { return flags_; }
112 
113  //
114  void setFlags(uint32_t flags) { flags_ = flags; }
115 
117  PositionType const& position() const { return caloCell().getPosition().basicVector(); }
118 
119  RhoEtaPhi const& positionREP() const { return caloCell().repPos(); }
120 
122  CornersVec const& getCornersXYZ() const { return caloCell().getCorners(); }
123 
124  RepCorners const& getCornersREP() const { return caloCell().getCornersREP(); }
125 
127  bool operator>=(const PFRecHit& rhs) const { return (energy_ >= rhs.energy_); }
128 
130  bool operator>(const PFRecHit& rhs) const { return (energy_ > rhs.energy_); }
131 
133  bool operator<=(const PFRecHit& rhs) const { return (energy_ <= rhs.energy_); }
134 
136  bool operator<(const PFRecHit& rhs) const { return (energy_ < rhs.energy_); }
137 
138  private:
139  Neighbours buildNeighbours(unsigned int n) const { return Neighbours(neighbours_.data(), n); }
140 
142  std::shared_ptr<const CaloCellGeometry> caloCell_ = nullptr;
143 
145  unsigned int detId_ = 0;
146 
149 
151  float energy_ = 0;
152 
154  float time_ = -1;
155 
157  int depth_ = 0;
158 
160  std::vector<unsigned int> neighbours_;
161  std::vector<unsigned short> neighbourInfos_;
162 
163  //Caching the neighbours4/8 per request of Lindsey
164  unsigned int neighbours4_ = 0;
165  unsigned int neighbours8_ = 0;
166 
167  // Detector-dependent hit status flag
168  uint32_t flags_ = 0;
169  };
170 
171 } // namespace reco
172 std::ostream& operator<<(std::ostream& out, const reco::PFRecHit& hit);
173 
174 #endif
EZArrayFL< GlobalPoint > CornersVec
float energy_
rechit energy
Definition: PFRecHit.h:151
void setDepth(int depth)
Definition: PFRecHit.h:74
BaseClass::BasicVectorType BasicVectorType
Definition: Point3DBase.h:17
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:161
Pointer begin() const
Definition: PFRecHit.h:44
int ib
Definition: cuy.py:661
double pt2() const
rechit momentum transverse to the beam, squared.
Definition: PFRecHit.h:108
std::vector< unsigned int > neighbours_
indices to existing neighbours (1 common side)
Definition: PFRecHit.h:160
unsigned int neighbours4_
Definition: PFRecHit.h:164
float time() const
timing for cleaned hits
Definition: PFRecHit.h:102
unsigned detId() const
rechit detId
Definition: PFRecHit.h:93
RepCorners const & getCornersREP() const
Definition: PFRecHit.h:124
PFRecHit & operator=(const PFRecHit &other)=default
T perp2() const
Squared magnitude of transverse component.
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
int depth_
depth
Definition: PFRecHit.h:157
void addNeighbour(short x, short y, short z, unsigned int)
Definition: PFRecHit.cc:5
unsigned int detId_
cell detid
Definition: PFRecHit.h:145
uint32_t flags_
Definition: PFRecHit.h:168
PFLayer::Layer layer_
rechit layer
Definition: PFRecHit.h:148
std::shared_ptr< const CaloCellGeometry > caloCell_
cell geometry
Definition: PFRecHit.h:142
Pointer end() const
Definition: PFRecHit.h:45
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
bool operator<=(const PFRecHit &rhs) const
comparison &lt;= operator
Definition: PFRecHit.h:133
unsigned int getNeighbour(short x, short y, short z) const
Definition: PFRecHit.cc:46
bool operator<(const PFRecHit &rhs) const
comparison &lt; operator
Definition: PFRecHit.h:136
PositionType const & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:117
RhoEtaPhi const & repPos() const
unsigned int neighbours8_
Definition: PFRecHit.h:165
int depth() const
depth for segemntation
Definition: PFRecHit.h:105
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:96
RepCorners const & getCornersREP() const
void clearNeighbours()
Definition: PFRecHit.h:75
unsigned int const * Pointer
Definition: PFRecHit.h:40
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
Neighbours buildNeighbours(unsigned int n) const
Definition: PFRecHit.h:139
float time_
time
Definition: PFRecHit.h:154
def move
Definition: eostools.py:511
bool hasCaloCell() const
Definition: PFRecHit.h:90
Neighbours neighbours8() const
Definition: PFRecHit.h:82
void setFlags(uint32_t flags)
Definition: PFRecHit.h:114
std::array< RhoEtaPhi, k_cornerSize > RepCorners
float energy() const
rechit energy
Definition: PFRecHit.h:99
void setTime(double time)
Definition: PFRecHit.h:73
PFRecHit(std::shared_ptr< const CaloCellGeometry > caloCell, unsigned int detId, PFLayer::Layer layer, float energy, uint32_t flags=0)
Definition: PFRecHit.h:53
unsigned int size() const
Definition: PFRecHit.h:46
CaloCellGeometry::RepCorners RepCorners
Definition: PFRecHit.h:35
Layer
layer definition
Definition: PFLayer.h:29
uint32_t flags() const
Definition: PFRecHit.h:111
bool operator>=(const PFRecHit &rhs) const
comparison &gt;= operator
Definition: PFRecHit.h:127
RepCorners REPPointVector
Definition: PFRecHit.h:36
bool operator>(const PFRecHit &rhs) const
comparison &gt; operator
Definition: PFRecHit.h:130
CornersVec const & getCorners() const
Returns the corner points of this cell&#39;s volume.
~PFRecHit()=default
destructor
void setEnergy(float energy)
Definition: PFRecHit.h:69
CaloCellGeometry const & caloCell() const
calo cell
Definition: PFRecHit.h:89
Neighbours(Pointer ib, unsigned int n)
Definition: PFRecHit.h:42
const std::vector< unsigned short > & neighbourInfos()
Definition: PFRecHit.h:86
Neighbours neighbours() const
Definition: PFRecHit.h:84
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
Neighbours neighbours4() const
Definition: PFRecHit.h:81
RhoEtaPhi const & positionREP() const
Definition: PFRecHit.h:119
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
PFRecHit()
default constructor. Sets energy and position to zero
Definition: PFRecHit.h:51
CornersVec const & getCornersXYZ() const
rechit corners
Definition: PFRecHit.h:122