Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ITManager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: G4ITManager.hh 65022 2012-11-12 16:43:12Z gcosmo $
27//
28// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29//
30// WARNING : This class is released as a prototype.
31// It might strongly evolve or even disapear in the next releases.
32//
33// History:
34// -----------
35// 10 Oct 2011 M.Karamitros created
36//
37// -------------------------------------------------------------------
38
39#ifndef G4ITManager_hh
40#define G4ITManager_hh 1
41
42#include "globals.hh"
43#include <map>
44#include "G4AllITManager.hh"
45#include "G4ITBox.hh"
46#include "G4KDTree.hh"
47#include "G4Track.hh"
48
49/**
50 * G4VITManager is just a virtual interface for G4ITManager.
51 * For more details, please have a look at the description
52 * of ITManager.
53 */
54
56{
57protected :
60
61public :
63 virtual ~G4VITManager(){;}
64
66 {
67 fVerbose = level;
68 }
70 {
71 return fVerbose;
72 }
73
74 virtual void UpdatePositionMap() = 0;
75 virtual void CreateTree() {;}
76
77 virtual void Push(G4Track*) = 0 ;
79 {
80 return fType;
81 }
82
83 G4ITBox* GetBox(const G4Track* track)
84 {
85 return GetBox(GetIT(track));
86 }
87
88 virtual G4ITBox* GetBox(const G4IT*) = 0;
89
90 // Navigate between boxes
91 virtual G4ITBox* GetFirstBox() = 0;
92 virtual G4ITBox* GetNextBox(G4ITBox*) = 0;
93 virtual G4ITBox* GetLastBox() = 0;
94
95public :
96
98 {
99 public :
101 virtual ~iterator(){;}
102 virtual G4bool begin();
103 virtual G4bool end();
104 iterator& operator= (const iterator& i);
106 G4IT* operator*();
107 G4ITBox* GetBox();
108
109 protected :
110 //_____________________________________
111 // Print "G4IT* friendIT" status :
112 void PrintNext() const;
113 //_____________________________________
114 // Attributes
115 G4IT* fNextIT; // the one you are looking reactants for
117 };
118
120 {
121 public :
124 virtual ~allbox_iterator() {;}
127
128 protected :
130
131 };
132
134 {
135 public :
137 virtual ~const_iterator(){;}
138 const G4IT* operator*();
139 };
140};
141
142/**
143 * G4ITManager is able to save into different boxes
144 * the ITs that will be used in the simulation.
145 * It is a stack-like.
146 * Those boxes are used to fill a tree which helps
147 * finding the closest neighboor.
148 */
149
150template<typename T>
152{
153 static G4ITManager<T> * fInstance;
155
156 typedef std::map<T,G4ITBox* > BoxMap;
157 BoxMap fBox;
158
159 typedef std::map<T, G4KDTree* > TreeMap;
160 TreeMap fTree;
161 TreeMap fPrevious_tree;
162
163public :
165 virtual ~G4ITManager();
166 virtual void Push(G4Track*);
167
168 //Make a method to extract number of IT from Box
170
171 void EraseABox(T*);
173
175 {
176 fVerbose = level;
177 }
179 {
180 return fVerbose;
181 }
182
183 virtual void UpdatePositionMap();
184 static void iUpdatePositionMap();
185
188 G4KDTreeResultHandle FindNearest(const T* it0, const T* it);
190
191 inline G4ITBox* GetBox(const T* IT)
192 {
193 typename BoxMap::const_iterator it = fBox.find(*IT);
194 if(it == fBox.end()) return 0;
195 return it->second;
196 }
197
198 inline virtual G4ITBox* GetBox(const G4IT* IT)
199 {
200 const T* myIT = dynamic_cast<const T*>(IT);
201
202 if(myIT == 0)
203 {
204 G4ExceptionDescription exceptionDescription ("You are requested a bad IT");
205 G4Exception("G4ITManager::GetBox","ITManager001",
206 FatalErrorInArgument,exceptionDescription);
207 return 0; // coverity
208 }
209
210 return GetBox(myIT);
211 }
212
214 {
215 typename BoxMap::iterator it = fBox.begin();
216 if(it != fBox.end())
217 {
218 return it->second;
219 }
220 return 0;
221 }
222
224 {
225 if(box)
226 {
227 return box->GetNextBox();
228 }
229 return 0;
230 }
231
233 {
234 typename BoxMap::reverse_iterator it = fBox.rbegin();
235 if(it != fBox.rend())
236 {
237 return it->second;
238 }
239 return 0;
240 }
241
242};
243
244#ifdef TEMPLATE
245#undef TEMPLATE
246#endif
247
248#define TEMPLATE template<typename T>
249#define G4ITMANAGER G4ITManager<T>
250
251#include "G4ITManager.icc"
252
253#undef TEMPLATE
254#undef G4ITMANAGER
255
256#endif
@ FatalErrorInArgument
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:48
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4ITBox * GetNextBox()
Definition: G4ITBox.hh:127
void SetVerboseLevel(G4int level)
Definition: G4ITManager.hh:174
virtual G4ITBox * GetNextBox(G4ITBox *box)
Definition: G4ITManager.hh:223
G4KDTreeResultHandle FindNearest(const G4ThreeVector &, const T *it)
void EraseABox(T *)
static void iUpdatePositionMap()
virtual void Push(G4Track *)
G4KDTreeResultHandle FindNearest(const T *it0, const T *it)
G4KDTreeResultHandle FindNearestInRange(const G4ThreeVector &, const T *, G4double)
virtual ~G4ITManager()
G4ITBox * GetBox(const T *IT)
Definition: G4ITManager.hh:191
virtual G4ITBox * GetBox(const G4IT *IT)
Definition: G4ITManager.hh:198
G4int NbElements(const G4IT *)
void EraseABox(G4ITBox *)
virtual G4ITBox * GetLastBox()
Definition: G4ITManager.hh:232
static G4ITManager< T > * Instance()
G4KDTreeResultHandle FindNearestInRange(const T *, const T *, G4double)
virtual void UpdatePositionMap()
G4int GetVerboseLevel()
Definition: G4ITManager.hh:178
virtual G4ITBox * GetFirstBox()
Definition: G4ITManager.hh:213
Definition: G4IT.hh:83
allbox_iterator & operator=(const allbox_iterator &i)
iterator & operator++(G4int)
iterator & operator=(const iterator &i)
G4ITType fType
Definition: G4ITManager.hh:58
virtual void CreateTree()
Definition: G4ITManager.hh:75
virtual G4ITBox * GetBox(const G4IT *)=0
G4int fVerbose
Definition: G4ITManager.hh:59
G4int GetVerboseLevel()
Definition: G4ITManager.hh:69
virtual G4ITBox * GetLastBox()=0
virtual ~G4VITManager()
Definition: G4ITManager.hh:63
virtual G4ITBox * GetFirstBox()=0
void SetVerboseLevel(G4int level)
Definition: G4ITManager.hh:65
G4ITBox * GetBox(const G4Track *track)
Definition: G4ITManager.hh:83
virtual void Push(G4Track *)=0
virtual G4ITBox * GetNextBox(G4ITBox *)=0
virtual void UpdatePositionMap()=0
G4ITType GetITType()
Definition: G4ITManager.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76