Geant4  10.01.p03
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 90900 2015-06-11 08:06:17Z 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 
42 using namespace std;
43 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
47 // Static functions
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 // Constructors / Destructors
64  fpTrack(0),
65  fpPreviousIT(0),
66  fpNextIT(0),
67  fTrackingInformation()
68 // fpTrackingInformation(new G4TrackingInformation())
69 {
71  fpITBox = 0;
72  fpKDNode = 0;
73  fpTrackNode = 0;
74  fParentID_A = 0;
75  fParentID_B = 0;
76 }
77 
78 // Use only by inheriting classes
79 G4IT::G4IT(const G4IT& /*right*/) :
81  fpTrack(0),
82  fpPreviousIT(0),
83  fpNextIT(0),
84  fTrackingInformation()
85 // fpTrackingInformation(new G4TrackingInformation())
86 {
87  fpITBox = 0;
88  fpKDNode = 0;
89  fpTrackNode = 0;
90  fParentID_A = 0;
91  fParentID_B = 0;
92 }
93 
94 // Should not be used
96 {
97  G4ExceptionDescription exceptionDescription;
98  exceptionDescription
99  << "The assignment operator of G4IT should not be used, this feature is not supported."
100  << "If really needed, please contact the developers.";
101  G4Exception("G4IT::operator=(const G4IT& right)", "G4IT001", FatalException,
102  exceptionDescription);
103 
104  if (this == &right) return *this;
105 
106  fpTrack = 0;
107  fpITBox = 0;
108  fpPreviousIT = 0;
109  fpNextIT = 0;
110  fpKDNode = 0;
111  fParentID_A = 0;
112  fParentID_B = 0;
113 // fpTrackingInformation = 0;
114  fpTrackNode = 0;
115 
116  return *this;
117 }
118 
119 G4IT::G4IT(G4Track * aTrack) :
120  G4VUserTrackInformation("G4IT"),
121  fpPreviousIT(0),
122  fpNextIT(0),
123  fTrackingInformation()
124 // fpTrackingInformation(new G4TrackingInformation())
125 {
127  fpITBox = 0;
128  fpTrack = aTrack;
129  fpKDNode = 0;
130  fpTrackNode = 0;
131  fParentID_A = 0;
132  fParentID_B = 0;
134 }
135 
137 {
138  if(fpITBox)
139  {
140  fpITBox->Extract(this);
141  }
142 
143  if(fpTrackNode)
144  {
145  delete fpTrackNode;
146  fpTrackNode = 0;
147  }
148 
149  if(fpKDNode)
150  {
152  fpKDNode = 0;
153  }
154 }
155 
157 {
158  TakeOutBox();
159 
160 // if(fpTrackingInformation)
161 // {
162 // delete fpTrackingInformation;
163 // fpTrackingInformation = 0;
164 // }
165 
166 // Note :
167 // G4ITTrackingManager will delete fTrackNode.
168 // fKDNode will be deleted when the KDTree is rebuilt
169 }
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172 // Methods
175 {
176  if (fpTrack)
177  {
179  }
180 }
181 
183 {
184  if (GetITType() == right.GetITType())
185  {
186  return (this->diff(right));
187  }
188  else
189  {
190  return (GetITType() < right.GetITType());
191  }
192  return false;
193 }
194 
196 {
197  if (GetITType() == right.GetITType())
198  {
199  return this->equal(right);
200  }
201  return false;
202 }
203 
205 {
206  return !(this->operator==(right));
207 }
208 
210 {
211  if (fpTrack) return GetTrack()->GetPosition();
212  return *(new G4ThreeVector());
213 }
214 
215 double G4IT::operator[](int i) const
216 {
217  return GetTrack()->GetPosition()[i];
218 }
G4ThreadLocal G4Allocator< G4IT > * aITAllocator
Definition: G4IT.cc:44
virtual G4bool equal(const G4IT &right) const =0
void TakeOutBox()
Definition: G4IT.cc:136
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
G4KDNode_Base * fpKDNode
Definition: G4IT.hh:182
G4IT()
Definition: G4IT.cc:62
const G4ThreeVector & GetPosition() const
void RecordCurrentPositionNTime()
Definition: G4IT.cc:174
void RecordCurrentPositionNTime(G4Track *)
G4bool operator<(const G4IT &right) const
Definition: G4IT.cc:182
#define G4ThreadLocal
Definition: tls.hh:89
G4ITBox * fpITBox
Definition: G4IT.hh:179
G4VUserTrackInformation * GetUserInformation() const
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:176
G4bool operator==(const G4IT &right) const
Definition: G4IT.cc:195
void InactiveNode(G4KDNode_Base *)
Definition: G4KDNode.cc:58
G4IT & operator=(const G4IT &)
Definition: G4IT.cc:95
G4TrackingInformation fTrackingInformation
Definition: G4IT.hh:187
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:184
double operator[](int i) const
Definition: G4IT.cc:215
int fParentID_B
Definition: G4IT.hh:185
virtual const G4ITType GetITType() const =0
G4Track * GetTrack()
Definition: G4IT.hh:240
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
virtual ~G4IT()
Definition: G4IT.cc:156
virtual const G4ThreeVector & GetPosition() const
Definition: G4IT.cc:209
{ Class description:
G4IT * fpNextIT
Definition: G4IT.hh:181
G4TrackListNode * fpTrackNode
Definition: G4IT.hh:188
G4IT * fpPreviousIT
Definition: G4IT.hh:180
G4bool operator!=(const G4IT &right) const
Definition: G4IT.cc:204
void Extract(G4IT *)
Definition: G4ITBox.cc:87