// VTrack.h #ifndef VTrack_H #define VTrack_H // TRF track vector without error. // // Data includes a surface pointer _psrf, a 5-vector _vec and a direction. // All are managed internally. // // The direction attribute is initially set undefined and may be defined // with methods set_backward() or set_forward(). However, the actual // direction of the track as returned by is_valid(), is_forward() and // is_backward() is obtained by asking the surface. The direction // attribute is used only if the surface returns undefined. #include "ref_count/RefCounter.hpp" #include "SurfacePtr.h" #include "TrackVector.h" #include "TrackSurfaceDirection.h" #include class SpacePoint; class SpacePath; namespace trf { class VTrackData; class VTrack : public RefCounter { private: // methods // set surface from clone // direction attribute is not set undefined void set_surface_from_clone(const Surface& srf); protected: // attributes // Surface pointer. // Zero indicates track in invalid state of default constructor. SurfacePtr _psrf; // Track 5-vector. TrackVector _vec; // Direction of the track relative to the surface. // This is need because track parameters may be ambiguous. TrackSurfaceDirection _dir; // Arbitrary data. Typically used to record history of track to aid // in propagation or fitting. // Null if no such data has been added. // This class manages the data object. VTrackData* _pdata; public: // methods // Default constructor. // Leaves track in invalid state. VTrack(); // construct a track vector from a surface #ifndef DEFECT_NO_EXPLICIT explicit #endif VTrack(const SurfacePtr& psrf); // constructor from a surface and a vector VTrack(const SurfacePtr& psrf, const TrackVector& vec); // constructor from a surface, vector and direction VTrack(const SurfacePtr& psrf, const TrackVector& vec, TrackSurfaceDirection dir); // copy constructor VTrack(const VTrack& trv); // assignment operator VTrack& operator=(const VTrack& trv); // destructor virtual ~VTrack(); // output stream void ostr(std::ostream& stream, bool call_from_subclass =false) const; // Return true if track is valid. // To be valid, the surface and direction must be defined. bool is_valid() const; // set surface // direction attribute is set undefined void set_surface(const SurfacePtr& psrf); // get surface const SurfacePtr& get_surface( ) const { return _psrf; }; // set vector // direction attribute is set undefined void set_vector(const TrackVector& vec); // set vector and keep the current direction void set_vector_and_keep_direction(const TrackVector& vec); // get vector const TrackVector& get_vector() const { return _vec; }; // return a component of the vector double get_vector(int i) const { assert( i>=0 && i<5 ); return _vec(i); }; // set direction forward void set_forward() { _dir = TSD_FORWARD; }; // set direction backward void set_backward() { _dir = TSD_BACKWARD; } // is track direction same as surface bool is_forward() const; // is track direction opposite that of surface? bool is_backward() const; // get the space point SpacePoint space_point() const; // get the space vector SpacePath space_vector() const; // Return q/p in 1/GeV/c. double qoverp() const; // Return if the track has extra data. bool has_data() const; // Return the data. VTrackData* get_data(); const VTrackData* get_data() const; // Drop (and delete) the extra data. void drop_data(); // Add extra data. // This class takes management of the data object. // Existing data is deleted. void set_data(VTrackData* pdata); }; } // end namespace trf // Output stream. std::ostream& operator<<(std::ostream& stream, const trf::VTrack& trv); // equality bool operator==(const trf::VTrack& trv1, const trf::VTrack& trv2); // inequality bool operator!=(const trf::VTrack& trv1, const trf::VTrack& trv2); #endif