// GTrackState.hpp #ifndef GTrackState_H #define GTrackState_H // This class represents the state of a reconstructed track at one // point along its trajectory. It consists of // // 1. the relative path distance s // 2. a fit at a surface (ETrack) // 3. the fit status (invalid, optimal, ...) // 4. a chi-square for that fit // 5. smoothing data // 6. an optional cluster // 7. an optional Miss // // The fit at any surface should be an optimal one accounting for // all the preceeding and following clusters. It is *not* a // partial fit including only the preceeding clusters. // // In principle one can obtain an optimal fit for any point outside // the first or last cluster and immediately between any intermediate // adjacent clusters for which smoothing is defined. #include #include #include "trfbase/ETrack.h" #include "d0cluster/ChunkClusterIndex.hpp" #include "trfbase/MissPtr.h" // Temporary definition for Smooth and SmoothPtr. // Users can verify smooth is not defined with SmoothPtr::is_valid(). class Smooth { }; typedef Ptr SmoothPtr; class GTrackState { public: // enums // Flag indicating the status of the track fit. // The first valid status should be recorded, e.g. if a fit is // COMPLETE, FORWARD and OPTIMAL, it is recorded as OPTIMAL. enum FitStatus { BADSTATE, // Entire state is invalid INVALID, // Fit parameters have no meaning OPTIMAL, // Optimal fit to all clusters (with smoothing) FORWARD, // Optimal fit with this and all preceeding clusters BACKWARD, // Optimal fit with this and all following clusters PULL, // Optimal fit with all clusters except this. COMPLETE, // Non-optimal fit to all clusters (e.g. no smoothing) PARTIAL // Fit with a subset of clusters }; public: // Static methods. // Return a string to label a fit status. static std::string name(FitStatus stat); private: // The path distance. double _s; // The track. trf::ETrack _tre; // The fit status. FitStatus _fit_status; // Chi-square. double _chi_square; // Optional smoothing data. SmoothPtr _psmooth; // Optional cluster. ChunkClusterIndex _pclu; // Optional miss. trf::MissPtr _pmiss; public: // Default constructor. // This is for STL--it leaves the state invalid. GTrackState(); // Constructor from s only. // Fit is set invalid and no cluster or miss is assigned. // This is useful for searching sets using s as a comparator. explicit GTrackState(double s); // Constructor from s and track fit. // No cluster or miss. GTrackState(double s, const trf::ETrack& tre, FitStatus fit_status, double chi_square); // Constructor from s, track fit and a cluster. GTrackState(double s, const trf::ETrack& tre, FitStatus fit_status, double chi_square, const ChunkClusterIndex& pclu); // Constructor from s, track fit, chi-square and a miss. GTrackState(double s, const trf::ETrack& tre, FitStatus fit_status, double chi_square, trf::MissPtr pmiss); // Destructor. ~GTrackState(); public: // Drop the fit from the state. // The fit, error and chi-square are zeroed. // The fit status is set INVALID. void drop_fit(); public: // Return if this state is valid. // This is true if the track is valid. bool is_valid() const { return _fit_status != BADSTATE; } // Return if the state is valid and has a valid fit. bool has_valid_fit() const { return is_valid() && _fit_status!=INVALID; } // Return the path distance. double s() const { return _s; } // Return the track. const trf::ETrack& track() const { return _tre; } // Return the fit status. // For most applications, anything but OPTIMAL is suspect. FitStatus fit_status() const { return _fit_status; } // return the chi-square. double chi_square() const { return _chi_square; } // Return the smoother. const SmoothPtr& smoother() const { return _psmooth; } // Return the cluster. const ChunkClusterIndex& cluster() const { return _pclu; } // Return the miss. const trf::MissPtr& miss() const { return _pmiss; } }; // Equality operator. // Requires complete match. bool operator==(const GTrackState& lhs, const GTrackState& rhs); // Inequality operator. inline bool operator!=(const GTrackState& lhs, const GTrackState& rhs) { return ! (lhs == rhs); } // Output stream. std::ostream& operator<<(std::ostream& stream, const GTrackState& rhs); #endif