File: PolyconeBenchmark.cpp

package info (click to toggle)
vecgeom 1.2.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 24,016 kB
  • sloc: cpp: 88,803; ansic: 6,888; python: 1,035; sh: 582; sql: 538; makefile: 23
file content (73 lines) | stat: -rw-r--r-- 1,927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "VecGeom/volumes/LogicalVolume.h"
#include "VecGeom/volumes/UnplacedPolycone.h"
#include "VecGeom/volumes/Box.h"
#include "VecGeomTest/Benchmarker.h"
#include "VecGeom/management/GeoManager.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/base/Global.h"
#include "ArgParser.h"
#ifdef VECGEOM_ROOT
#include "VecGeomTest/Visualizer.h"
#endif

using namespace vecgeom;

// #define VISUALIZER

int main(int argc, char *argv[])
{
  OPTION_INT(npoints, 1024);
  OPTION_INT(nrep, 4);
  OPTION_DOUBLE(phistart, 0.);
  OPTION_DOUBLE(phidelta, kTwoPi);

  int Nz           = 4;
  Precision rmin[] = {0.1, 0., 0., 0.2};
  Precision rmax[] = {1., 2., 2., 1.5};
  Precision z[]    = {-1, -0.5, 0.5, 10};

  UnplacedBox worldUnplaced(5, 5, 15);
  auto pconUnplaced = GeoManager::MakeInstance<UnplacedPolycone>(phistart, phidelta, Nz, z, rmin, rmax);

  pconUnplaced->Print();

  LogicalVolume world("world", &worldUnplaced);
  LogicalVolume pcon("pcon", pconUnplaced);

  Transformation3D placement(0, 0, 0);
#if defined(VECGEOM_ROOT) and defined(VISUALIZER)
  VPlacedVolume const *vol =
#endif
      world.PlaceDaughter("pcon", &pcon, &placement);

  VPlacedVolume *worldPlaced = world.Place();

  GeoManager::Instance().SetWorldAndClose(worldPlaced);

  Benchmarker tester(GeoManager::Instance().GetWorld());
  tester.SetVerbosity(2);
  tester.SetTolerance(1E-7);
  tester.SetPoolMultiplier(1);
  tester.SetRepetitions(nrep);
  tester.SetPointCount(npoints);
  tester.SetInsideBias(0.5);

  auto errcode = tester.RunBenchmark();

#ifdef VISUALIZER
  Visualizer visualizer;
  visualizer.AddVolume(*vol);
  if (tester.GetProblematicContainPoints().size() > 0) {
    for (auto v : tester.GetProblematicContainPoints()) {
      visualizer.AddPoint(v);

      // for debugging purpose
      std::cerr << " " << vol->Contains(v) << "\n";
      std::cout << v << "\n";
    }
    visualizer.Show();
  }
#endif

  return errcode;
}