remage
Simulation framework for HPGe-based experiments
Toggle main menu visibility
Loading...
Searching...
No Matches
RMGNavigationTools.hh
1
// Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571>
2
//
3
// This program is free software: you can redistribute it and/or modify it under
4
// the terms of the GNU Lesser General Public License as published by the Free
5
// Software Foundation, either version 3 of the License, or (at your option) any
6
// later version.
7
//
8
// This program is distributed in the hope that it will be useful, but WITHOUT
9
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11
// details.
12
//
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16
#ifndef _RMG_NAVIGATION_TOOLS_HH_
17
#define _RMG_NAVIGATION_TOOLS_HH_
18
19
#include <regex>
20
#include <set>
21
#include <string>
22
#include <unordered_map>
23
#include <vector>
24
25
#include "G4AffineTransform.hh"
26
#include "G4LogicalVolume.hh"
27
#include "G4RotationMatrix.hh"
28
#include "G4ThreeVector.hh"
29
#include "G4VPhysicalVolume.hh"
30
#include "G4VSolid.hh"
31
32
// TODO: write function that locates points in global coordinates by using an
33
// auxiliary G4Navigator. The G4Navigator instance must be unique and its
34
// access thread-safe.
35
36
namespace
RMGNavigationTools {
37
47
G4LogicalVolume* FindLogicalVolume(std::string name);
59
60
std::set<G4VPhysicalVolume*> FindPhysicalVolume(std::string name, std::string copy_nr =
".*"
);
70
G4VPhysicalVolume* FindDirectMother(
const
G4VPhysicalVolume* volume);
81
std::set<G4VPhysicalVolume*> FindDirectMothers(
const
G4VPhysicalVolume* volume);
82
89
void
PrintListOfLogicalVolumes();
96
void
PrintListOfPhysicalVolumes();
97
98
struct
VolumeTreeEntry {
99
VolumeTreeEntry() =
delete
;
100
VolumeTreeEntry(
const
VolumeTreeEntry&) =
default
;
101
VolumeTreeEntry& operator=(
const
VolumeTreeEntry&) =
default
;
102
VolumeTreeEntry(
const
G4VPhysicalVolume
* pv) { physvol = pv; }
103
104
const
G4VPhysicalVolume
* physvol;
105
106
G4ThreeVector vol_global_translation;
// origin
107
G4RotationMatrix vol_global_rotation;
// identity
108
std::vector<G4RotationMatrix> partial_rotations;
109
std::vector<G4ThreeVector> partial_translations;
110
};
111
116
std::vector<VolumeTreeEntry> FindGlobalPositions(
const
G4VPhysicalVolume
* pv);
117
122
VolumeTreeEntry
FindGlobalPosition(
const
G4VPhysicalVolume
* pv);
123
125
struct
VolumeCacheEntry
{
126
G4AffineTransform
inverse_transform;
127
const
G4VSolid
* solid{};
128
size_t
num_daughters{};
129
std::vector<G4AffineTransform> daughter_transforms;
130
std::vector<const G4VSolid*> daughter_solids;
131
std::vector<bool> daughter_is_multiunion;
132
std::vector<G4ThreeVector> daughter_centers;
// bounding sphere centers in parent local coords
133
std::vector<double> daughter_radii;
// bounding sphere radii
134
std::vector<bool> daughter_is_germanium;
// whether daughter is registered as Germanium detector
135
};
136
138
// Cache for volume data, keyed by physical volume pointer
139
extern
G4ThreadLocal std::unordered_map<const G4VPhysicalVolume*, VolumeCacheEntry> volume_cache;
141
148
std::unordered_map<const G4VPhysicalVolume*, VolumeCacheEntry>::iterator GetVolumeCacheEntry(
149
const
G4VPhysicalVolume
* pv
150
);
151
152
}
// namespace RMGNavigationTools
153
154
#endif
155
156
// vim: tabstop=2 shiftwidth=2 expandtab
G4AffineTransform
G4VPhysicalVolume
G4VSolid
RMGNavigationTools::VolumeCacheEntry
Cache structure for volume geometry data.
Definition
RMGNavigationTools.hh:125
RMGNavigationTools::VolumeTreeEntry
Definition
RMGNavigationTools.hh:98
include
RMGNavigationTools.hh
Generated by
1.17.0