File: root_geometry.cpp

package info (click to toggle)
vecgeom 1.2.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,016 kB
  • sloc: cpp: 88,803; ansic: 6,888; python: 1,035; sh: 582; sql: 538; makefile: 23
file content (54 lines) | stat: -rw-r--r-- 1,607 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

// force assert() to be used, even in Release mode
#undef NDEBUG

#include "VecGeom/management/GeoManager.h"

#include "VecGeomTest/RootGeoManager.h"

#include "VecGeom/navigation/NavigationState.h"
#include "VecGeom/navigation/GlobalLocator.h"
#include "VecGeom/volumes/PlacedVolume.h"

#include "TGeoBBox.h"
#include "TGeoManager.h"
#include "TGeoMatrix.h"
#include "TGeoTube.h"
#include "TGeoVolume.h"

using namespace VECGEOM_NAMESPACE;

int main()
{

  TGeoVolume *world_root = gGeoManager->MakeBox("world", NULL, 5., 5., 10.);
  TGeoVolume *tube_root  = gGeoManager->MakeTube("tube", NULL, 1., 5., 10.);

  world_root->AddNode(tube_root, 0, new TGeoTranslation(0, 0, 0));

  gGeoManager->SetTopVolume(world_root);
  gGeoManager->CloseGeometry();

  RootGeoManager::Instance().set_verbose(1);
  RootGeoManager::Instance().LoadRootGeometry();
  RootGeoManager::Instance().world()->PrintContent();

  VPlacedVolume const *const world = GeoManager::Instance().GetWorld();
  VPlacedVolume const *const tube  = *world->GetDaughters().begin();

  auto CheckPoint = [&](const Precision x, const Precision y, const Precision z, VPlacedVolume const *const volume) {
    Vector3D<Precision> const point = Vector3D<Precision>(x, y, z);
    NavigationState *path           = NavigationState::MakeInstance(2);
    assert(GlobalLocator::LocateGlobalPoint(world, point, *path, true) == volume);
  };

  CheckPoint(0, 0, 0, world);
  CheckPoint(4, 4, -9, world);
  CheckPoint(4, 0, 3, tube);
  CheckPoint(0, 3, -5, tube);
  CheckPoint(0, 3, -11, NULL);

  printf("\nAll tests successfully passed.\n");

  return 0;
}