// MTrack.h #ifndef MTrack_H #define MTrack_H // This class describes a hit track with misses; i.e. it derives from // hit track and adds a list of misses. A miss is a layer surface from // from which no hits were taken. It provides a likelihood that the // specified track would not produce a cluster. #include "HTrack.h" #include "trfbase/MissPtr.h" // This is needed because files including this header may need to // instantiate a template calling the Miss destructor. #include "trfbase/Miss.h" namespace trf { class MTrack : public HTrack { public: // Miss typedefs // list of misses typedef std::vector MissList; public: // nested classes // Pointer to a either hit or a miss. class HitMissPtr { private: // attributes bool _is_hit; // flag indicating hit or miss union Ptr { const HitPtr* _pphit; const MissPtr* _ppmiss; Ptr() { _pphit = 0; }; Ptr(const HitPtr& phit) { _pphit = &phit; }; Ptr(const MissPtr& pmiss) { _ppmiss = &pmiss; }; } _ptr; // pointer public: // methods HitMissPtr(); // default constructor for STL #ifndef DEFECT_NO_EXPLICIT explicit #endif HitMissPtr(const HitPtr& phit); // construct from a hit pointer #ifndef DEFECT_NO_EXPLICIT explicit #endif HitMissPtr(const MissPtr& pmiss); // construct from a miss pointer bool is_hit() const // return true for hit pointer { return _is_hit; }; bool is_miss() const // return true for miss pointer { return ! _is_hit; }; const HitPtr& get_hit() const; // return hit pointer const MissPtr& get_miss() const; // return miss pointer bool operator==(const HitMissPtr& rhs) const; bool operator<(const HitMissPtr& rhs) const; }; public: // HitPtr typedefs // list of hit-misses typedef std::vector HitMissList; // miss iterator typedef HitMissList::iterator HitMissIterator; private: // count typedefs // list of counters typedef std::vector CountList; // Count iterator typedef CountList::iterator CountIterator; // Count iterator typedef CountList::const_iterator CountConstIterator; private: // attributes // list of misses MissList _misses; // number of hits preceeding each miss // (to keep relative ordering of hits and misses) // length of this should be one greater than the list of misses CountList _hit_counts; private: // methods // output stream virtual void ostr(std::ostream& stream) const; public: // methods // Default constructor (for STL) MTrack(); // Constructor specifying the starting track. MTrack(const ETrack& tre); // Constructor from the base class. MTrack(const HTrack& trh); // Copy constructor. MTrack(const MTrack& trm); // Destructor. ~MTrack(); // Add a hit to the back of the list. void add_hit(const HitPtr& phit); // Drop the last hit on the list. void drop_hit(); // Drop all hits (and misses). void drop_hits(); // Add a miss to the back of the list. // The misses (not their pointers) are copied into the list. void add_miss(const Miss& miss); // Drop the last miss on the list. void drop_miss(); // Fetch the list of misses. const MissList& get_misses() const { return _misses; }; // Fetch the combined list of hits and misses. const HitMissList get_hits_and_misses() const; // Fetch the total miss likelihood. double get_miss_likelihood() const; }; } // end namespace trf // Equality. // Same HTrack and same hits/misses list. bool operator==(const trf::MTrack& lhs, const trf::MTrack& rhs); // Inequality. // Opposite of above. bool operator!=(const trf::MTrack& lhs, const trf::MTrack& rhs); #endif