CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecHit.cc
Go to the documentation of this file.
2 using namespace reco;
3 using namespace std;
4 
5 const unsigned PFRecHit::nCorners_ = 4;
6 
8  detId_(0),
10  energy_(0.),
11  time_(-1.),
12  depth_(0),
13  position_(math::XYZPoint(0.,0.,0.))
14 {
15 
16  cornersxyz_.reserve( nCorners_ );
17  for(unsigned i=0; i<nCorners_; i++) {
18  cornersxyz_.push_back( position_ );
19  }
21 }
22 
23 
24 PFRecHit::PFRecHit(unsigned detId,
25  PFLayer::Layer layer,
26  double energy,
27  const math::XYZPoint& position,
28  const math::XYZVector& axisxyz,
29  const vector< math::XYZPoint >& cornersxyz) :
30  detId_(detId),
31  layer_(layer),
32  energy_(energy),
33  time_(-1.),
34  depth_(0),
35  position_(position),
36  axisxyz_(axisxyz),
37  cornersxyz_(cornersxyz)
38 {
40 }
41 
42 PFRecHit::PFRecHit(unsigned detId,
43  PFLayer::Layer layer,
44  double energy,
45  double posx, double posy, double posz,
46  double axisx, double axisy, double axisz) :
47 
48  detId_(detId),
49  layer_(layer),
50  energy_(energy),
51  time_(-1.),
52  depth_(0),
53  position_(posx, posy, posz),
54  axisxyz_(axisx, axisy, axisz) {
55 
56  cornersxyz_.reserve( nCorners_ );
57  for(unsigned i=0; i<nCorners_; i++) {
58  cornersxyz_.push_back( position_ );
59  }
60 
62 
63 }
64 
65 
67  originalRecHit_(other.originalRecHit_),
68  detId_(other.detId_),
69  layer_(other.layer_),
70  energy_(other.energy_),
71  time_(other.time_),
72  depth_(other.depth_),
73  position_(other.position_),
74  positionrep_(other.positionrep_),
75  axisxyz_(other.axisxyz_),
76  cornersxyz_(other.cornersxyz_),
77  cornersrep_(other.cornersrep_),
78  neighbours_(other.neighbours_),
79  neighbourInfos_(other.neighbourInfos_),
80  neighbours4_(other.neighbours4_),
81  neighbours8_(other.neighbours8_)
82 {}
83 
84 
85 
87 {}
88 
89 
90 void PFRecHit::setNWCorner( double posx, double posy, double posz ) {
91  setCorner(0, posx, posy, posz);
92 }
93 
94 
95 void PFRecHit::setSWCorner( double posx, double posy, double posz ) {
96  setCorner(1, posx, posy, posz);
97 }
98 
99 
100 void PFRecHit::setSECorner( double posx, double posy, double posz ) {
101  setCorner(2, posx, posy, posz);
102 }
103 
104 
105 void PFRecHit::setNECorner( double posx, double posy, double posz ) {
106  setCorner(3, posx, posy, posz);
107 }
108 
109 
110 void PFRecHit::setCorner( unsigned i, double posx, double posy, double posz ) {
111  assert( cornersxyz_.size() == nCorners_);
112  assert( i<cornersxyz_.size() );
113 
114  cornersxyz_[i] = math::XYZPoint( posx, posy, posz);
115  cornersrep_[i] = REPPoint( cornersxyz_[i].Rho(),
116  cornersxyz_[i].Eta(),
117  cornersxyz_[i].Phi() );
118 }
119 
120 void
122  positionrep_.SetCoordinates( position_.Rho(),
123  position_.Eta(),
124  position_.Phi() );
125  cornersrep_.resize(cornersxyz_.size());
126  for( unsigned i = 0; i < cornersxyz_.size(); ++i ) {
127  cornersrep_[i].SetCoordinates(cornersxyz_[i].Rho(),
128  cornersxyz_[i].Eta(),
129  cornersxyz_[i].Phi());
130  }
131 }
132 
133 void PFRecHit::addNeighbour(short x,short y,short z,const PFRecHitRef& ref) {
134  //bitmask interface to accomodate more advanced naighbour finding [i.e in z as well]
135  //bit 0 side for eta [0 for <=0 , 1 for >0]
136  //bits 1,2,3 : abs(eta) wrt the center
137  //bit 4 side for phi
138  //bits 5,6,7 : abs(phi) wrt the center
139  //bit 8 side for z
140  //bits 9,10,11 : abs(z) wrt the center
141 
142  unsigned short absx = abs(x);
143  unsigned short absy = abs(y);
144  unsigned short absz = abs(z);
145 
146  unsigned short bitmask=0;
147 
148 
149  if (x>0)
150  bitmask = bitmask | 1 ;
151  bitmask = bitmask | (absx << 1);
152  if (y>0)
153  bitmask = bitmask | (1<<4) ;
154  bitmask = bitmask | (absy << 5);
155  if (z>0)
156  bitmask = bitmask | (1<<8) ;
157  bitmask = bitmask | (absz << 9);
158 
159  neighbours_.push_back(ref);
160  neighbourInfos_.push_back(bitmask);
161 
162  if (z==0) {
163  neighbours8_.push_back(ref);
164  //find only the 4 neighbours
165  if (absx+absy==1)
166  neighbours4_.push_back(ref);
167  }
168 }
169 
170 
171 const PFRecHitRef PFRecHit::getNeighbour(short x,short y,short z) {
172  unsigned short absx = abs(x);
173  unsigned short absy = abs(y);
174  unsigned short absz = abs(z);
175 
176  unsigned short bitmask=0;
177 
178  if (x>0)
179  bitmask = bitmask | 1 ;
180  bitmask = bitmask | (absx << 1);
181  if (y>0)
182  bitmask = bitmask | (1<<4) ;
183  bitmask = bitmask | (absy << 5);
184  if (z>0)
185  bitmask = bitmask | (1<<8) ;
186  bitmask = bitmask | (absz << 9);
187 
188  for (unsigned int i=0;i<neighbourInfos_.size();++i) {
189  if (neighbourInfos_[i] == bitmask)
190  return neighbours_[i];
191  }
192  return PFRecHitRef();
193 }
194 
195 
196 void PFRecHit::size(double& deta, double& dphi) const {
197 
198  double minphi=9999;
199  double maxphi=-9999;
200  double mineta=9999;
201  double maxeta=-9999;
202  for ( unsigned ic=0; ic<cornersxyz_.size(); ++ic ) {
203  double eta = cornersxyz_[ic].Eta();
204  double phi = cornersxyz_[ic].Phi();
205 
206  if(phi>maxphi) maxphi=phi;
207  if(phi<minphi) minphi=phi;
208  if(eta>maxeta) maxeta=eta;
209  if(eta<mineta) mineta=eta;
210  }
211 
212  deta = maxeta - mineta;
213  dphi = maxphi - minphi;
214 }
215 
216 
217 ostream& reco::operator<<(ostream& out, const reco::PFRecHit& hit) {
218 
219  if(!out) return out;
220 
221  // reco::PFRecHit& nshit = const_cast<reco::PFRecHit& >(hit);
222  // const reco::PFRecHit::REPPoint& posrep = nshit.positionREP();
223 
224  const math::XYZPoint& posxyz = hit.position();
225 
226  out<<"hit id:"<<hit.detId()
227  <<" l:"<<hit.layer()
228  <<" E:"<<hit.energy()
229  <<" t:"<<hit.time()
230  <<" rep:"<<posxyz.Rho()<<","<<posxyz.Eta()<<","<<posxyz.Phi()<<"| N:";
231  return out;
232 }
void setSECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:100
int i
Definition: DBlmapReader.cc:9
static const char layer_[]
std::vector< math::XYZPoint > cornersxyz_
rechit cell corners
Definition: PFRecHit.h:202
void setNECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:105
PFRecHitRefVector neighbours4_
Definition: PFRecHit.h:212
unsigned detId() const
rechit detId
Definition: PFRecHit.h:106
assert(m_qm.get())
void addNeighbour(short x, short y, short z, const PFRecHitRef &)
Definition: PFRecHit.cc:133
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:209
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:109
virtual ~PFRecHit()
destructor
Definition: PFRecHit.cc:86
void setSWCorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:95
const PFRecHitRef getNeighbour(short x, short y, short z)
Definition: PFRecHit.cc:171
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:35
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
layer definition for PFRecHit and PFCluster
Definition: PFLayer.h:21
void size(double &deta, double &dphi) const
Definition: PFRecHit.cc:196
edm::Ref< PFRecHitCollection > PFRecHitRef
persistent reference to PFRecHit objects
Definition: PFRecHitFwd.h:15
void setNWCorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:90
Layer
layer definition
Definition: PFLayer.h:31
const math::XYZPoint & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:131
void calculatePositionREP()
Definition: PFRecHit.cc:121
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFRecHit.h:42
PFRecHitRefVector neighbours8_
Definition: PFRecHit.h:213
math::XYZPoint position_
rechit cell centre: x, y, z
Definition: PFRecHit.h:193
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
PFRecHitRefVector neighbours_
indices to existing neighbours (1 common side)
Definition: PFRecHit.h:208
Geom::Phi< T > phi() const
std::vector< REPPoint > cornersrep_
rechit cell corners rho/eta/phi
Definition: PFRecHit.h:205
double energy() const
rechit energy
Definition: PFRecHit.h:112
static int position[264][3]
Definition: ReadPGInfo.cc:509
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
REPPoint positionrep_
rechit cell centre: rho, eta, phi (transient)
Definition: PFRecHit.h:196
static const unsigned nCorners_
number of corners
Definition: PFRecHit.h:217
double time() const
timing for cleaned hits
Definition: PFRecHit.h:116
void setCorner(unsigned i, double posx, double posy, double posz)
set position of one of the corners
Definition: PFRecHit.cc:110
PFRecHit()
default constructor. Sets energy and position to zero
Definition: PFRecHit.cc:7