File: TestRegions.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 (68 lines) | stat: -rw-r--r-- 2,115 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
#include "VecGeom/volumes/LogicalVolume.h"

#include "VecGeomTest/RootGeoManager.h"

#include "VecGeom/management/GeoManager.h"
#include "TGeoManager.h"
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>

namespace vecgeom {
// for compatibility with CUDA
inline namespace VECGEOM_IMPL_NAMESPACE {
// this is our Region class
class Region {
};
}
}

using namespace vecgeom;

int main()
{
  // testing region concept on ExN03 example geometry
  TGeoManager::SetVerboseLevel(0);
  TGeoManager::Import("ExN03.root");
  RootGeoManager::Instance().LoadRootGeometry();

  GeoManager &geom = GeoManager::Instance();
  // hierarchy of ExN03 geometry is
  // World  - Calorimeter - Layer - [ Lead | liquidArgon ]
  auto leadvolume  = const_cast<LogicalVolume *>(geom.FindLogicalVolume("Lead"));
  auto worldvolume = const_cast<LogicalVolume *>(geom.FindLogicalVolume("World"));
  auto layervolume = const_cast<LogicalVolume *>(geom.FindLogicalVolume("Layer"));
  auto calovolume  = const_cast<LogicalVolume *>(geom.FindLogicalVolume("Calorimeter"));
  auto argonvolume = const_cast<LogicalVolume *>(geom.FindLogicalVolume("liquidArgon"));

  Region *region1 = new Region;
  Region *region2 = new Region;

  leadvolume->SetRegion(region1);
  assert(leadvolume->GetRegion() == region1);
  assert(worldvolume->GetRegion() == nullptr);
  assert(argonvolume->GetRegion() == nullptr);

  // now do something with a pushdown
  calovolume->SetRegion(region2);
  assert(worldvolume->GetRegion() == nullptr);
  assert(calovolume->GetRegion() == region2);
  assert(layervolume->GetRegion() == region2);
  assert(leadvolume->GetRegion() == region2);
  assert(argonvolume->GetRegion() == region2);

  // now do something without pushdown
  calovolume->SetRegion(region1, false);
  assert(worldvolume->GetRegion() == nullptr);
  assert(calovolume->GetRegion() == region1);
  assert(layervolume->GetRegion() == region2);
  assert(leadvolume->GetRegion() == region2);
  assert(argonvolume->GetRegion() == region2);

  Region const *reg = leadvolume->GetRegion();
  assert(reg == region2);

  std::cout << "test passed \n";
  return 0;
}