// PropCyl_t.cpp // Test PropCyl. #include "PropCyl.h" #include #include #include #include #include "objstream/StdObjStream.hpp" #include "trfutil/trfstream.h" #include "trfutil/TRFMath.h" #include "trfbase/PropStat.h" #include "trfbase/TrackVector.h" #include "trfbase/VTrack.h" #include "trfbase/ETrack.h" #include "SurfCylinder.h" #include "PropCylFieldConst.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 = "PropCyl (I): "; string error_prefix = "PropCyl test (E): "; cout << ok_prefix << "-------- Testing component PropCyl. --------" << 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 << "Test constructor." << endl; PropCyl prop(ObjDoublePtr(new ObjDouble(-2.0))); cout << prop << endl; //******************************************************************** // Here we propagate some tracks both forward and backward and then // each back to the original track. We check that the returned // track parameters match those of the original track. cout << ok_prefix << "Check reversibility." << endl; double r1[] = { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 }; double r2[] = { 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0 }; double phi1[] = { 0.0, 1.0, -1.0, 2.0, 2.0, -2.0, 3.0, 0.0 }; double alf1[] = { 0.0, .0001,-.0001, 0.9, -0.9, 0.9, 0.9, 3.0 }; double crv[] = { 0.0, 0.0, 0.0, 0.0, 0.0, -0.05, 0.01, 0.0 }; double z[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 15.0, 0.0 }; double tlm[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.35, 0.0 }; double fbdf[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double bfdf[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double maxdiff = 1.e-10; int ntrk = 8; int i; for ( i=0; iget_type() == PropCyl::get_static_type() ); assert( is_equal( pobj->get_bfield(), 24.6 ) ); assert( pobj->get_map() == 0 ); assert( pobj->get_direction() == Propagator::FORWARD ); } } //******************************************************************** cout << ok_prefix << "Read object data with map." << endl; { string istring = "[ bmap PropCylFieldConst bfield=36.9 ]\n"; istring += "[ obj3 PropCyl bfield_map=@bmap dir=\"forward\" ]"; istringstream isstrm(istring); { StdObjStream obstr(isstrm); const PropCylField* pmap; { string name = obstr.read_object(); assert( name == "bmap" ); ObjTable::get_object(name,pmap); } const PropCyl* pobj; { string name = obstr.read_object(); assert( name == "obj3" ); ObjTable::get_object(name,pobj); } assert( pobj != 0 ); assert( pobj->get_type() == PropCyl::get_static_type() ); assert( is_equal( pobj->get_bfield(), 0.0 ) ); assert( pobj->get_map() == pmap ); assert( pobj->get_direction() == Propagator::FORWARD ); } } //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }