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  position_(math::XYZPoint(0.,0.,0.))
13 {
14 
15  cornersxyz_.reserve( nCorners_ );
16  for(unsigned i=0; i<nCorners_; i++) {
17  cornersxyz_.push_back( position_ );
18  }
20 }
21 
22 
23 PFRecHit::PFRecHit(unsigned detId,
24  PFLayer::Layer layer,
25  double energy,
26  const math::XYZPoint& position,
27  const math::XYZVector& axisxyz,
28  const vector< math::XYZPoint >& cornersxyz) :
29  detId_(detId),
30  layer_(layer),
31  energy_(energy),
32  time_(-1.),
33  position_(position),
34  axisxyz_(axisxyz),
35  cornersxyz_(cornersxyz)
36 {
38 }
39 
40 PFRecHit::PFRecHit(unsigned detId,
41  PFLayer::Layer layer,
42  double energy,
43  double posx, double posy, double posz,
44  double axisx, double axisy, double axisz) :
45 
46  detId_(detId),
47  layer_(layer),
48  energy_(energy),
49  time_(-1.),
50  position_(posx, posy, posz),
51  axisxyz_(axisx, axisy, axisz) {
52 
53  cornersxyz_.reserve( nCorners_ );
54  for(unsigned i=0; i<nCorners_; i++) {
55  cornersxyz_.push_back( position_ );
56  }
57 
59 
60 }
61 
62 
64  originalRecHit_(other.originalRecHit_),
65  detId_(other.detId_),
66  layer_(other.layer_),
67  energy_(other.energy_),
68  time_(other.time_),
69  position_(other.position_),
70  positionrep_(other.positionrep_),
71  axisxyz_(other.axisxyz_),
72  cornersxyz_(other.cornersxyz_),
73  cornersrep_(other.cornersrep_),
74  neighbours_(other.neighbours_),
75  neighbourInfos_(other.neighbourInfos_),
76  neighbours4_(other.neighbours4_),
77  neighbours8_(other.neighbours8_)
78 {}
79 
80 
81 
83 {}
84 
85 
86 void PFRecHit::setNWCorner( double posx, double posy, double posz ) {
87  setCorner(0, posx, posy, posz);
88 }
89 
90 
91 void PFRecHit::setSWCorner( double posx, double posy, double posz ) {
92  setCorner(1, posx, posy, posz);
93 }
94 
95 
96 void PFRecHit::setSECorner( double posx, double posy, double posz ) {
97  setCorner(2, posx, posy, posz);
98 }
99 
100 
101 void PFRecHit::setNECorner( double posx, double posy, double posz ) {
102  setCorner(3, posx, posy, posz);
103 }
104 
105 
106 void PFRecHit::setCorner( unsigned i, double posx, double posy, double posz ) {
107  assert( cornersxyz_.size() == nCorners_);
108  assert( i<cornersxyz_.size() );
109 
110  cornersxyz_[i] = math::XYZPoint( posx, posy, posz);
111  cornersrep_[i] = REPPoint( cornersxyz_[i].Rho(),
112  cornersxyz_[i].Eta(),
113  cornersxyz_[i].Phi() );
114 }
115 
116 void
118  positionrep_.SetCoordinates( position_.Rho(),
119  position_.Eta(),
120  position_.Phi() );
121  cornersrep_.resize(cornersxyz_.size());
122  for( unsigned i = 0; i < cornersxyz_.size(); ++i ) {
123  cornersrep_[i].SetCoordinates(cornersxyz_[i].Rho(),
124  cornersxyz_[i].Eta(),
125  cornersxyz_[i].Phi());
126  }
127 }
128 
129 void PFRecHit::addNeighbour(short x,short y,short z,const PFRecHitRef& ref) {
130  //bitmask interface to accomodate more advanced naighbour finding [i.e in z as well]
131  //bit 0 side for eta [0 for <=0 , 1 for >0]
132  //bits 1,2,3 : abs(eta) wrt the center
133  //bit 4 side for phi
134  //bits 5,6,7 : abs(phi) wrt the center
135  //bit 8 side for z
136  //bits 9,10,11 : abs(z) wrt the center
137 
138  unsigned short absx = abs(x);
139  unsigned short absy = abs(y);
140  unsigned short absz = abs(z);
141 
142  unsigned short bitmask=0;
143 
144 
145  if (x>0)
146  bitmask = bitmask | 1 ;
147  bitmask = bitmask | (absx << 1);
148  if (y>0)
149  bitmask = bitmask | (1<<4) ;
150  bitmask = bitmask | (absy << 5);
151  if (z>0)
152  bitmask = bitmask | (1<<8) ;
153  bitmask = bitmask | (absz << 9);
154 
155  neighbours_.push_back(ref);
156  neighbourInfos_.push_back(bitmask);
157 
158  if (z==0) {
159  neighbours8_.push_back(ref);
160  //find only the 4 neighbours
161  if (absx+absy==1)
162  neighbours4_.push_back(ref);
163  }
164 }
165 
166 void PFRecHit::size(double& deta, double& dphi) const {
167 
168  double minphi=9999;
169  double maxphi=-9999;
170  double mineta=9999;
171  double maxeta=-9999;
172  for ( unsigned ic=0; ic<cornersxyz_.size(); ++ic ) {
173  double eta = cornersxyz_[ic].Eta();
174  double phi = cornersxyz_[ic].Phi();
175 
176  if(phi>maxphi) maxphi=phi;
177  if(phi<minphi) minphi=phi;
178  if(eta>maxeta) maxeta=eta;
179  if(eta<mineta) mineta=eta;
180  }
181 
182  deta = maxeta - mineta;
183  dphi = maxphi - minphi;
184 }
185 
186 
187 ostream& reco::operator<<(ostream& out, const reco::PFRecHit& hit) {
188 
189  if(!out) return out;
190 
191  // reco::PFRecHit& nshit = const_cast<reco::PFRecHit& >(hit);
192  // const reco::PFRecHit::REPPoint& posrep = nshit.positionREP();
193 
194  const math::XYZPoint& posxyz = hit.position();
195 
196  out<<"hit id:"<<hit.detId()
197  <<" l:"<<hit.layer()
198  <<" E:"<<hit.energy()
199  <<" t:"<<hit.time()
200  <<" rep:"<<posxyz.Rho()<<","<<posxyz.Eta()<<","<<posxyz.Phi()<<"| N:";
201  return out;
202 }
void setSECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:96
int i
Definition: DBlmapReader.cc:9
static const char layer_[]
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< Double32_t > > REPPoint
Definition: PFRecHit.h:39
std::vector< math::XYZPoint > cornersxyz_
rechit cell corners
Definition: PFRecHit.h:190
void setNECorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:101
PFRecHitRefVector neighbours4_
Definition: PFRecHit.h:200
unsigned detId() const
rechit detId
Definition: PFRecHit.h:101
void addNeighbour(short x, short y, short z, const PFRecHitRef &)
Definition: PFRecHit.cc:129
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:197
T eta() const
float float float z
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:104
virtual ~PFRecHit()
destructor
Definition: PFRecHit.cc:82
void setSWCorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:91
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:166
void setNWCorner(double posx, double posy, double posz)
Definition: PFRecHit.cc:86
tuple out
Definition: dbtoconf.py:99
Layer
layer definition
Definition: PFLayer.h:31
const math::XYZPoint & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:123
void calculatePositionREP()
Definition: PFRecHit.cc:117
PFRecHitRefVector neighbours8_
Definition: PFRecHit.h:201
math::XYZPoint position_
rechit cell centre: x, y, z
Definition: PFRecHit.h:181
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:196
std::vector< REPPoint > cornersrep_
rechit cell corners rho/eta/phi
Definition: PFRecHit.h:193
double energy() const
rechit energy
Definition: PFRecHit.h:107
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:64
REPPoint positionrep_
rechit cell centre: rho, eta, phi (transient)
Definition: PFRecHit.h:184
Definition: DDAxes.h:10
static const unsigned nCorners_
number of corners
Definition: PFRecHit.h:205
double time() const
timing for cleaned hits
Definition: PFRecHit.h:111
void setCorner(unsigned i, double posx, double posy, double posz)
set position of one of the corners
Definition: PFRecHit.cc:106
PFRecHit()
default constructor. Sets energy and position to zero
Definition: PFRecHit.cc:7
Definition: DDAxes.h:10