// Path.h #ifndef Path_H #define Path_H // Paths provide the map for finding tracks. Each path contains // the following: // 1. The next candidate layer to search for hits. // 2. A list of checkers to apply to all tracks after adding hits. // 3. An optional refitter to be used after adding hits or misses. // 4. An optional list of checkers to apply after refitting. // 5. An optional path stop. // 6. A flag indicating that tracks may end. // 7. A pointer to the previous path (parent). // 8. A list of pointers to possible next paths (children). // // The stop indicates a point where track-finding should cease // until a list of filters is executed. // // The above imply the paths form a tree structure. There is a top // level element called the head path which contains none of the // above except for a list of descendants. It is constructed using // the default constructor and all other paths in the tree are // constructed by calling their parent's method add_child(). // // The path has exclusive management of its candidate layer. // The path has shared management of its child paths and its // checkers. // The path does not manage its parent or its stop. // // ObjStream examples: // // [ head Path checkers=@( ) stop=@0 end=false ] // // [ mypath Path parent=@head // layer=*mylyr propagator=*myprop fitter=*myfit // cfilters=@( cfilt1 cfilt2 ) // checkers=@( chk1 chk2 chk3 ) // stop=@mystop // end=false // name="lyr1" (optional) // refitter=*myfullfitter (optional) // post_checkers=@( chkp1 chkp2 ) (optional) // ] #include "ClusterFilterPtr.h" #include "CheckerPtr.h" #include #include #include #include "ptr/Ptr.h" #include "ptr/LocalSharedDeletePolicy.h" #include "trfobj/TrfReportingObject.h" #include "PathStopPtr.h" #include "CandidateLayer.h" namespace trf { class Path; class FullFitter; typedef Ptr PathPtr; typedef Ptr MutablePathPtr; typedef Ptr NullPathPtr; typedef Ptr MutableNullPathPtr; // Output stream. std::ostream& operator<<(std::ostream& stream, const Path& path); class Path : public TrfReportingObject { public: // typedefs // list of paths // This is a delete pointer so that all descendant paths are deleted // anytime a path is deleted. Users must be careful never to fill a // a list of this type with pointers they do not want to delete. typedef std::vector PathList; typedef std::vector MutablePathList; // list of cluster filters typedef std::vector ClusterFilterList; // list of checkers typedef std::vector CheckerList; private: // static attributes // Counter incremented each time a path is created. static int _count; public: // static methods // Return the type name. static TypeName get_type_name() { return "Path"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } // Return the current number of path creations. static int get_path_count() { return _count; }; private: // attributes // parent (0 for the head path) MutableNullPathPtr _pparent; // children // We store const pointers because this is the most common // request. We will cast if user needs mutable paths. PathList _children; // candidate layer CandidateLayer _cnl; // cluster filters ClusterFilterList _cfilters; // checkers CheckerList _checkers; // post checkers CheckerList _post_checkers; // Refitter. const FullFitter* _prefit; // stop PathStopPtr _pstop; // flag indicating that a track may end here even if there // are children bool _end; // Unique id number. int _id; // Name. std::string _name; private: // methods // constructor Path(MutableNullPathPtr pparent, const Layer& layer, const Propagator& prop, const AddFitter& fit, std::string name); // Hide copy constructor. Path(const Path& rhs); // Hide assignment. Path& operator=(const Path& rhs); // output stream void ostr(std::ostream& stream) const; public: // constructors and destructors // head constructor Path(std::string name=""); // destructor ~Path(); public: // const methods // Return the type. Type get_generic_type() const { return get_static_type(); } // Return the type. Type get_type() const { return get_static_type(); } // Write the object data. ObjData write_data() const; // Is this the head path? bool is_head() const { return ! _pparent; }; // Fetch the parent path. NullPathPtr get_parent() const { return _pparent; }; // Fetch the list of child paths. const PathList& get_children() const { return _children; }; // Get the candidate layer. const CandidateLayer& get_candidate_layer() const { return _cnl; }; // Fetch the list of cluster filters. const ClusterFilterList& get_cluster_filters() const { return _cfilters; }; // Fetch the list of checkers. const CheckerList& get_checkers() const { return _checkers; }; // Fetch the list of post checkers. const CheckerList& get_post_checkers() const { return _post_checkers; }; // Fetch the refitter. bool has_refitter() const { return _prefit != 0; } const FullFitter& get_refitter() const { return *_prefit; } // Get stop. const PathStopPtr get_stop() const { return _pstop; }; // Get the end flag. bool get_end() const { return _end; }; // Return the path id. int get_id() const { return _id; }; // Return the name. std::string get_name() const { return _name; }; public: // non-const methods // Add a child to this path. MutablePathPtr add_child(const Layer& layer, const Propagator& prop, const AddFitter& fit, std::string name=""); // Add a cluster filter. void add_cluster_filter(const ClusterFilterPtr& pfil); // Add a checker. void add_checker(const CheckerPtr& pchk); // Add a refitter. // This is called for all new tracks (including thise with added miss). void add_refitter(const FullFitter& fit); // Add a post checker. // These are applied to all new tracks after the refit. void add_post_checker(const CheckerPtr& pchk); // Set stop. void set_stop(const PathStopPtr& pstop); // Set end. void set_end(bool value =true) { _end = value; }; // Fetch the mutable parent path. MutableNullPathPtr get_mutable_parent() { return _pparent; }; // Fetch the list of mutable child paths. const MutablePathList get_mutable_children(); public: // friends // Output stream. friend std::ostream& operator<<(std::ostream& stream, const Path& path); }; } // end namespace trf #endif