#ifndef TTrajectory3D_hh #define TTrajectory3D_hh #include "TVector3.h" class TLine3D; class TTrajectoryPoint; class TTrajectory3D: public TObject { public: TTrajectory3D(); virtual ~TTrajectory3D(); class Location { //------------------------------------------------------------------------- //KCDF: // //We modify this class to avoid computation of directions //where they are never needed. //e.g. in THelix3D::newIntersectionWith(plane) // //For this purpose a private member _dirIsComputed (bool) and //a pointer to a trajectory is introduced. //The direction is computed only the first time it is accessed. //(If at all!) // //When the old constructors are used TTrajectory3D::Location //behaves like before, i.e. nothing is computed. // //Kurt Rinnert 09/09/1998 // KarlsRuhe's changes, above, were dangerous as they allowed the // possibilty (not encountered yet, fortunately) of trying to compute a // direction from the stored trajectory pointer *after* it had gone // stale. I replace here _dirIsComputed with _dirIsValid and an `Ominous // Warning' condition if the direction is requested from a location which // does not contain a computed direction. No attempt has been made to // compute this direction. // // Several constructors have been modified to provide ways of // constructing a location minimizing the number of constructors, // destructors and copies of CLHEP objects. // // Chris Green 1998/09/11 public: Location() : __s(0.0),_position(0.0,0.0,0.0),_direction(0.0,0.0,0.0) , _dirIsValid(false) {} // involves an extra copy/destructor over // the one above, I think. Location(double s, TVector3 position, TVector3 direction) : __s(s), _position(position), _direction(direction) , _dirIsValid(true) {} Location(double s, double a, double b, double c, double x, double y, double z) : __s(s), _position(a,b,c), _direction(x,y,z) , _dirIsValid(true) {} // //KR: a new constructor, see comment above // Location(double s, TVector3 position, // const TTrajectory3D* t) : // __s(s), _position(position), _direction(0.0,0.0,0.0), // _traj(t), _dirIsComputed(false) // {} // Replaced by CG 1998/09/11. Also see above comments Location(double s, double a, double b, double c) : __s(s), _position(a,b,c) , _dirIsValid(false) {} ~Location() {} // void setLocation(double s, TVector3 &position, TVector3 &direction) { // __s=s; // _position=position; // _direction=direction; // _dirIsValid=true; // } // Involves an extra copy/destructor over the one above, I think. void setLocation(double s, TVector3& position, TVector3& direction) { __s=s; _position=position; _direction=direction; _dirIsValid=true; } void setLocation(double s, double a, double b, double c, double x, double y, double z) { __s=s; _position.SetX(a); // should avoid any destructors / constructors this way _position.SetY(b); // The set? method should be inlined in CLHEP _position.SetZ(c); _direction.SetX(x); _direction.SetY(y); _direction.SetZ(z); _dirIsValid=true; } void setLocation(double s, double a, double b, double c) { __s=s; _position.SetX(a); // should avoid any destructors / constructors this way _position.SetY(b); // The set? method should be inlined in CLHEP _position.SetZ(c); _dirIsValid=false; } const double & s(void) const { return __s; } const TVector3 & position(void) const { return _position; } const TVector3& direction(void) const { if ( ! _dirIsValid ) { printf(" TTrajectory3D::Location::direction: _dirIsValid is false!\n"); } return _direction; } void Print(Option_t* opt = ""); private: Double_t __s; TVector3 _position; TVector3 _direction; mutable bool _dirIsValid; }; // Get position as a function of // pathlength virtual void GetPosition(TVector3& pos, double s = 0.0) const = 0; // Get direction as a function of // pathlength virtual void GetDirection(TVector3& dir, double s = 0.0) const = 0; // Get both position and location // as a function of pathlength virtual void GetPoint (TTrajectoryPoint* point, double s = 0.0) const = 0; virtual void GetPointAtRho(TTrajectoryPoint* point, double rho ) const; virtual void GetPointAtZ (TTrajectoryPoint* point, double Z ) const; virtual void GetLocation(TTrajectory3D::Location & loc, double s = 0.0) const; // Get the tangent line virtual void getTangent(TLine3D& line, double s=0.0) const; // Get pathlength at specifed distance // from z-axis virtual double GetPathLengthAtRho(double rho) const = 0; virtual double GetPathLengthAtZ (double Z ) const = 0; // Get D0 to a point virtual double getPathLengthTo(const TVector3 &point) const; // Get pathlength to another trajectory virtual double getPathLengthTo(const TTrajectory3D &traj) const; // Get D0 to another trajectory virtual double getDzeroTo(const TVector3 &point) const; // Get D0 to another trajectory virtual double getDzeroTo(const TTrajectory3D &traj) const; // Return a new intersection with a // plane. Deletion is NOT the // responsibility of the caller. // virtual Location * newIntersectionWith(const HepPlane3D &plane) const; // Get the second derivative vector. virtual TVector3 getSecondDerivative(double s = 0.0) const = 0; protected: static const double ECOARSE; // various numbers defining search precision static const double COARSE ; static const double FINE ; static const double EFINE ; static const double EEFINE ; static const double COMP_PREC; // Minimum precision for comparisons static const double NUM_PREC; // Minimum precision for things which *should* be zero ClassDef(TTrajectory3D,1) }; #endif