#include #include #include #include #include #include #include #include #include #include #include //#include #include "IGeomInfo.hxx" #include "tutTestGeom.hxx" // Namespace surrounding all tut testing code namespace tut { struct baseGeomInfo { baseGeomInfo() { // Run before each test. TestGeom::LoadGeometry("$OAGEOMINFOROOT/test/geometries/Phase_I_CyDet_Geom.mac"); } ~baseGeomInfo() { // Run after each test. TestGeom::ResetGeometry(); } }; // Declare the test typedef test_group::object testGeomInfo; test_group groupGeomInfo("GeomInfo"); // Test the default constructor and destructor. template<> template<> void testGeomInfo::test<1> () {COMET::IGeomInfo::Get();} // Check the node id and the node position match. // TODO get this working, breaks for tourus like objects like sense layers // since centre of frame of sense layer is not actually in the sense // layer, /* *template<> template<> *void testGeomInfo::test<2> () { * int geomIdCount = 0; * for (int i=0; i<100000; ++i) { * // Get two dummy nodes * COMET::IGeometryId n1, n2; * COMETLog("Index : " << i << " FOUND : " << geomIdCount); * // Get a random place within the beamline * TVector3 p0(gRandom->Uniform(-175,1065), * gRandom->Uniform(-230,200), * gRandom->Uniform(-185,985)); * // Get the geometry ID from this location * n1 = COMET::IGeomInfo::Get().GeomId(p0.X(), p0.Y(), p0.Z()); * // Skip if there is not one * if (n1 == COMET::IGeometryId()) continue; * COMETLog("Geom NAME : " << n1.GetName()); * // Incriment if there is * ++geomIdCount; * // Get the node position back * TVector3 p1 = COMET::IGeomInfo::Get().NodePosition(n1); * COMETLog("n1 pos : " << p1.X() << " " << p1.Y() << " " << p1.Z()); * // Get the node at this position * n2 = COMET::IGeomInfo::Get().GeomId(p1.X(), p1.Y(), p1.Z()); * // Check the same node is retrieved again * TVector3 p2 = COMET::IGeomInfo::Get().NodePosition(n2); * // If it not the same node, check if it is a daughter node? * if (n1 != n2) { * std::string name1 = COMET::IGeomInfo::Get().NodeName(n1); * std::string name2 = COMET::IGeomInfo::Get().NodeName(n2); * if (name1.find(name2) != std::string::npos) continue; * if (name2.find(name1) != std::string::npos) continue; * } * ensure_equals("Node position matches node number",n1,n2); * } * ensure_greaterthan("Geometry objects found", geomIdCount, 0); *} */ };