Geant4  10.02.p02
G4IT.cc
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.cc 94218 2015-11-09 08:24:48Z gcosmo $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // History:
31 // -----------
32 // 10 Oct 2011 M.Karamitros created
33 //
34 // -------------------------------------------------------------------
35 
36 #include "G4IT.hh"
37 #include "G4KDTree.hh"
38 #include "G4ITBox.hh"
39 #include "G4Track.hh"
40 #include "G4TrackList.hh"
41 #include "G4TrackingInformation.hh"
42 
43 using namespace std;
44 
45 //------------------------------------------------------------------------------
46 //
47 // Static functions
48 //
49 G4IT* GetIT(const G4Track* track)
50 {
51  return (dynamic_cast<G4IT*>(track->GetUserInformation()));
52 }
53 
54 G4IT* GetIT(const G4Track& track)
55 {
56  return (dynamic_cast<G4IT*>(track.GetUserInformation()));
57 }
58 
59 //------------------------------------------------------------------------------
60 //
61 // Constructors / Destructors
62 //
65  fpTrack(0),
66  fpPreviousIT(0),
67  fpNextIT(0),
68  fpTrackingInformation(new G4TrackingInformation())
69 {
70  fpITBox = 0;
71  fpKDNode = 0;
72  fpTrackNode = 0;
73  fParentID_A = 0;
74  fParentID_B = 0;
75 }
76 
77 // Use only by inheriting classes
78 G4IT::G4IT(const G4IT& /*right*/) :
80  fpTrack(0),
81  fpPreviousIT(0),
82  fpNextIT(0),
83  fpTrackingInformation(new G4TrackingInformation())
84 {
85  fpITBox = 0;
86  fpKDNode = 0;
87  fpTrackNode = 0;
88  fParentID_A = 0;
89  fParentID_B = 0;
90 }
91 
92 // Should not be used
94 {
95  G4ExceptionDescription exceptionDescription;
96  exceptionDescription
97  << "The assignment operator of G4IT should not be used, "
98  "this feature is not supported."
99  << "If really needed, please contact the developers.";
100  G4Exception("G4IT::operator=(const G4IT& right)",
101  "G4IT001",
103  exceptionDescription);
104 
105  if (this == &right) return *this;
106 
107  fpTrack = 0;
108  fpITBox = 0;
109  fpPreviousIT = 0;
110  fpNextIT = 0;
111  fpKDNode = 0;
112  fParentID_A = 0;
113  fParentID_B = 0;
115  fpTrackNode = 0;
116 
117  return *this;
118 }
119 
120 G4IT::G4IT(G4Track * aTrack) :
121  G4VUserTrackInformation("G4IT"),
122  fpPreviousIT(0),
123  fpNextIT(0),
124  fpTrackingInformation(new G4TrackingInformation())
125 {
126  fpITBox = 0;
127  fpTrack = aTrack;
128  fpKDNode = 0;
129  fpTrackNode = 0;
130  fParentID_A = 0;
131  fParentID_B = 0;
133 }
134 
136 {
137  if(fpITBox)
138  {
139  fpITBox->Extract(this);
140  }
141 
142  if(fpTrackNode)
143  {
144  delete fpTrackNode;
145  fpTrackNode = 0;
146  }
147 
148  if(fpKDNode)
149  {
151  fpKDNode = 0;
152  }
153 }
154 
156 {
157  TakeOutBox();
158 
160  {
161  delete fpTrackingInformation;
163  }
164 
165 // Note :
166 // G4ITTrackingManager will delete fTrackNode.
167 // fKDNode will be deleted when the KDTree is rebuilt
168 }
169 
170 //------------------------------------------------------------------------------
172 // Methods
174 
176 {
177  if (GetITType() == right.GetITType())
178  {
179  return (this->diff(right));
180  }
181  else
182  {
183  return (GetITType() < right.GetITType());
184  }
185  return false;
186 }
187 
189 {
190  if (GetITType() == right.GetITType())
191  {
192  return this->equal(right);
193  }
194  return false;
195 }
196 
198 {
199  return !(this->operator==(right));
200 }
201 
202 
203 
204 double G4IT::operator[](int i) const
205 {
206  return fpTrack->GetPosition()[i];
207 }
208 
209 //------------------------------------------------------------------------------
210 
212 {
213  if (fpTrack) return GetTrack()->GetPosition();
214  return *(new G4ThreeVector());
215 }
216 
218 {
219  if (fpTrack)
220  {
222  }
223 }
224 
226 {
228 }
229 
231 {
233 }
234 
236 {
238 }
239 
virtual G4bool equal(const G4IT &right) const =0
void TakeOutBox()
Definition: G4IT.cc:135
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetPreStepGlobalTime() const
CLHEP::Hep3Vector G4ThreeVector
G4KDNode_Base * fpKDNode
Definition: G4IT.hh:170
G4IT()
Definition: G4IT.cc:63
G4TrackingInformation * fpTrackingInformation
Definition: G4IT.hh:175
const G4ThreeVector & GetPreStepPosition() const
Definition: G4IT.cc:235
const G4ThreeVector & GetPosition() const
void RecordCurrentPositionNTime()
Definition: G4IT.cc:217
void RecordCurrentPositionNTime(G4Track *)
G4bool operator<(const G4IT &right) const
Definition: G4IT.cc:175
The class G4TrackingInformation (hold by G4IT) emcompasses processes informations computed at the PS/...
G4ITBox * fpITBox
Definition: G4IT.hh:167
G4VUserTrackInformation * GetUserInformation() const
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:164
G4bool operator==(const G4IT &right) const
Definition: G4IT.cc:188
void InactiveNode(G4KDNode_Base *)
Definition: G4KDNode.cc:58
G4IT & operator=(const G4IT &)
Definition: G4IT.cc:93
G4double GetPreStepLocalTime() const
G4double GetPreStepLocalTime() const
Definition: G4IT.cc:230
const G4ThreeVector & GetPreStepPosition() const
virtual G4bool diff(const G4IT &right) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
int fParentID_A
Definition: G4IT.hh:172
double operator[](int i) const
Definition: G4IT.cc:204
int fParentID_B
Definition: G4IT.hh:173
virtual const G4ITType GetITType() const =0
G4Track * GetTrack()
Definition: G4IT.hh:215
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
double G4double
Definition: G4Types.hh:76
virtual ~G4IT()
Definition: G4IT.cc:155
G4double GetPreStepGlobalTime() const
Definition: G4IT.cc:225
const G4ThreeVector & GetPosition() const
Definition: G4IT.cc:211
{ Class description:
G4IT * fpNextIT
Definition: G4IT.hh:169
G4TrackListNode * fpTrackNode
Definition: G4IT.hh:176
G4IT * fpPreviousIT
Definition: G4IT.hh:168
G4bool operator!=(const G4IT &right) const
Definition: G4IT.cc:197
void Extract(G4IT *)
Definition: G4ITBox.cc:87