File: E03Test.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 (93 lines) | stat: -rw-r--r-- 2,786 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * E03Test.cpp
 *
 *  Created on: Jan 7, 2015
 *      Author: swenzel
 */

// tests on a simple geometry from the Geant4 E03 example
// only makes sense with the proper geometry description (EN03.root)

#include "VecGeomTest/RootGeoManager.h"

#include "VecGeom/management/GeoManager.h"
#include "VecGeom/navigation/NavigationState.h"
#include "VecGeom/navigation/GlobalLocator.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/volumes/UnplacedBox.h"

#ifdef VECGEOM_ROOT
#include "TGeoManager.h"
#include "TGeoNode.h"
#include "TGeoVolume.h"
#endif

typedef vecgeom::NavigationState VolumePath_t;
using namespace vecgeom;

void locatetest()
{
  VolumePath_t *a;
  a = VolumePath_t::MakeInstance(3);

  vecgeom::UnplacedBox *const box =
      (vecgeom::UnplacedBox * const)GeoManager::Instance().GetWorld()->GetUnplacedVolume();
  std::cerr << "\n" << box << "\n";
  std::cerr << box->dimensions() << "\n";
  std::cerr << box->dimensions().x() << "\n";
  std::cerr << box->dimensions().y() << "\n";
  std::cerr << box->dimensions().z() << "\n";
  std::cerr << box->x() << "\n";
  std::cerr << box->y() << "\n";
  std::cerr << box->z() << "\n";
  std::cerr << box->Capacity() << "\n"; // not OK
  box->Print();                         // OK

  GlobalLocator::LocateGlobalPoint(GeoManager::Instance().GetWorld(), Vector3D<Precision>(-8, 0, 0), *a, true);
  a->Print();
  auto* node = RootGeoManager::Instance().tgeonode(a->Top());

  if (node != nullptr) {
    node->GetVolume()->Print();
  }
  NavigationState::ReleaseInstance(a);
}

void loadvecgeomgeometry()
{
  if (vecgeom::GeoManager::Instance().GetWorld() == NULL) {
    Printf("Now loading VecGeom geometry\n");
    vecgeom::RootGeoManager::Instance().LoadRootGeometry();
    Printf("Loading VecGeom geometry done\n");
    Printf("Have depth %d\n", vecgeom::GeoManager::Instance().getMaxDepth());
    std::vector<vecgeom::LogicalVolume *> v1;
    vecgeom::GeoManager::Instance().GetAllLogicalVolumes(v1);
    Printf("Have logical volumes %ld\n", v1.size());
    std::vector<vecgeom::VPlacedVolume *> v2;
    vecgeom::GeoManager::Instance().getAllPlacedVolumes(v2);
    Printf("Have placed volumes %ld\n", v2.size());
    vecgeom::RootGeoManager::Instance().world()->PrintContent();
  }
}

//______________________________________________________________________________
void loadgeometry(const char *filename)
{
  // Load the detector geometry from file, unless already loaded.
  TGeoManager *geom = (gGeoManager) ? gGeoManager : TGeoManager::Import(filename);
  if (geom) {
    loadvecgeomgeometry();
    // fMaxDepth = TGeoManager::GetMaxLevels();
  }
}

int main()
{
  // read in detector passed as argument
  // RootGeoManager::Instance().set_verbose(3);
  loadgeometry("ExN03.root");

  locatetest();

  return 0;
}