forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeantGeoUtils.hh
125 lines (103 loc) · 4.01 KB
/
GeantGeoUtils.hh
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//----------------------------------*-C++-*----------------------------------//
// Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/ext/GeantGeoUtils.hh
//---------------------------------------------------------------------------//
#pragma once
#include <iosfwd>
#include <string>
#include <unordered_set>
#include "celeritas_config.h"
#include "celeritas_sys_config.h"
#include "corecel/Assert.hh"
#include "corecel/cont/Span.hh"
//---------------------------------------------------------------------------//
// Forward declarations
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4Navigator;
#if CELERITAS_GEANT4_VERSION >= 0x0b0200
// Geant4 11.2 removed G4VTouchable
class G4TouchableHistory;
#else
class G4VTouchable;
#endif
namespace celeritas
{
//---------------------------------------------------------------------------//
#if CELERITAS_GEANT4_VERSION >= 0x0b0200
//! Version-independent typedef to Geant4 touchable history
using GeantTouchableBase = G4TouchableHistory;
#else
using GeantTouchableBase = G4VTouchable;
#endif
//---------------------------------------------------------------------------//
//! Wrap around a touchable to get a descriptive output.
struct PrintableNavHistory
{
GeantTouchableBase const* touch{nullptr};
};
//---------------------------------------------------------------------------//
//! Wrap around a G4LogicalVolume to get a descriptive output.
struct PrintableLV
{
G4LogicalVolume const* lv{nullptr};
};
// Print detailed information about the touchable history.
std::ostream& operator<<(std::ostream& os, PrintableNavHistory const& pnh);
// Print the logical volume name, ID, and address.
std::ostream& operator<<(std::ostream& os, PrintableLV const& pnh);
//---------------------------------------------------------------------------//
// FREE FUNCTIONS
//---------------------------------------------------------------------------//
// Load a GDML file and return the world volume (Geant4 owns!)
G4VPhysicalVolume* load_geant_geometry(std::string const& gdml_filename);
// Load a GDML file, stripping pointers
G4VPhysicalVolume* load_geant_geometry_native(std::string const& gdml_filename);
//---------------------------------------------------------------------------//
// Reset all Geant4 geometry stores if *not* using RunManager
void reset_geant_geometry();
//---------------------------------------------------------------------------//
// Get a view to the Geant4 LV store
Span<G4LogicalVolume*> geant_logical_volumes();
//---------------------------------------------------------------------------//
// Find Geant4 logical volumes corresponding to a list of names
std::unordered_set<G4LogicalVolume const*>
find_geant_volumes(std::unordered_set<std::string>);
//---------------------------------------------------------------------------//
// Generate the GDML name for a Geant4 logical volume
std::string make_gdml_name(G4LogicalVolume const&);
//---------------------------------------------------------------------------//
// INLINE DEFINITIONS
//---------------------------------------------------------------------------//
#if !CELERITAS_USE_GEANT4
inline G4VPhysicalVolume* load_geant_geometry(std::string const&)
{
CELER_NOT_CONFIGURED("Geant4");
}
inline G4VPhysicalVolume* load_geant_geometry_native(std::string const&)
{
CELER_NOT_CONFIGURED("Geant4");
}
inline void reset_geant_geometry()
{
CELER_NOT_CONFIGURED("Geant4");
}
inline Span<G4LogicalVolume*> geant_logical_volumes()
{
CELER_NOT_CONFIGURED("Geant4");
}
inline std::unordered_set<G4LogicalVolume const*>
find_geant_volumes(std::unordered_set<std::string>)
{
CELER_NOT_CONFIGURED("Geant4");
}
inline std::string make_gdml_name(G4LogicalVolume const&)
{
CELER_NOT_CONFIGURED("Geant4");
}
#endif
//---------------------------------------------------------------------------//
} // namespace celeritas