SND@LHC Software
Loading...
Searching...
No Matches
genfit::DetPlane Class Reference

Detector plane. More...

#include <DetPlane.h>

Inheritance diagram for genfit::DetPlane:
Collaboration diagram for genfit::DetPlane:

Public Member Functions

 DetPlane (AbsFinitePlane *finite=NULL)
 
 DetPlane (const TVector3 &o, const TVector3 &u, const TVector3 &v, AbsFinitePlane *finite=NULL)
 
 DetPlane (const TVector3 &o, const TVector3 &n, AbsFinitePlane *finite=NULL)
 
virtual ~DetPlane ()
 
 DetPlane (const DetPlane &)
 
DetPlaneoperator= (DetPlane)
 
void swap (DetPlane &other)
 
const TVector3 & getO () const
 
const TVector3 & getU () const
 
const TVector3 & getV () const
 
void set (const TVector3 &o, const TVector3 &u, const TVector3 &v)
 
void setO (const TVector3 &o)
 
void setO (double, double, double)
 
void setU (const TVector3 &u)
 
void setU (double, double, double)
 
void setV (const TVector3 &v)
 
void setV (double, double, double)
 
void setUV (const TVector3 &u, const TVector3 &v)
 
void setON (const TVector3 &o, const TVector3 &n)
 
void setFinitePlane (AbsFinitePlane *finite)
 
TVector3 getNormal () const
 
void setNormal (const TVector3 &n)
 
void setNormal (double, double, double)
 
void setNormal (const double &theta, const double &phi)
 
TVector2 project (const TVector3 &x) const
 projecting a direction onto the plane:
 
TVector2 LabToPlane (const TVector3 &x) const
 transform from Lab system into plane
 
TVector3 toLab (const TVector2 &x) const
 transform from plane coordinates to lab system
 
TVector3 dist (const TVector3 &point) const
 
TVector2 straightLineToPlane (const TVector3 &point, const TVector3 &dir) const
 gives u,v coordinates of the intersection point of a straight line with plane
 
void straightLineToPlane (const double &posX, const double &posY, const double &posZ, const double &dirX, const double &dirY, const double &dirZ, double &u, double &v) const
 gives u,v coordinates of the intersection point of a straight line with plane
 
void Print (const Option_t *="") const
 
double distance (const TVector3 &point) const
 absolute distance from a point to the plane
 
double distance (double, double, double) const
 
bool isInActive (const TVector3 &point, const TVector3 &dir) const
 intersect in the active area? C.f. AbsFinitePlane
 
bool isInActive (const double &posX, const double &posY, const double &posZ, const double &dirX, const double &dirY, const double &dirZ) const
 intersect in the active area? C.f. AbsFinitePlane
 
bool isInActive (double u, double v) const
 isInActive methods refer to finite plane. C.f. AbsFinitePlane
 
bool isInActive (const TVector2 &v) const
 isInActive methods refer to finite plane. C.f. AbsFinitePlane
 
bool isFinite () const
 
void rotate (double angle)
 rotate u and v around normal. Angle is in rad. More for debugging than for actual use.
 
void reset ()
 delete finitePlane_ and set O, U, V to default values
 

Private Member Functions

void sane ()
 ensures orthonormal coordinates
 

Private Attributes

TVector3 o_
 
TVector3 u_
 
TVector3 v_
 
boost::scoped_ptr< AbsFinitePlanefinitePlane_
 

Friends

bool operator== (const DetPlane &lhs, const DetPlane &rhs)
 Checks equality of planes by comparing the 9 double values that define them.
 
bool operator!= (const DetPlane &lhs, const DetPlane &rhs)
 returns NOT ==
 

Detailed Description

Detector plane.

A detector plane is the principle object to define coordinate systems for track fitting in genfit. Since a particle trajectory is a one-dimensional object (regardless of any specific parameterization) positions with respect to the track are always measured in a plane.

Which plane is chosen depends on the type of detector. Fixed plane detectors have their detector plane defined by their mechanical setup. While wire chambers or time projection chambers might want to define a detector plane more flexibly.

This class parameterizes a plane in terms of an origin vector o and two plane-spanning directions u and v.

Definition at line 61 of file DetPlane.h.

Constructor & Destructor Documentation

◆ DetPlane() [1/4]

genfit::DetPlane::DetPlane ( AbsFinitePlane finite = NULL)

Definition at line 33 of file DetPlane.cc.

34 :finitePlane_(finite)
35{
36 // default constructor
37 o_.SetXYZ(0.,0.,0.);
38 u_.SetXYZ(1.,0.,0.);
39 v_.SetXYZ(0.,1.,0.);
40 // sane() not needed here
41}
boost::scoped_ptr< AbsFinitePlane > finitePlane_
Definition DetPlane.h:191

◆ DetPlane() [2/4]

genfit::DetPlane::DetPlane ( const TVector3 &  o,
const TVector3 &  u,
const TVector3 &  v,
AbsFinitePlane finite = NULL 
)

Definition at line 44 of file DetPlane.cc.

48 :o_(o), u_(u), v_(v), finitePlane_(finite)
49{
50 sane();
51}
void sane()
ensures orthonormal coordinates
Definition DetPlane.cc:205

◆ DetPlane() [3/4]

genfit::DetPlane::DetPlane ( const TVector3 &  o,
const TVector3 &  n,
AbsFinitePlane finite = NULL 
)

Definition at line 53 of file DetPlane.cc.

56 :o_(o), finitePlane_(finite)
57{
58 setNormal(n);
59}
void setNormal(const TVector3 &n)
Definition DetPlane.cc:166

◆ ~DetPlane()

genfit::DetPlane::~DetPlane ( )
virtual

Definition at line 62 of file DetPlane.cc.

62 {
63 ;
64}

◆ DetPlane() [4/4]

genfit::DetPlane::DetPlane ( const DetPlane rhs)

Definition at line 67 of file DetPlane.cc.

67 :
68 TObject(rhs),
69 o_(rhs.o_),
70 u_(rhs.u_),
71 v_(rhs.v_)
72{
73 if(rhs.finitePlane_)
74 finitePlane_.reset(rhs.finitePlane_->clone());
75 else finitePlane_.reset();
76}

Member Function Documentation

◆ dist()

TVector3 genfit::DetPlane::dist ( const TVector3 &  point) const

Definition at line 199 of file DetPlane.cc.

200{
201 return toLab(LabToPlane(x)) - x;
202}
TVector3 toLab(const TVector2 &x) const
transform from plane coordinates to lab system
Definition DetPlane.cc:190
TVector2 LabToPlane(const TVector3 &x) const
transform from Lab system into plane
Definition DetPlane.cc:184

◆ distance() [1/2]

double genfit::DetPlane::distance ( const TVector3 &  point) const

absolute distance from a point to the plane

Definition at line 268 of file DetPlane.cc.

268 {
269 // |(point - o_)*(u_ x v_)|
270 return fabs( (point.X()-o_.X()) * (u_.Y()*v_.Z() - u_.Z()*v_.Y()) +
271 (point.Y()-o_.Y()) * (u_.Z()*v_.X() - u_.X()*v_.Z()) +
272 (point.Z()-o_.Z()) * (u_.X()*v_.Y() - u_.Y()*v_.X()));
273}

◆ distance() [2/2]

double genfit::DetPlane::distance ( double  x,
double  y,
double  z 
) const

Definition at line 275 of file DetPlane.cc.

275 {
276 // |(point - o_)*(u_ x v_)|
277 return fabs( (x-o_.X()) * (u_.Y()*v_.Z() - u_.Z()*v_.Y()) +
278 (y-o_.Y()) * (u_.Z()*v_.X() - u_.X()*v_.Z()) +
279 (z-o_.Z()) * (u_.X()*v_.Y() - u_.Y()*v_.X()));
280}

◆ getNormal()

TVector3 genfit::DetPlane::getNormal ( ) const

Definition at line 157 of file DetPlane.cc.

158{
159 return u_.Cross(v_);
160}

◆ getO()

const TVector3 & genfit::DetPlane::getO ( ) const
inline

Definition at line 85 of file DetPlane.h.

85{return o_;}

◆ getU()

const TVector3 & genfit::DetPlane::getU ( ) const
inline

Definition at line 86 of file DetPlane.h.

86{return u_;}

◆ getV()

const TVector3 & genfit::DetPlane::getV ( ) const
inline

Definition at line 87 of file DetPlane.h.

87{return v_;}

◆ isFinite()

bool genfit::DetPlane::isFinite ( ) const
inline

Definition at line 171 of file DetPlane.h.

171 {
172 return (finitePlane_.get() != NULL);
173 }

◆ isInActive() [1/4]

bool genfit::DetPlane::isInActive ( const double &  posX,
const double &  posY,
const double &  posZ,
const double &  dirX,
const double &  dirY,
const double &  dirZ 
) const
inline

intersect in the active area? C.f. AbsFinitePlane

Definition at line 152 of file DetPlane.h.

153 {
154 if(finitePlane_.get() == NULL) return true;
155 double u, v;
156 this->straightLineToPlane(posX, posY, posZ, dirX, dirY, dirZ, u, v);
157 return this->isInActive(u, v);
158 }
bool isInActive(const TVector3 &point, const TVector3 &dir) const
intersect in the active area? C.f. AbsFinitePlane
Definition DetPlane.h:146
TVector2 straightLineToPlane(const TVector3 &point, const TVector3 &dir) const
gives u,v coordinates of the intersection point of a straight line with plane
Definition DetPlane.cc:283

◆ isInActive() [2/4]

bool genfit::DetPlane::isInActive ( const TVector2 &  v) const
inline

isInActive methods refer to finite plane. C.f. AbsFinitePlane

Definition at line 167 of file DetPlane.h.

167 {
168 return isInActive(v.X(),v.Y());
169 }

◆ isInActive() [3/4]

bool genfit::DetPlane::isInActive ( const TVector3 &  point,
const TVector3 &  dir 
) const
inline

intersect in the active area? C.f. AbsFinitePlane

Definition at line 146 of file DetPlane.h.

146 {
147 if(finitePlane_.get() == NULL) return true;
148 return this->isInActive( this->straightLineToPlane(point,dir));
149 }

◆ isInActive() [4/4]

bool genfit::DetPlane::isInActive ( double  u,
double  v 
) const
inline

isInActive methods refer to finite plane. C.f. AbsFinitePlane

Definition at line 161 of file DetPlane.h.

161 {
162 if(finitePlane_.get() == NULL) return true;
163 return finitePlane_->isInActive(u,v);
164 }

◆ LabToPlane()

TVector2 genfit::DetPlane::LabToPlane ( const TVector3 &  x) const

transform from Lab system into plane

Definition at line 184 of file DetPlane.cc.

185{
186 return project(x-o_);
187}
TVector2 project(const TVector3 &x) const
projecting a direction onto the plane:
Definition DetPlane.cc:178

◆ operator=()

DetPlane & genfit::DetPlane::operator= ( DetPlane  other)

Definition at line 79 of file DetPlane.cc.

79 {
80 swap(other);
81 return *this;
82}
void swap(DetPlane &other)
Definition DetPlane.cc:85

◆ Print()

void genfit::DetPlane::Print ( const Option_t *  option = "") const

Definition at line 220 of file DetPlane.cc.

221{
222 std::cout<<"DetPlane: "
223 <<"O("<<o_.X()<<", "<<o_.Y()<<", "<<o_.Z()<<") "
224 <<"u("<<u_.X()<<", "<<u_.Y()<<", "<<u_.Z()<<") "
225 <<"v("<<v_.X()<<", "<<v_.Y()<<", "<<v_.Z()<<") "
226 <<"n("<<getNormal().X()<<", "<<getNormal().Y()<<", "<<getNormal().Z()<<") "
227 <<std::endl;
228 if(finitePlane_ != NULL) {
229 finitePlane_->Print(option);
230 }
231
232}
TVector3 getNormal() const
Definition DetPlane.cc:157

◆ project()

TVector2 genfit::DetPlane::project ( const TVector3 &  x) const

projecting a direction onto the plane:

Definition at line 178 of file DetPlane.cc.

179{
180 return TVector2(u_*x, v_*x);
181}

◆ reset()

void genfit::DetPlane::reset ( )

delete finitePlane_ and set O, U, V to default values

Definition at line 329 of file DetPlane.cc.

329 {
330 o_.SetXYZ(0.,0.,0.);
331 u_.SetXYZ(1.,0.,0.);
332 v_.SetXYZ(0.,1.,0.);
333 finitePlane_.reset();
334}

◆ rotate()

void genfit::DetPlane::rotate ( double  angle)

rotate u and v around normal. Angle is in rad. More for debugging than for actual use.

Definition at line 320 of file DetPlane.cc.

320 {
321 TVector3 normal = getNormal();
322 u_.Rotate(angle, normal);
323 v_.Rotate(angle, normal);
324
325 sane();
326}

◆ sane()

void genfit::DetPlane::sane ( )
private

ensures orthonormal coordinates

Definition at line 205 of file DetPlane.cc.

205 {
206 assert(u_!=v_);
207
208 // ensure unit vectors
209 u_.SetMag(1.);
210 v_.SetMag(1.);
211
212 // check if already orthogonal
213 if (u_.Dot(v_) < 1.E-5) return;
214
215 // ensure orthogonal system
216 v_ = getNormal().Cross(u_);
217}

◆ set()

void genfit::DetPlane::set ( const TVector3 &  o,
const TVector3 &  u,
const TVector3 &  v 
)

Definition at line 95 of file DetPlane.cc.

98{
99 o_ = o;
100 u_ = u;
101 v_ = v;
102 sane();
103}

◆ setFinitePlane()

void genfit::DetPlane::setFinitePlane ( AbsFinitePlane finite)
inline

Optionally, set the finite plane definition. This is most important for avoiding fake intersection points in fitting of curlers. This should be implemented for silicon detectors most importantly.

Definition at line 105 of file DetPlane.h.

105{finitePlane_.reset(finite);}

◆ setNormal() [1/3]

void genfit::DetPlane::setNormal ( const double &  theta,
const double &  phi 
)

Definition at line 173 of file DetPlane.cc.

173 {
174 setNormal( TVector3(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) );
175}

◆ setNormal() [2/3]

void genfit::DetPlane::setNormal ( const TVector3 &  n)

Definition at line 166 of file DetPlane.cc.

166 {
167 u_ = n.Orthogonal();
168 v_ = n.Cross(u_);
169 u_.SetMag(1.);
170 v_.SetMag(1.);
171}

◆ setNormal() [3/3]

void genfit::DetPlane::setNormal ( double  X,
double  Y,
double  Z 
)

Definition at line 162 of file DetPlane.cc.

162 {
163 setNormal( TVector3(X,Y,Z) );
164}

◆ setO() [1/2]

void genfit::DetPlane::setO ( const TVector3 &  o)

Definition at line 106 of file DetPlane.cc.

107{
108 o_ = o;
109}

◆ setO() [2/2]

void genfit::DetPlane::setO ( double  X,
double  Y,
double  Z 
)

Definition at line 111 of file DetPlane.cc.

112{
113 o_.SetXYZ(X,Y,Z);
114}

◆ setON()

void genfit::DetPlane::setON ( const TVector3 &  o,
const TVector3 &  n 
)

Definition at line 151 of file DetPlane.cc.

151 {
152 o_ = o;
153 setNormal(n);
154}

◆ setU() [1/2]

void genfit::DetPlane::setU ( const TVector3 &  u)

Definition at line 116 of file DetPlane.cc.

117{
118 u_ = u;
119 sane(); // sets v_ perpendicular to u_
120}

◆ setU() [2/2]

void genfit::DetPlane::setU ( double  X,
double  Y,
double  Z 
)

Definition at line 122 of file DetPlane.cc.

123{
124 u_.SetXYZ(X,Y,Z);
125 sane(); // sets v_ perpendicular to u_
126}

◆ setUV()

void genfit::DetPlane::setUV ( const TVector3 &  u,
const TVector3 &  v 
)

Definition at line 144 of file DetPlane.cc.

145{
146 u_ = u;
147 v_ = v;
148 sane();
149}

◆ setV() [1/2]

void genfit::DetPlane::setV ( const TVector3 &  v)

Definition at line 128 of file DetPlane.cc.

129{
130 v_ = v;
131 u_ = getNormal().Cross(v_);
132 u_ *= -1.;
133 sane();
134}

◆ setV() [2/2]

void genfit::DetPlane::setV ( double  X,
double  Y,
double  Z 
)

Definition at line 136 of file DetPlane.cc.

137{
138 v_.SetXYZ(X,Y,Z);
139 u_ = getNormal().Cross(v_);
140 u_ *= -1.;
141 sane();
142}

◆ straightLineToPlane() [1/2]

void genfit::DetPlane::straightLineToPlane ( const double &  posX,
const double &  posY,
const double &  posZ,
const double &  dirX,
const double &  dirY,
const double &  dirZ,
double &  u,
double &  v 
) const

gives u,v coordinates of the intersection point of a straight line with plane

Definition at line 296 of file DetPlane.cc.

298 {
299
300 TVector3 W = getNormal();
301 double dirTimesN = dirX*W.X() + dirY*W.Y() + dirZ*W.Z();
302 if(fabs(dirTimesN)<1.E-6){//straight line is parallel to plane, so return infinity
303 u = 1.E100;
304 v = 1.E100;
305 return;
306 }
307 double t = 1./dirTimesN * ((o_.X()-posX)*W.X() +
308 (o_.Y()-posY)*W.Y() +
309 (o_.Z()-posZ)*W.Z());
310
311 double posOnPlaneX = posX-o_.X() + t*dirX;
312 double posOnPlaneY = posY-o_.Y() + t*dirY;
313 double posOnPlaneZ = posZ-o_.Z() + t*dirZ;
314
315 u = u_.X()*posOnPlaneX + u_.Y()*posOnPlaneY + u_.Z()*posOnPlaneZ;
316 v = v_.X()*posOnPlaneX + v_.Y()*posOnPlaneY + v_.Z()*posOnPlaneZ;
317}

◆ straightLineToPlane() [2/2]

TVector2 genfit::DetPlane::straightLineToPlane ( const TVector3 &  point,
const TVector3 &  dir 
) const

gives u,v coordinates of the intersection point of a straight line with plane

Definition at line 283 of file DetPlane.cc.

283 {
284 TVector3 dirNorm(dir.Unit());
285 TVector3 normal = getNormal();
286 double dirTimesN = dirNorm*normal;
287 if(fabs(dirTimesN)<1.E-6){//straight line is parallel to plane, so return infinity
288 return TVector2(1.E100,1.E100);
289 }
290 double t = 1./dirTimesN * ((o_-point)*normal);
291 return project(point - o_ + t * dirNorm);
292}

◆ swap()

void genfit::DetPlane::swap ( DetPlane other)

Definition at line 85 of file DetPlane.cc.

85 {
86 // by swapping the members of two classes,
87 // the two classes are effectively swapped
88 std::swap(this->o_, other.o_);
89 std::swap(this->u_, other.u_);
90 std::swap(this->v_, other.v_);
91 this->finitePlane_.swap(other.finitePlane_);
92}

◆ toLab()

TVector3 genfit::DetPlane::toLab ( const TVector2 &  x) const

transform from plane coordinates to lab system

Definition at line 190 of file DetPlane.cc.

191{
192 TVector3 d(o_);
193 d += x.X()*u_;
194 d += x.Y()*v_;
195 return d;
196}

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const DetPlane lhs,
const DetPlane rhs 
)
friend

returns NOT ==

Definition at line 263 of file DetPlane.cc.

263 {
264 return !(lhs==rhs);
265}

◆ operator==

bool operator== ( const DetPlane lhs,
const DetPlane rhs 
)
friend

Checks equality of planes by comparing the 9 double values that define them.

Definition at line 241 of file DetPlane.cc.

241 {
242 if (&lhs == &rhs)
243 return true;
244 static const double detplaneEpsilon = 1.E-5;
245 if(
246 fabs( (lhs.o_.X()-rhs.o_.X()) ) > detplaneEpsilon ||
247 fabs( (lhs.o_.Y()-rhs.o_.Y()) ) > detplaneEpsilon ||
248 fabs( (lhs.o_.Z()-rhs.o_.Z()) ) > detplaneEpsilon
249 ) return false;
250 else if(
251 fabs( (lhs.u_.X()-rhs.u_.X()) ) > detplaneEpsilon ||
252 fabs( (lhs.u_.Y()-rhs.u_.Y()) ) > detplaneEpsilon ||
253 fabs( (lhs.u_.Z()-rhs.u_.Z()) ) > detplaneEpsilon
254 ) return false;
255 else if(
256 fabs( (lhs.v_.X()-rhs.v_.X()) ) > detplaneEpsilon ||
257 fabs( (lhs.v_.Y()-rhs.v_.Y()) ) > detplaneEpsilon ||
258 fabs( (lhs.v_.Z()-rhs.v_.Z()) ) > detplaneEpsilon
259 ) return false;
260 return true;
261}

Member Data Documentation

◆ finitePlane_

boost::scoped_ptr<AbsFinitePlane> genfit::DetPlane::finitePlane_
private

Definition at line 191 of file DetPlane.h.

◆ o_

TVector3 genfit::DetPlane::o_
private

Definition at line 186 of file DetPlane.h.

◆ u_

TVector3 genfit::DetPlane::u_
private

Definition at line 187 of file DetPlane.h.

◆ v_

TVector3 genfit::DetPlane::v_
private

Definition at line 188 of file DetPlane.h.


The documentation for this class was generated from the following files: