Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OctreeFinder.hh
Go to the documentation of this file.
1// ********************************************************************
2// * License and Disclaimer *
3// * *
4// * The Geant4 software is copyright of the Copyright Holders of *
5// * the Geant4 Collaboration. It is provided under the terms and *
6// * conditions of the Geant4 Software License, included in the file *
7// * LICENSE and available at http://cern.ch/geant4/license . These *
8// * include a list of copyright holders. *
9// * *
10// * Neither the authors of this software system, nor their employing *
11// * institutes,nor the agencies providing financial support for this *
12// * work make any representation or warranty, express or implied, *
13// * regarding this software system or assume any liability for its *
14// * use. Please see the license in the file LICENSE and URL above *
15// * for the full disclaimer and the limitation of liability. *
16// * *
17// * This code implementation is the result of the scientific and *
18// * technical work of the GEANT4 collaboration. *
19// * By using, copying, modifying or distributing the software (or *
20// * any work based on the software) you agree to acknowledge its *
21// * use in resulting scientific publications, and indicate your *
22// * acceptance of all terms of the Geant4 Software license. *
23// ********************************************************************
24//
25//
26//
27
28#ifndef G4OctreeFinder_hh
29#define G4OctreeFinder_hh 1
30#include "globals.hh"
31#include <map>
32#include "G4Octree.hh"
33#include "G4Track.hh"
34#include "G4ITType.hh"
35#include "G4memory.hh"
36#include "G4TrackList.hh"
37
38#undef DEBUG
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41{
42public:
43 G4VFinder() = default;
44 virtual ~G4VFinder() = default;
45 virtual void Clear() = 0;
46 virtual void SetVerboseLevel(G4int level) = 0;
47 virtual G4int GetVerboseLevel() = 0;
48 virtual G4ITType GetITType() = 0;
49};
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
52#ifndef _Extractor_
53#define _Extractor_
54template<typename CONTAINER>
56{
57public:
58 const G4ThreeVector operator () (typename CONTAINER::iterator it)
59 {
60 return (*it)->GetPosition();
61 }
62 std::function<G4bool(const std::pair<typename CONTAINER::iterator,G4double>,
63 const std::pair<typename CONTAINER::iterator,G4double>)>
64 compareInterval = [](const std::pair<typename CONTAINER::iterator,G4double>& iter1,
65 const std::pair<typename CONTAINER::iterator,G4double>& iter2)
66 -> G4bool
67 {
68 return (std::get<1>(iter1) < std::get<1>(iter2));
69 };
70
71};
72#endif
73template<class T,typename CONTAINER>
75{
76 using Octree = G4Octree<typename CONTAINER::iterator,
78 using OctreeHandle = G4shared_ptr<Octree>;
79 using TreeMap = std::map<int, OctreeHandle>;
80
81private:
82 static G4ThreadLocal G4OctreeFinder* fInstance;
84 int fVerbose;
85 G4bool fIsOctreeUsed;
86 G4bool fIsOctreeBuit;
87 Extractor<CONTAINER> fExtractor;
88 TreeMap fTreeMap;
89 OctreeHandle fTree;
90public:
92
95
98
99 ~G4OctreeFinder() override;
100 void Clear() override;
101
102 void SetVerboseLevel(G4int level) override
103 {
104 fVerbose = level;
105 }
106
108 {
109 return fVerbose;
110 }
111
113 {
114 return T::ITType();
115 }
116 void BuildTreeMap(const std::map<G4int,CONTAINER*>& listMap);
117 void FindNearestInRange(const G4Track& track,
118 const int& key,
119 G4double R,
120 std::vector<std::pair<typename
121 CONTAINER::iterator,G4double>>& result,
122 G4bool isSort = false) const;
123
124 void FindNearest(const G4Track& track,
125 const int& key,
126 G4double R,
127 std::vector<std::pair<typename
128 CONTAINER::iterator,G4double>>& result,
129 G4bool isSort = false) const;
130
132 const G4int& key,
133 G4double R,
134 std::vector<std::pair<typename
135 CONTAINER::iterator,G4double>>& result,
136 G4bool isSort = false) const;
137
138 void FindNearestInRange(const G4ThreeVector& /*from this point*/,
139 G4double R,
140 std::vector<std::pair<
141 typename CONTAINER::iterator,G4double> >&
142 result,
143 G4bool isSorted) const;
144};
145
146#include "G4OctreeFinder.icc"
147#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::function< G4bool(const std::pair< typename CONTAINER::iterator, G4double >, const std::pair< typename CONTAINER::iterator, G4double >)> compareInterval
const G4ThreeVector operator()(typename CONTAINER::iterator it)
void FindNearestInRange(const G4ThreeVector &position, const G4int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
void BuildTreeMap(const std::map< G4int, CONTAINER * > &listMap)
G4ITType GetITType() override
void SetOctreeUsed(G4bool used)
static G4OctreeFinder * Instance()
void FindNearestInRange(const G4Track &track, const int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
G4bool IsOctreeUsed() const
G4int GetVerboseLevel() override
void FindNearest(const G4Track &track, const int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
void SetVerboseLevel(G4int level) override
void FindNearestInRange(const G4ThreeVector &, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSorted) const
~G4OctreeFinder() override
void SetOctreeBuilt(G4bool used)
G4bool IsOctreeBuilt() const
void Clear() override
virtual G4ITType GetITType()=0
virtual ~G4VFinder()=default
virtual void SetVerboseLevel(G4int level)=0
virtual void Clear()=0
G4VFinder()=default
virtual G4int GetVerboseLevel()=0
#define G4ThreadLocal
Definition: tls.hh:77