File: ImportFromRootFileTest.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 (71 lines) | stat: -rw-r--r-- 2,280 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
/*
 * ImportGDMLTest.cpp
 *
 *  Created on: Jun 24, 2014
 *      Author: swenzel
 */

#include "VecGeom/management/GeoManager.h"

#include "VecGeomTest/RootGeoManager.h"

#include "VecGeom/management/CppExporter.h"
#ifdef VECGEOM_CUDA_INTERFACE
#include "VecGeom/management/CudaManager.h"
#endif
#include "TGeoManager.h"
#include <cstdio>
#include <iostream>

//______________________________________________________________________________
void LoadVecGeomGeometry(bool printcontent = false)
{
  if (vecgeom::GeoManager::Instance().GetWorld() == NULL) {
    vecgeom::RootGeoManager::Instance().set_verbose(3);
    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());
    printf("Have registered volumes (including virtual) %ld\n",
           vecgeom::GeoManager::Instance().GetRegisteredVolumesCount());
    std::vector<vecgeom::VPlacedVolume *> v2;
    vecgeom::GeoManager::Instance().getAllPlacedVolumes(v2);
    printf("Have placed volumes %ld\n", v2.size());
    if (printcontent) {
      vecgeom::RootGeoManager::Instance().world()->PrintContent();
    }
  } else {
    printf("GeoManager already initialized; cannot load from ROOT file\n");
  }
}

//______________________________________________________________________________
void LoadGeometry(const char *filename)
{
  TGeoManager *geom = (gGeoManager) ? gGeoManager : TGeoManager::Import(filename);
  if (geom) {
    LoadVecGeomGeometry();
  }
}

int main(int argc, char *argv[])
{
  if (argc > 1) LoadGeometry(argv[1]);

  vecgeom::GeomCppExporter::Instance().DumpGeometry(std::cout);

#ifdef VECGEOM_CUDA_INTERFACE
  if (vecgeom::GeoManager::Instance().GetWorld() != NULL) {
    printf("copying to GPU\n");
    vecgeom::CudaManager::Instance().set_verbose(3);
    vecgeom::CudaManager::Instance().LoadGeometry(vecgeom::GeoManager::Instance().GetWorld());
    vecgeom::CudaManager::Instance().Synchronize();
  }
  printf("CUDA manager successfully finished");
#endif

  return 0;
}