// HitTest.h #ifndef HitTest_H #define HitTest_H // Dummy concrete cluster and hit classes. // Theses are only used for testing. #include "Hit.h" #include "trfutil/trfstream.h" #include "SurfTest.h" #include "ETrack.h" #include "objstream/ObjData.hpp" using trf::HitVector; using trf::HitError; using trf::HitDerivative; using trf::Cluster; using trf::Hit; using trf::HitPtr; using trf::ConstHitPtr; using trf::HitList; using trf::ClusterPtr; using trf::McIdList; class ClusterTest; ObjPtr create_HitTest(const ObjData& data); ObjPtr create_ClusterTest(const ObjData& data); // Hit. class HitTest : public Hit { private: static double _pdata[]; enum {SIZE=2}; int _ival; void ostr(ostream& stream) const { stream << begin_object; stream << "Dummy hit prediction " << _ival << new_line; stream << "Cluster address: " << _pclus << new_line; stream << "Cluster: " << *_pclus; stream << end_object; }; bool equal(const Hit& hit) const { assert( hit.get_type() == get_type() ); return _ival == ((const HitTest&) hit)._ival; }; public: // static methods // Return the type name. static TypeName get_type_name() { return "HitTest"; } // Return the creator. static ObjCreator get_creator() { return create_HitTest; } // Return the type. static Type get_static_type() { return get_creator(); } public: HitTest(int ival) : _ival(ival) { }; HitTest(const HitTest& ht) : _ival(ht._ival) { }; ~HitTest() { }; Type get_type() const { return get_static_type(); } ObjData write_data() const { ObjData data("HitTest"); data.add_bare_pointer("cluster",get_cluster()); data.add_int("ival",_ival); return data; } int get_ival() const { return _ival; } int size() const { return SIZE; }; HitVector measured_vector() const { return HitVector(2,_pdata); }; HitError measured_error() const { return HitError(2,_pdata+1); }; HitVector predicted_vector() const { return HitVector(2,_pdata+2); }; HitError predicted_error() const { return HitError(2,_pdata+3); }; HitDerivative dhit_dtrack() const { return HitDerivative(2,_pdata+4); }; HitVector difference_vector() const { return predicted_vector() - measured_vector(); }; void update( const ETrack& tre ) { _ival = 0; }; }; // Cluster. class ClusterTest : public Cluster { private: // surface const SurfTest& _stst; // # predictions to generate int _npred; void ostr(ostream& stream) const { stream << begin_object; stream << "Dummy hit (" << _npred << " predictions)"; stream << end_object; } bool equal(const Cluster& clus) const { return _npred == ((ClusterTest&) clus)._npred; }; HitList _predict(const ETrack& tre) const { HitList hits; for ( int ipred=0; ipred<_npred; ++ipred ) hits.push_back( HitPtr(new HitTest(ipred)) ); return hits; }; public: // static methods // Return the type name. static TypeName get_type_name() { return "ClusterTest"; } // Return the creator. static ObjCreator get_creator() { return create_ClusterTest; } // Return the type. static Type get_static_type() { return get_creator(); } public: ClusterTest(const SurfTest& srf,int npred) : _stst(srf), _npred(npred) { }; ClusterTest(const ClusterTest& clus) : _stst(clus._stst), _npred(clus._npred) { }; ~ClusterTest( ) { }; Type get_type() const { return get_static_type(); } ObjData write_data() const { ObjData data("ClusterTest"); data.add_bare_pointer("surface",&_stst); data.add_int("npred",_npred); return data; } const SurfTest& get_surface() const { return _stst; }; }; double HitTest::_pdata[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 }; ObjPtr create_HitTest(const ObjData& data) { assert( data.get_object_type() == "HitTest" ); if ( data.get_object_type() != "HitTest" ) return ObjPtr(0); int ival = data.get_int("ival"); ClusterPtr pclu; data.get_bare_pointer("cluster",pclu); HitTest* phit = new HitTest(ival); phit->set_parent_pointer(pclu); return ObjPtr(phit); } ObjPtr create_ClusterTest(const ObjData& data) { assert( data.get_object_type() == "ClusterTest" ); if ( data.get_object_type() != "ClusterTest" ) return ObjPtr(0); int npred = data.get_int("npred"); const SurfTest* psrf; data.get_bare_pointer("surface",psrf); return ObjPtr( new ClusterTest(*psrf,npred) ); } #endif