#include #include #include "IReconBase.hxx" #include "IReconNode.hxx" #include "IReconState.hxx" #include "IReconCluster.hxx" #include "IReconShower.hxx" #include "IReconTrack.hxx" #include "IReconVertex.hxx" #include "IReconPID.hxx" namespace tut { struct baseTReconVertex { baseTReconVertex() { // Run before each test. } ~baseTReconVertex() { // Run after each test. } }; // Declare the test typedef test_group::object testTReconVertex; test_group groupTReconVertex("IReconVertex"); // Test the IReconVertex constructor and destructor. template<> template<> void testTReconVertex::test<1> () { COMET::IReconVertex recObj; ensure_distance("Default quality is zero", recObj.GetQuality(), 0.0, std::numeric_limits::epsilon()); ensure_equals("Default degrees of freedom", recObj.GetNDOF(), 0); ensure("Default state",recObj.GetState()); COMET::IHandle recState = recObj.GetState(); ensure("Default state is IVertexState",recState); COMET::IHandle clusterState = recObj.GetState(); ensure("Default state is not IClusterState",!clusterState); ensure_equals("Default TReconNodesContainer has size zero", recObj.GetNodes().size(), (unsigned) 0); ensure("Default has no hits",!recObj.GetHits()); } // Test the state definition. template<> template<> void testTReconVertex::test<2> () { COMET::IReconVertex recObj; COMET::IHandle recState = recObj.GetState(); ensure("The state is valid", recState); const int stateDim = recState->GetDimensions(); ensure_equals("Vertex state dimensions", stateDim, 4); } // Test nodes which are saved have the correct type of state and all have // an associated object. template<> template<> void testTReconVertex::test<3> () { COMET::IReconVertex recObj; COMET::IReconNodeContainer& recNodes = recObj.GetNodes(); COMET::IHandle recNode; COMET::IHandle recCluster(new COMET::IReconCluster); COMET::IHandle recState(new COMET::IVertexState); ensure_equals("Node container starts empty.",recNodes.size(), (unsigned)0); #ifdef MISSING_STATE_CHECK try { recNode = COMET::IHandle(new COMET::IReconNode); recNode->SetObject(recCluster); recNodes.push_back(recNode); fail("IReconNodeContainer node state is empty"); } catch (COMET::EWrongStateType& ex) { // OK! std::cout << std::endl << "Caught " << ex.what() << std::endl; } #endif try { recNode = COMET::IHandle(new COMET::IReconNode); recNode->SetState(recState); recNodes.push_back(recNode); recNode->ls(); fail("IReconNodeContainer object is empty"); } catch (COMET::EObjectEmpty& ex) { // OK! std::cout << std::endl << "Caught " << ex.what() << std::endl; } try { recNode = COMET::IHandle(new COMET::IReconNode); recNode->SetObject(recCluster); recNode->SetState(recState); recNodes.push_back(recNode); } catch (...) { fail("IReconNodeContainer failed with correct object and state"); } } // Test the getters and setters. template<> template<> void testTReconVertex::test<4> () { COMET::IReconVertex recObj; COMET::IHandle recState = recObj.GetState(); ensure("The state is valid", recState); const TLorentzVector pos(1.1,1.2,1.3,1.4); recState->SetPosition(pos); ensure_lessthan("Vertex position saved", (recObj.GetPosition()-pos).Mag(), 0.0001); } };