// CrossStat.h #ifndef CrossStat_H #define CrossStat_H // // This class describes the crossing of a track with a surface. // It is characterized by seven boolean variables and provide methods // to fetch the state of each. // // The variables include: // // Surface: // at - the track and surface have the same pure surface // // Normal: // on - the track vector is on the surface // inside - the track vector is inside the surface // outside - the track vector is outside the surface // // Boundary: // bounds_checked - boundaries have been checked // in_bounds - at surface and within boundaries // out_of_bounds - at surface and outside boundaries // // The vector state on is true if the track is with a distance // PRECISION of the surface. This value is nonzero to allow // for roundoff errors. If the track is not on, then it is either // inside or outside--the surface defines the meaning of those. // Exactly one of these states can be true. // // The state bounds_checked is true and the states in_bounds and // out_of_bounds are defined only if the track is at the surface // and the surface is bounded. By definition, a bounded surface // assigns each point in track parameter space as either in bounds // or out of bounds. The state in_bounds (out_of_bounds) is true // if any in bounds (out of bounds) points are within distance // PRECISION of the track volume. The track volume is defined by // expanding the error ellipsoid by NSIGMA. Note that it is // possible for both states to be true. // // Here are the allowed pure states and their names: // // at on in out // 0 1 0 0 ON // 0 0 1 0 INSIDE // 0 0 0 1 OUTSIDE // 1 1 0 0 AT // // Here are the allowed bound states (pure state must be AT): // // 0 0 UNDEFINED_BOUNDS // 1 0 IN_BOUNDS // 0 1 OUT_OF_BOUNDS // 1 1 BOTH_BOUNDS // // The crossing status is constructed from // 1. a pure state alone (leaving its bound state UNDEFINED_BOUNDS), // 2. a bound state alone (pure state is set to AT), or // 3. another crossing status (copy constructor). // // The state of the class is set by the constructor and cannot // be modified. // // The methods get_precision() and get_nsigma() return the values // to used for PRECISION and NSIGMA. Programmers can inherit from // this class to change these values. If the base class is used, // the values can also be obtained through the static methods // get_static_precision() and get_static_nsigma(). // #include namespace trf { class CrossStat { public: // states enum PureStat { AT, ON, INSIDE, OUTSIDE }; enum BoundedStat { UNDEFINED_BOUNDS, IN_BOUNDS, OUT_OF_BOUNDS, BOTH_BOUNDS }; private: // static attributes // precision static double _precision; // nsigma static double _nsigma; public: // static methods // return the precision static double get_static_precision() { return _precision; }; // return nsigma static double get_static_nsigma() { return _nsigma; }; private: // attributes // Pure state PureStat _pure; // Bound state BoundedStat _bound; public: // constructor from a pure state CrossStat(PureStat pure); // constructor from a bound state CrossStat(BoundedStat bound); // copy constructor CrossStat(const CrossStat& xstat); // assignment CrossStat& operator=(const CrossStat& xstat); // destructor virtual ~CrossStat(); // output stream void ostr(std::ostream& stream) const; // Is track at the surface? bool at() const { return _pure==AT; }; // Is the the track position on the the surface? bool on() const { return _pure==ON || _pure==AT; }; // Is the track off the surface on the inside? bool inside() const { return _pure==INSIDE; }; // Is the track off the surface on the outside? bool outside() const { return _pure==OUTSIDE; }; // Have the bounds been checked? bool bounds_checked() const { return _bound!=UNDEFINED_BOUNDS; }; // Is the track in bounds? bool in_bounds() const { return _bound==IN_BOUNDS || _bound==BOTH_BOUNDS; }; // Is the track out of bounds? bool out_of_bounds() const { return _bound==OUT_OF_BOUNDS || _bound==BOTH_BOUNDS; } // fetch the precision virtual double get_precision() const { return get_static_precision(); }; // fetch nsigma virtual double get_nsigma() const { return get_static_nsigma(); }; }; } // end namespace trf // Output stream. std::ostream& operator<<(std::ostream& stream, const trf::CrossStat& xstat); #endif