48 :o_(o), u_(u), v_(v), finitePlane_(finite)
56 :o_(o), finitePlane_(finite)
88 std::swap(this->
o_, other.
o_);
89 std::swap(this->
u_, other.
u_);
90 std::swap(this->
v_, other.
v_);
174 setNormal( TVector3(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) );
180 return TVector2(
u_*x,
v_*x);
213 if (
u_.Dot(
v_) < 1.E-5)
return;
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()<<
") "
244 static const double detplaneEpsilon = 1.E-5;
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
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
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
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()));
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()));
284 TVector3 dirNorm(dir.Unit());
286 double dirTimesN = dirNorm*normal;
287 if(fabs(dirTimesN)<1.E-6){
288 return TVector2(1.E100,1.E100);
290 double t = 1./dirTimesN * ((
o_-point)*normal);
291 return project(point -
o_ + t * dirNorm);
297 const double& dirX,
const double& dirY,
const double& dirZ,
298 double& u,
double& v)
const {
301 double dirTimesN = dirX*W.X() + dirY*W.Y() + dirZ*W.Z();
302 if(fabs(dirTimesN)<1.E-6){
307 double t = 1./dirTimesN * ((
o_.X()-posX)*W.X() +
308 (
o_.Y()-posY)*W.Y() +
309 (
o_.Z()-posZ)*W.Z());
311 double posOnPlaneX = posX-
o_.X() + t*dirX;
312 double posOnPlaneY = posY-
o_.Y() + t*dirY;
313 double posOnPlaneZ = posZ-
o_.Z() + t*dirZ;
315 u =
u_.X()*posOnPlaneX +
u_.Y()*posOnPlaneY +
u_.Z()*posOnPlaneZ;
316 v =
v_.X()*posOnPlaneX +
v_.Y()*posOnPlaneY +
v_.Z()*posOnPlaneZ;
322 u_.Rotate(angle, normal);
323 v_.Rotate(angle, normal);
337void DetPlane::Streamer(TBuffer &R__b)
345 if (R__b.IsReading()) {
346 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) { }
357 TClass* cl = TClass::Load(R__b);
358 AbsFinitePlane *p = (AbsFinitePlane*)(cl->New());
359 cl->Streamer(p, R__b);
362 R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
364 R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
405 R__b.SetByteCount(R__c, kTRUE);
Abstract base class for finite detector planes.
void swap(DetPlane &other)
void setV(const TVector3 &v)
DetPlane(AbsFinitePlane *finite=NULL)
void rotate(double angle)
rotate u and v around normal. Angle is in rad. More for debugging than for actual use.
TVector3 getNormal() const
boost::scoped_ptr< AbsFinitePlane > finitePlane_
double distance(const TVector3 &point) const
absolute distance from a point to the plane
TVector3 toLab(const TVector2 &x) const
transform from plane coordinates to lab system
void Print(const Option_t *="") const
void reset()
delete finitePlane_ and set O, U, V to default values
void setO(const TVector3 &o)
DetPlane & operator=(DetPlane)
void set(const TVector3 &o, const TVector3 &u, const TVector3 &v)
void setUV(const TVector3 &u, const TVector3 &v)
void setON(const TVector3 &o, const TVector3 &n)
void setU(const TVector3 &u)
TVector2 project(const TVector3 &x) const
projecting a direction onto the plane:
TVector2 LabToPlane(const TVector3 &x) const
transform from Lab system into plane
void sane()
ensures orthonormal coordinates
void setNormal(const TVector3 &n)
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
bool operator==(const DetPlane &lhs, const DetPlane &rhs)
bool operator!=(const DetPlane &lhs, const DetPlane &rhs)