remage
Simulation framework for HPGe-based experiments
 
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
36namespace 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
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 };
132
134 // Cache for volume data, keyed by physical volume pointer
135 extern G4ThreadLocal std::unordered_map<const G4VPhysicalVolume*, VolumeCacheEntry> volume_cache;
137
144 std::unordered_map<const G4VPhysicalVolume*, VolumeCacheEntry>::iterator GetVolumeCacheEntry(
145 const G4VPhysicalVolume* pv
146 );
147
148} // namespace RMGNavigationTools
149
150#endif
151
152// vim: tabstop=2 shiftwidth=2 expandtab
Cache structure for volume geometry data.
Definition RMGNavigationTools.hh:125
Definition RMGNavigationTools.hh:98