Commit 5d8a0c4e authored by Martin Kostelnik's avatar Martin Kostelnik Committed by Andrei Gheata
Browse files

Introduce standalone kFarAway in ShapeTester and further reduce errors

parent bdb7e876
......@@ -1216,9 +1216,9 @@ int ShapeTester<ImplT>::TestAccuracyDistanceToIn(Precision dist)
{
// Test accuracy of DistanceToIn method against required one
int errCode = 0;
Vec_t point, pointSurf, pointIn, v, direction, normal;
Vec_t point, pointSurf, pointIn, pointBB, v, direction, normal;
bool convex = false;
Precision distIn, distOut;
Precision distIn, distOut, distBB;
Precision maxDistIn = 0., diff = 0., difMax = 0.;
int nError = 0;
ClearErrors();
......@@ -1264,7 +1264,9 @@ int ShapeTester<ImplT>::TestAccuracyDistanceToIn(Precision dist)
for (int j = 0; j < 1000; j++) {
vec = GetRandomDirection();
distIn = fVolume->DistanceToIn(point, vec);
distBB = fVolume->GetUnplacedVolume()->ApproachSolid(point, 1 / vec);
pointBB = point + distBB * vec;
distIn = fVolume->DistanceToIn(pointBB, vec) + distBB;
distOut = CallDistanceToOut(fVolume, point, vec, normal, convex);
// Test for consistency for fPoints situated Inside
......@@ -1307,7 +1309,6 @@ int ShapeTester<ImplT>::TestAccuracyDistanceToIn(Precision dist)
distOut = CallDistanceToOut(fVolume, point, vec, normal, convex);
Inside_t surfaceP = fVolume->Inside(point + distOut * vec);
distIn = fVolume->DistanceToIn(point, vec);
// iWrongSideIn++;
if (distOut >= kInfLength) {
iInInf++;
......
......@@ -20,15 +20,15 @@ int main(int argc, char *argv[])
OPTION_BOOL(stat, false);
OPTION_INT(type, 3);
double rmin = 0.;
double rmax = 5.;
double dz = 10.;
double sphi = 0.;
double dphi = 2 * kPi;
double thb = 3 * kPi / 4;
double phib = kPi / 3;
double tht = kPi / 4;
double phit = 2 * kPi / 3;
Precision rmin = 0.;
Precision rmax = 5.;
Precision dz = 10.;
Precision sphi = 0.;
Precision dphi = 2. * kPi;
Precision thb = 3. * kPi / 4.;
Precision phib = kPi / 3.;
Precision tht = kPi / 4.;
Precision phit = 2. * kPi / 3.;
switch (type) {
case 0:
......@@ -37,18 +37,18 @@ int main(int argc, char *argv[])
rmin = 3.;
break;
case 2:
dphi = 2 * kPi / 3;
dphi = 2. * kPi / 3.;
break;
case 3:
rmin = 3.;
dphi = 2 * kPi / 3;
dphi = 2. * kPi / 3.;
break;
default:
printf("Unknown test\n");
return 1;
}
Vector3D<double> nbottom(std::sin(thb) * std::cos(phib), std::sin(thb) * std::sin(phib), std::cos(thb));
Vector3D<double> ntop(std::sin(tht) * std::cos(phit), std::sin(tht) * std::sin(phit), std::cos(tht));
Vector3D<Precision> nbottom(std::sin(thb) * std::cos(phib), std::sin(thb) * std::sin(phib), std::cos(thb));
Vector3D<Precision> ntop(std::sin(tht) * std::cos(phit), std::sin(tht) * std::sin(phit), std::cos(tht));
CutTube_t *cuttube = new CutTube_t("test_VecGeomCutTube", rmin, rmax, dz, sphi, dphi, nbottom, ntop);
cuttube->Print();
......@@ -58,6 +58,9 @@ int main(int argc, char *argv[])
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(true);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1e-4);
#endif
int errCode = tester.Run(cuttube);
std::cout << "Final Error count for Shape *** " << cuttube->GetName() << "*** = " << errCode << "\n";
......
......@@ -41,6 +41,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
......@@ -41,6 +41,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
......@@ -39,6 +39,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
......@@ -24,6 +24,9 @@ int main(int argc, char *argv[])
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(false);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errCode = tester.Run(placed);
std::cout << "Final Error count for Shape *** " << placed->GetName() << "*** = " << errCode << "\n";
......
......@@ -27,6 +27,8 @@ int main(int argc, char *argv[])
#ifndef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-7);
#else
tester.SetSolidTolerance(1.e-4);
#endif
tester.SetTestBoundaryErrors(false);
......
......@@ -18,6 +18,10 @@ int main(int argc, char *argv[])
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(true);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
tester.SetSolidFarAway(1.e4);
#endif
int errCode = tester.Run(hype);
std::cout << "Final Error count for Shape *** " << hype->GetName() << "*** = " << errCode << "\n";
......
......@@ -32,13 +32,13 @@ int main(int argc, char *argv[])
UnplacedMultiUnion &multiunion = (UnplacedMultiUnion &)(*solid->GetUnplacedVolume());
std::cout << "Testing multi-union of " << nsolids << " boxes\n";
constexpr double size = 10.;
constexpr Precision size = 10.;
double sized = size * std::pow(0.5 / nsolids, 1. / 3.);
Precision sized = size * std::pow(0.5 / nsolids, 1. / 3.);
for (int i = 0; i < nsolids; ++i) {
Vector3D<double> pos(RNG::Instance().uniform(-size, size), RNG::Instance().uniform(-size, size),
Vector3D<Precision> pos(RNG::Instance().uniform(-size, size), RNG::Instance().uniform(-size, size),
RNG::Instance().uniform(-size, size));
double sizernd = RNG::Instance().uniform(0.8 * sized, 1.2 * sized);
Precision sizernd = RNG::Instance().uniform(0.8 * sized, 1.2 * sized);
Transformation3D trans(pos.x(), pos.y(), pos.z(), RNG::Instance().uniform(-180, 180),
RNG::Instance().uniform(-180, 180), RNG::Instance().uniform(-180, 180));
trans.SetProperties();
......
......@@ -39,6 +39,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(true);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errCode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errCode << "\n";
......
......@@ -28,8 +28,8 @@ int main(int argc, char *argv[])
Para_t *solid = 0;
Precision dx = 10.;
Precision dy = 7;
Precision dz = 15;
Precision dy = 7.;
Precision dz = 15.;
Precision alpha = 30.;
Precision theta = 30.;
Precision phi = 45.;
......@@ -54,6 +54,9 @@ int main(int argc, char *argv[])
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(true);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-4);
#endif
int errCode = tester.Run(solid);
std::cout << "Final Error count for Shape *** " << solid->GetName() << "*** = " << errCode << "\n";
......
......@@ -14,36 +14,36 @@ int main(int argc, char *argv[])
using namespace vecgeom;
Precision Z_ValP[15];
Z_ValP[0] = -1520;
Z_ValP[1] = -804;
Z_ValP[2] = -804;
Z_ValP[0] = -1520.;
Z_ValP[1] = -804.;
Z_ValP[2] = -804.;
Z_ValP[3] = -515.345;
Z_ValP[4] = -515.345;
Z_ValP[5] = -177;
Z_ValP[6] = -177;
Z_ValP[5] = -177.;
Z_ValP[6] = -177.;
Z_ValP[7] = 149.561;
Z_ValP[8] = 149.561;
Z_ValP[9] = 575;
Z_ValP[10] = 575;
Z_ValP[9] = 575.;
Z_ValP[10] = 575.;
Z_ValP[11] = 982.812;
Z_ValP[12] = 982.812;
Z_ValP[13] = 1166.7;
Z_ValP[14] = 1524;
Z_ValP[14] = 1524.;
Precision R_MinP[15];
R_MinP[0] = 1238;
R_MinP[1] = 1238;
R_MinP[2] = 1238;
R_MinP[3] = 1238;
R_MinP[4] = 1238;
R_MinP[5] = 1238;
R_MinP[6] = 1238;
R_MinP[7] = 1238;
R_MinP[8] = 1238;
R_MinP[9] = 1238;
R_MinP[10] = 1238;
R_MinP[11] = 1238;
R_MinP[12] = 1238;
R_MinP[13] = 1238;
R_MinP[0] = 1238.;
R_MinP[1] = 1238.;
R_MinP[2] = 1238.;
R_MinP[3] = 1238.;
R_MinP[4] = 1238.;
R_MinP[5] = 1238.;
R_MinP[6] = 1238.;
R_MinP[7] = 1238.;
R_MinP[8] = 1238.;
R_MinP[9] = 1238.;
R_MinP[10] = 1238.;
R_MinP[11] = 1238.;
R_MinP[12] = 1238.;
R_MinP[13] = 1238.;
R_MinP[14] = 1455.22;
Precision R_MaxP[15];
......
......@@ -34,6 +34,9 @@ int main(int argc, char *argv[])
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetTestBoundaryErrors(false);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1e-5);
#endif
int errCode = tester.Run(solid);
std::cout << "Final Error count for Shape *** " << solid->GetName() << "*** = " << errCode << "\n";
......
......@@ -88,6 +88,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
ShapeTester<ImplT> tester;
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
......@@ -70,6 +70,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
......@@ -33,6 +33,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
#ifdef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1e-4);
#endif
int errcode = tester.Run(shape);
std::cout << "Final Error count for Shape *** " << shape->GetName() << "*** = " << errcode << "\n";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment