#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 baseTReconPID { baseTReconPID() { // Run before each test. } ~baseTReconPID() { // Run after each test. } }; // Declare the test typedef test_group::object testTReconPID; test_group groupTReconPID("IReconPID"); // Test the IReconPID constructor and destructor. template<> template<> void testTReconPID::test<1> () { COMET::IReconPID 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 IPIDState",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 testTReconPID::test<2> () { COMET::IReconPID recObj; COMET::IHandle recState = recObj.GetState(); ensure("The state is valid", recState); const int stateDim = recState->GetDimensions(); ensure_equals("PID state dimensions", stateDim, 9); } // Test nodes which are saved have the correct type of state and all have // an associated object. template<> template<> void testTReconPID::test<3> () { COMET::IReconPID recObj; COMET::IReconNodeContainer& recNodes = recObj.GetNodes(); COMET::IHandle recNode; COMET::IHandle recCluster(new COMET::IReconCluster); COMET::IHandle recState(new COMET::IPIDState); ensure_equals("Node container starts empty.",recNodes.size(), (unsigned) 0); #ifdef CHECK_MISSING_STATE 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 testTReconPID::test<4> () { COMET::IReconPID recObj; COMET::IHandle recState = recObj.GetState(); ensure("The state is valid", recState); const double momentum = 1.414; recState->SetMomentum(momentum); const TLorentzVector pos(1.1,1.2,1.3,1.4); recState->SetPosition(pos); ensure_distance("PID momentum saved", recObj.GetMomentum(), momentum, 0.00001); ensure_lessthan("PID position saved", (recObj.GetPosition()-pos).Mag(), 0.0001); } };