// PropNull_t.cpp #include "PropNull.h" #include #include #include #include "objstream/StdObjStream.hpp" #include "trfutil/trfstream.h" #include "PropagatorPtr.h" #include "PropStat.h" #include "VTrack.h" #include "ETrack.h" #include "TrackVector.h" #include "SurfTest.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 ok_prefix = "PropNull test (I): "; string error_prefix = "PropNull test (E): "; cout << ok_prefix << "------- Testing component PropNull -----------" << 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; } //******************************************************************** ObjTable::register_type(); ObjTable::register_type(); cout << trf_format; cout << ok_prefix << "Construct propagator." << endl; PropNull prop; cout << prop << endl; //******************************************************************** cout << ok_prefix << "Construct surfaces and tracks." << endl; SurfacePtr psrf1( new SurfTest(1) ); SurfacePtr psrf2( new SurfTest(2) ); SurfacePtr pbsrf1( new BSurfTest(1,2) ); VTrack trv1(SurfacePtr( new SurfTest(1) )); VTrack trv2(psrf2); ETrack tre1(psrf1); ETrack tre2(psrf2); //******************************************************************** cout << ok_prefix << "Propagate to same surface." << endl; PropStat pstat; pstat = prop.vec_prop(trv1,*psrf1); cout << pstat << endl; assert( pstat.success() ); pstat = prop.vec_dir_prop(trv1,*psrf1,Propagator::FORWARD); cout << pstat << endl; assert( pstat.success() ); pstat = prop.err_prop(tre1,*psrf1); cout << pstat << endl; assert( pstat.success() ); pstat = prop.err_dir_prop(tre1,*psrf1,Propagator::FORWARD); cout << pstat << endl; assert( pstat.success() ); //******************************************************************** cout << ok_prefix << "Propagate to same bounded surface." << endl; pstat = prop.vec_prop(trv1,*pbsrf1); cout << pstat << endl; assert( pstat.success() ); pstat = prop.vec_dir_prop(trv1,*pbsrf1,Propagator::FORWARD); cout << pstat << endl; assert( pstat.success() ); pstat = prop.err_prop(tre1,*pbsrf1); cout << pstat << endl; assert( pstat.success() ); pstat = prop.err_dir_prop(tre1,*pbsrf1,Propagator::FORWARD); cout << pstat << endl; assert( pstat.success() ); //******************************************************************** cout << ok_prefix << "Propagate to different surface." << endl; pstat = prop.vec_prop(trv1,*psrf2); cout << pstat << endl; assert( ! pstat.success() ); pstat = prop.vec_dir_prop(trv1,*psrf2,Propagator::FORWARD); cout << pstat << endl; assert( ! pstat.success() ); pstat = prop.err_prop(tre1,*psrf2); cout << pstat << endl; assert( ! pstat.success() ); pstat = prop.err_dir_prop(tre1,*psrf2,Propagator::FORWARD); cout << pstat << endl; assert( ! pstat.success() ); //******************************************************************** cout << ok_prefix << "Write object data." << endl; { PropagatorPtr pprop(new PropNull); ostringstream osstrm; assert( ! ObjTable::has_object_name("prop1") ); { StdObjStream obstr(osstrm); obstr.write_object("prop1",pprop); cout << osstrm.str() << endl; } assert( ObjTable::has_object_name("prop1") ); } //******************************************************************** cout << ok_prefix << "Read object data." << endl; { string istring = "[ prop2 PropNull ]"; istringstream isstrm(istring); { StdObjStream obstr(isstrm); string name = obstr.read_object(); assert( name == "prop2" ); PropagatorPtr pprop; assert( pprop == 0 ); ObjTable::get_object("prop2",pprop); assert( pprop != 0 ); assert( pprop->get_type() == PropNull::get_static_type() ); } } //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }