Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4IT.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: G4IT.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 G4IT_h
40 #define G4IT_h 1
41 
42 #include "globals.hh"
43 #include "G4ITType.hh"
44 #include "G4ThreeVector.hh"
46 #include "G4TrackingInformation.hh"
47 
49 // To implement your own IT class, you should use
50 // ITDef(MyClass) in the class define in your MyClass.hh
51 // and ITImp(MyClass) in your MyClass.cc
52 // For instance, see G4Molecule
54 
55 class G4IT;
56 class G4KDNode;
57 class G4ITBox;
58 class G4Track;
59 
60 G4IT* GetIT(const G4Track* track) ;
61 G4IT* GetIT(const G4Track& track) ;
62 
63 #if defined G4EM_ALLOC_EXPORT
65 #else
67 #endif
68 
69 class G4TrackListNode;
70 
82 class G4IT : public virtual G4VUserTrackInformation
83 {
84 public :
85  G4IT();
86  G4IT(G4Track*);
87  virtual ~G4IT();
88 
89  inline void *operator new(size_t);
90  inline void operator delete(void *aIT);
91 
92  virtual void Print() const {}
93  virtual const G4String& GetName() const = 0 ;
94 
96  // You should not worried of implementing diff, equal
97  // and GetType.
98  // When using ITDef(MyClass) this will be done.
99  // However, you need to implement in the concrete class
100  // even fake operators for < and ==
101  // They will be used by diff and equal.
103  virtual G4bool diff(const G4IT& right) const = 0 ;
104  virtual G4bool equal(const G4IT& right) const = 0 ;
105  G4bool operator<(const G4IT& right) const;
106  G4bool operator==(const G4IT& right) const;
107  G4bool operator!=(const G4IT& right) const;
108 
109  void SetTrack(G4Track*);
110  inline G4Track* GetTrack();
111  inline const G4Track* GetTrack() const;
112 
114 
115  inline void SetPrevious(G4IT*);
116  inline void SetNext(G4IT*);
117  inline G4IT* GetPrevious();
118  inline G4IT* GetNext();
119  inline const G4IT* GetPrevious() const;
120  inline const G4IT* GetNext() const;
121  inline void SetITBox(G4ITBox*);
122  inline const G4ITBox* GetITBox() const;
123  void TakeOutBox();
124  inline void SetNode(G4KDNode*);
125 
126  inline void SetParentID(int,int);
127  inline void GetParentID(int&,int&);
128 
129  inline const G4ThreeVector& GetPreStepPosition() const;
130  inline G4double GetPreStepLocalTime() const;
131  inline G4double GetPreStepGlobalTime() const;
132  inline G4KDNode* GetNode() const;
133 
134  inline G4TrackingInformation* GetTrackingInfo(){return &fTrackingInformation;}
135 
136  inline G4TrackListNode* GetTrackListNode(){return fpTrackNode;}
137  inline void SetTrackListNode(G4TrackListNode* node){ fpTrackNode = node;}
138 
139  virtual const G4ITType GetITType() const = 0 ;
140 
141 protected :
142  G4IT(const G4IT&);
143  G4IT& operator=(const G4IT&);
145 
146 private :
147  G4ITBox * fpITBox;
148  G4IT* fpPreviousIT;
149  G4IT* fpNextIT;
150  G4KDNode* fpKDNode ;
151 
152  int fParentID_A;
153  int fParentID_B;
154 
155  G4TrackingInformation fTrackingInformation ;
156  G4TrackListNode* fpTrackNode;
157 };
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
160 // Inline methods
162 inline void* G4IT::operator new(size_t)
163 {
164  void *aIT;
165  aIT = (void *) aITAllocator.MallocSingle();
166  return aIT;
167 }
168 
169 inline void G4IT::operator delete(void *aIT)
170 { aITAllocator.FreeSingle((G4IT *) aIT);}
171 
172 inline const G4ITBox* G4IT::GetITBox() const
173 {
174  return fpITBox ;
175 }
176 
177 inline void G4IT::SetITBox(G4ITBox * aITBox)
178 {
179  fpITBox = aITBox;
180 }
181 
182 inline void G4IT::SetPrevious(G4IT* aIT)
183 {
184  fpPreviousIT = aIT;
185 }
186 
187 inline void G4IT::SetNext(G4IT* aIT)
188 {
189  fpNextIT = aIT;
190 }
191 
193 {
194  return fpPreviousIT;
195 }
196 
198 {
199  return fpNextIT;
200 }
201 
202 inline void G4IT::SetTrack(G4Track* track)
203 {
204  fpTrack = track;
205 }
206 
208 {
209  return fpTrack;
210 }
211 
212 inline const G4Track* G4IT::GetTrack() const
213 {
214  return fpTrack;
215 }
216 
217 inline void G4IT::SetParentID(int p_a, int p_b)
218 {
219  fParentID_A = p_a;
220  fParentID_B = p_b;
221 }
222 
223 inline void G4IT::GetParentID(int& p_a,int&p_b)
224 {
225  p_a = fParentID_A;
226  p_b = fParentID_B ;
227 }
228 
230 {
231  return fTrackingInformation.GetPreStepGlobalTime();
232 }
233 
235 {
236  return fTrackingInformation.GetPreStepLocalTime();
237 }
238 
240 {
241  return fTrackingInformation.GetPreStepPosition();
242 }
243 
244 inline const G4IT* G4IT::GetPrevious() const
245 {
246  return fpPreviousIT ;
247 }
248 
249 inline const G4IT* G4IT::GetNext() const
250 {
251  return fpNextIT ;
252 }
253 
254 inline void G4IT::SetNode(G4KDNode* aNode)
255 {
256  fpKDNode = aNode ;
257 }
258 
259 inline G4KDNode* G4IT::GetNode() const
260 {
261  return fpKDNode ;
262 }
263 #endif
264 
265 
266