// FilterContains_t.cpp #include "FilterContains.h" #include #include #include #include "objstream/StdObjStream.hpp" #include "trfutil/trfstream.h" #include "trfbase/SurfTest.h" #include "trfbase/ETrack.h" #include "trffit/MTrack.h" #include "trfbase/HitTest.h" #include "FilterPtr.h" using std::cout; using std::cerr; using std::endl; using std::string; using std::ostringstream; using std::istringstream; using namespace trf; //********************************************************************** int main( ) { string component = "FilterContains"; 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; ObjTable::register_type(); FilterContains filt; cout << filt << endl; //******************************************************************** cout << ok_prefix << "Generate some hits." << endl; SurfTest srf(1); ETrack tre( SurfacePtr(srf.new_pure_surface()) ); // 1st layer ClusterPtr pclu1 = new ClusterTest(srf,1); HitPtr phit1 = pclu1->predict(tre).front(); // 2nd layer ClusterPtr pclu2 = new ClusterTest(srf,2); HitPtr phit2 = pclu2->predict(tre).front(); // 3rd layer ClusterPtr pclu3 = new ClusterTest(srf,3); HitPtr phit3 = pclu3->predict(tre).front(); // 4th layer ClusterPtr pclu4 = new ClusterTest(srf,4); HitPtr phit4 = pclu4->predict(tre).front(); // 5th layer ClusterPtr pclu5 = new ClusterTest(srf,5); HitPtr phit5 = pclu5->predict(tre).front(); //******************************************************************** MTrack* ptrm; //******************************************************************** cout << ok_prefix << "Build track list." << endl; Filter::MTrackArray trms; int ntrm = 7; // track 0 - bad (killed by 3) ptrm = new MTrack(tre); ptrm->add_hit(phit1); ptrm->add_hit(phit2); ptrm->add_hit(phit3); trms.push_back(Filter::MTrackPtr(ptrm)); // track 1 - bad (killed by 3) ptrm = new MTrack(tre); ptrm->add_hit(phit2); ptrm->add_hit(phit3); ptrm->add_hit(phit4); trms.push_back(Filter::MTrackPtr(ptrm)); // track 2 - good (hits ordered differently) ptrm = new MTrack(tre); ptrm->add_hit(phit2); ptrm->add_hit(phit1); ptrm->add_hit(phit3); trms.push_back(Filter::MTrackPtr(ptrm)); // track 3 - good ptrm = new MTrack(tre); ptrm->add_hit(phit1); ptrm->add_hit(phit2); ptrm->add_hit(phit3); ptrm->add_hit(phit4); ptrm->add_hit(phit5); trms.push_back(Filter::MTrackPtr(ptrm)); // track 4 - bad (killed by 3) ptrm = new MTrack(tre); ptrm->add_hit(phit3); ptrm->add_hit(phit4); ptrm->add_hit(phit5); trms.push_back(Filter::MTrackPtr(ptrm)); // track 5 - bad (killed by 3) ptrm = new MTrack(tre); trms.push_back(Filter::MTrackPtr(ptrm)); // track 6 - bad (killed by 3) ptrm->add_hit(phit2); ptrm->add_hit(phit4); ptrm = new MTrack(tre); trms.push_back(Filter::MTrackPtr(ptrm)); assert( trms.size() == ntrm ); //******************************************************************** Filter::FlagArray flags; int iflag; //******************************************************************** cout << ok_prefix << "Process hits." << endl; flags = filt.process(trms); assert( flags.size() == ntrm ); for ( iflag=0; iflagget_type() == FilterContains::get_static_type() ); } } //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }