// GTrack_t.cpp // Test GTrack. #include "GTrackTest.hpp" using std::cout; using std::cerr; using std::endl; using std::vector; using std::string; #ifdef GTrack_holds_chunk_id using edm::ChunkID; using edm::LinkIndex; #endif using namespace trf; //********************************************************************** int main( ) { string component = "GTrack"; 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; } //******************************************************************** GTrackTest test(ok_prefix); int nclus = test.nclus; int nmiss = test.nmiss; int nstate = nclus + nmiss; const vector& clus_ss = test.ss; const vector& miss_ss = test.miss_ss; const vector& clus_surfs = test.surfs; const vector& miss_surfs = test.miss_surfs; const GTrack::StateList& states = test.stateset; const GTrack& gtr0 = test.gtr; #ifdef GTrack_holds_chunk_id GTrack& mgtr0 = const_cast(gtr0); ChunkID cid(4); unsigned int oid(123); ChunkID coid(cid.id(), oid); mgtr0.set_ids(cid,oid); { LinkIndex igtr = gtr0.index(); assert( igtr.getPointer() == >r0 ); cout << coid << endl; cout << igtr.id() << endl; assert( igtr.id() == coid ); } #else assert(false); #endif //******************************************************************** cout << ok_prefix << "Build empty track." << endl; GTrack gtr2; assert( ! gtr2.is_valid() ); assert( gtr0 != gtr2 ); assert( ! (gtr0 == gtr2) ); //******************************************************************** cout << ok_prefix << "Check copy." << endl; GTrack gtr1 = gtr0; GTrack gtr3 = gtr2; assert( gtr1.is_valid() ); assert( ! gtr3.is_valid() ); assert( gtr1 == gtr0 ); #ifdef GTrack_holds_chunk_id { LinkIndex igtr = gtr1.index(); assert( igtr.getPointer() == >r1 ); assert( igtr.id() == coid ); } #endif //******************************************************************** cout << ok_prefix << "Check assignment." << endl; gtr2 = gtr1; assert( gtr2.is_valid() ); assert( gtr2 == gtr1 ); gtr2 = gtr3; assert( ! gtr2.is_valid() ); //******************************************************************** cout << ok_prefix << "Fetch states by s." << endl; // Every other state is a miss. { GTrack::StateList::const_iterator ista = states.begin(); bool cluster = true; int iclus = 0; int imiss = 0; for ( int i=0; i 1 ); GTrack::StateList::const_iterator ista = gtr.get_states().begin(); ++ista; double s = ista->s(); cout << "s = " << s << endl; cout << gtr << endl; assert( gtr.get_state(s).has_valid_fit() ); gtr.drop_fit(s); cout << gtr << endl; assert( ! gtr.get_state(s).has_valid_fit() ); } //******************************************************************** cout << ok_prefix << "------------- All tests passed. -------------" << endl; return 0; //******************************************************************** }