// PTrack_t.cpp #include "PTrack.h" #include #include #include #include "trfutil/trfstream.h" #include "trfutil/Tuple.h" #include "trfutil/EventID.h" #include "trfutil/CpuTimerTuple.h" #include "trfbase/ETrack.h" #include "trfbase/PropDirectedTest.h" #include "trfbase/PropStat.h" #include "trfbase/SurfTest.h" #include "trfbase/MissTest.h" #include "trflayer/LayerTest.h" #include "trffit/AddFitter.h" #include "trffit/AddFitterTest.h" #include "Checker.h" #include "CheckerTest.h" #include "Path.h" #include "PathStop.h" using std::cout; using std::cerr; using std::endl; using std::string; using std::abs; using namespace trf; //********************************************************************** int main( ) { string component = "PTrack"; 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 << "Set event number." << endl; EventID evid(25); assert( EventID::get_global_event_number() == 25 ); //******************************************************************** cout << ok_prefix << "Create the kinematic track." << endl; ETrack tre( SurfacePtr( new SurfTest(0) ) ); //******************************************************************** cout << ok_prefix << "Create the paths." << endl; Path path0; LayerTest lay1(1.0,2); LayerTest lay2(2.0); LayerTest lay3(3.0,2); PropTest prop; AddFitterTest fit(2); Path& path1 = *path0.add_child(lay1,prop,fit,"one"); Path& path2 = *path0.add_child(lay2,prop,fit,"two*"); Path& path3 = *path0.add_child(lay2,prop,fit,"thr"); Path& path4 = *path0.add_child(lay3,prop,fit,"fou*"); // Add a child to each path except the last. path1.add_child(lay1,prop,fit); path2.add_child(lay1,prop,fit); path3.add_child(lay1,prop,fit); PathStopPtr pstop( new PathStop ); path2.set_stop(pstop); path4.set_stop(pstop); path3.set_end(); cout << path0 << endl; assert( path0.get_children().size() == 4 ); //******************************************************************** cout << ok_prefix << "Create PTrack from ETrack." << endl; PTrack::enable_tuple(); PTrack trp(path0,tre); int id = 0; assert( trp.get_id() == ++id ); cout << trp << endl; //******************************************************************** cout << ok_prefix << "Create PTrack from MTrack." << endl; { MTrack trm(tre); PTrack trp(path0,trm); assert( trp.get_id() == ++id ); cout << trm << endl; } //******************************************************************** cout << ok_prefix << "Propagate track." << endl; // There are four child paths and we expect to generate // a new track with one miss for each child. // Evaluate the expected likelihood for each new track. double likes[4] = { 0.5, 0.5, 0.5, 0.5 }; // Define the expected stop states. The 1st and 3rd paths don't // 0: 2 surfaces, no stop ==> not stopped // 1: 1 surface, has stop ==> stopped // 2: 1 surface, no stop ==> not stopped // 3: 2 surfaces, has stop ==> not stopped // have stops; the 4th layer has two surfaces. bool stops[4] = { false, true, false, false }; PTrack::PTrackList tracks = trp.propagate(); PTrack::PTrackIterator itrp = tracks.begin(); cout << ok_prefix << tracks.size() << " tracks generated." << endl; assert( tracks.size() == 4 ); for ( int i=0; i