// ClusterFilter_t.cpp #include "ClusterFilter.h" #include #include #include #include "trfbase/HitTest.h" #include "trffit/MTrack.h" #include "ClusterFilterTest.h" #include "trflayer/ClusterContainerStandard.h" using std::cout; using std::cerr; using std::endl; using std::string; using namespace trf; //********************************************************************** int main( ) { string component = "ClusterFilter"; string ok_prefix = component + " (I): "; string error_prefix = component + " test (E): "; cout << ok_prefix << "---------- Testing component " + component + ". ----------" << endl; // Make sure assert is enabled. bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //******************************************************************** cout << trf_format; cout << ok_prefix << "Create filter." << endl; ClusterFilterTest filt0; const ClusterFilter& filt = filt0; cout << filt << endl; //******************************************************************** cout << ok_prefix << "Create track and cluster list." << endl; ClusterList clus; SurfTest srf(1.234); clus.push_back(new ClusterTest(srf,1)); clus.push_back(new ClusterTest(srf,2)); clus.push_back(new ClusterTest(srf,3)); clus.push_back(new ClusterTest(srf,4)); SurfacePtr psrf(new SurfTest(srf)); TrackVector vec; TrackError err; ETrack tre(psrf,vec,err); MTrack trm(tre); //******************************************************************** cout << ok_prefix << "Apply filter." << endl; assert( clus.size() != 0 ); int count = clus.size(); ClusterContainerStandard box(clus); const ClusterContainer* pbox = &box; cout << "Size: " << pbox->get_clusters().size() << endl; while ( count > 1 ) { pbox = &filt.filter_container(tre,*pbox,0); cout << "Size: " << pbox->get_clusters().size() << endl; assert( pbox->get_clusters().size() == --count ); } assert( pbox->get_clusters().size() == 1 ); //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }