// Hit.h #ifndef Hit_H #define Hit_H // Abstract interface for clusters and hits. // // The abstract base class Cluster represents a detector observation // that is independent of other such observations. I.e., the track // crossing contributing to a particular cluster does not contribute // to any others. Due to finite detector resolution, more than one track // crossing may contribute to a single cluster. // // The abstract base class Hit represents a measurement derived from // a cluster which is assigned to a single track. If the hit only makes // use of a portion of the cluster, then it is assumed that the remainder // of the cluster is independent of the track crossing which produced the // portion of interest. // // The only requirement on a cluster is that it is able to generate a list // hits from a track. The track must first be propagated to the cluster // surface. The returned list contains reference-counting pointers so // that each hit is deleted when its list element // is deleted. // // A hit provides a measurement vector and error matrix, a predicted // vector and error matrix and the derivative of the prediction with // respect to the input track. If the hit is N-dimensional, then the // error matrix is NxN symmetric and the derivative is Nx5. // // The hit also maintains a reference-counting pointer to its parent hit. // This must be supplied when generating the list of predictions. // // The hit prediction has one non-const method update which takes a // track as input. This track is used to recalculate the data. The // data should remain the same if the track is the same as that used // to generate the hit prediction. If the track vector or its error // change, then any of the data may change. // #include #include #include #include "ptr/Ptr.h" #include "ptr/LocalSharedDeletePolicy.h" #include "trfobj/TrfObject.h" #include "HitVector.h" #include "ClusterPtr.h" namespace trf { class ETrack; class Surface; class Cluster; class Hit; //********************************************************************** // reference-counting pointer for Hit typedef Ptr HitPtr; typedef Ptr ConstHitPtr; // list of Hit pointers typedef std::vector HitList; //********************************************************************** // list of Cluster pointers //class ClusterPtr; typedef std::deque ClusterList; //********************************************************************** // List of McTrack identifiers. typedef int McId; typedef std::vector McIdList; //********************************************************************** // output stream std::ostream& operator<<(std::ostream& stream, const Cluster& clus); class Cluster : public TrfObject { public: // static methods // Return the type name. static TypeName get_type_name() { return "Cluster"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } private: // disallow assignment Cluster& operator=(const Cluster& clus); // output stream (called by operator<<) virtual void ostr(std::ostream& stream) const =0; // equality // Return true if and only if the two clusters are identical. virtual bool equal(const Cluster& clus) const =0; // Generate and return the predictions for a track. virtual HitList _predict(const ETrack& tre) const =0; public: // constructor Cluster(); // copy constructor Cluster(const Cluster& clus); // destructor virtual ~Cluster(); // Return the type. Type get_generic_type() const { return get_static_type(); } Type get_type() const { return get_static_type(); } // Return the cluster surface. virtual const Surface& get_surface() const =0; // Return the ID's of MC tracks contributing to this cluster. // The default implementation here returns an empty list. virtual const McIdList& get_mc_ids() const; // Generate and return the predictions for a track. // The specified parent pointer is assigned to each prediction. HitList predict(const ETrack& tre) const; // equality // false if the cluster predictions are of diffent type // otherwise compare with virtual function equal bool operator==( const Cluster& rhs ) const; // inequality bool operator!=( const Cluster& rhs ) const { return ! operator==(rhs); }; // output stream friend std::ostream& operator<<(std::ostream& stream, const Cluster& clus); }; //********************************************************************** // output stream std::ostream& operator<<(std::ostream& stream, const Hit& hp); class Hit : public TrfObject { public: // static methods // Return the type name. static TypeName get_type_name() { return "Hit"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } protected: // pointer to the parent cluster // this is a reference-counting pointer ClusterPtr _pclus; private: // output stream (called by operator<<) virtual void ostr(std::ostream& stream) const =0; // equality // Return true if and only if the two predictions would return the same // parameters for any input track. // The current track (and thus the current sets of parameters) do // not have to be the same. // It has already been verified that this and hp are of the same type // and have equal clusters. virtual bool equal(const Hit& hp) const =0; // hide assignment operator Hit& operator=(const Hit& hp); public: // constructor Hit(); // copy constructor Hit(const Hit& hp); // destructor virtual ~Hit(); // Return the type. Type get_generic_type() const { return get_static_type(); } Type get_type() const { return get_static_type(); } // Register the parent cluster. // This should only be called once. void set_parent_pointer(const ClusterPtr& pclus); // return the parent cluster const ClusterPtr& get_cluster() const {return _pclus; }; // Return the parent cluster surface. virtual const Surface& get_surface() const; // return the dimension of the hit vector virtual int size() const =0; // return the measured hit vector virtual HitVector measured_vector() const =0; // return the measured hit error virtual HitError measured_error() const =0; // return the predicted hit vector virtual HitVector predicted_vector() const =0; // return the predicted hit error virtual HitError predicted_error() const =0; // return the Nx5 derivative dhit_dtrack. virtual HitDerivative dhit_dtrack() const =0; // return the difference between the prediction and the measurement // this is not trivial because of circular variables (e.g. angles) virtual HitVector difference_vector() const =0; // Update the measurement and prediction using new track parameters. // If update is called with the same track, then the measurement, // prediction and derivative should not change. virtual void update(const ETrack& tre) =0; // Return the ID's of MC tracks contributing to the parent cluster. const McIdList& get_mc_ids() const { return _pclus->get_mc_ids(); } // equality // false if the hits are of different type // otherwise compare with virtual function equal bool operator==(const Hit& rhs) const; // inequality bool operator!=(const Hit& rhs) const { return ! operator==(rhs); }; // output stream friend std::ostream& operator<<(std::ostream& stream, const Hit& hp); }; //********************************************************************** } // end namespace trf #endif