Geant4_10
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 71125 2013-06-11 15:39:09Z 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 
41 using namespace std;
42 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46 // Static functions
48 G4IT* GetIT(const G4Track* track)
49 {
50  return (dynamic_cast<G4IT*>(track->GetUserInformation()));
51 }
52 
53 G4IT* GetIT(const G4Track& track)
54 {
55  return (dynamic_cast<G4IT*>(track.GetUserInformation()));
56 }
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 // Constructors / Destructors
62  fpTrack (0),
63  fpPreviousIT(0), fpNextIT(0),
64  fTrackingInformation()
65 // fpTrackingInformation(new G4TrackingInformation())
66 {
68  fpITBox=0;
69  fpKDNode = 0 ;
70  fpTrackNode = 0;
71  fParentID_A = 0;
72  fParentID_B = 0;
73 }
74 
75 // Use only by inheriting classes
76 G4IT::G4IT(const G4IT& /*right*/) : G4VUserTrackInformation("G4IT"),
77  fpTrack (0),
78  fpPreviousIT(0), fpNextIT(0),
79  fTrackingInformation()
80 // fpTrackingInformation(new G4TrackingInformation())
81 {
82  fpITBox=0;
83  fpKDNode = 0 ;
84  fpTrackNode = 0;
85  fParentID_A = 0;
86  fParentID_B = 0;
87 }
88 
89 // Should not be used
91 {
92  G4ExceptionDescription exceptionDescription;
93  exceptionDescription << "The assignment operator of G4IT should not be used, this feature is not supported."
94  << "If really needed, please contact the developers.";
95  G4Exception("G4IT::operator=(const G4IT& right)","G4IT001",FatalException,exceptionDescription);
96 
97  if(this == &right) return *this;
98 
99  fpTrack = 0;
100  fpITBox = 0;
101  fpPreviousIT = 0;
102  fpNextIT = 0;
103  fpKDNode = 0 ;
104  fParentID_A = 0;
105  fParentID_B = 0;
106 // fpTrackingInformation = 0;
107  fpTrackNode = 0;
108 
109  return *this;
110 }
111 
113  fpPreviousIT(0), fpNextIT(0),
114  fTrackingInformation()
115 // fpTrackingInformation(new G4TrackingInformation())
116 {
118  fpITBox = 0;
119  fpTrack = aTrack;
120  fpKDNode = 0 ;
121  fpTrackNode = 0;
122  fParentID_A = 0;
123  fParentID_B = 0;
125 }
126 
128 {
129  if(fpITBox)
130  {
131  fpITBox->Extract(this);
132  }
133 
134  if(fpKDNode)
135  {
136  InactiveNode(fpKDNode);
137  fpKDNode = 0;
138  }
139 }
140 
142 {
143  TakeOutBox();
144 
145 // if(fpTrackingInformation)
146 // {
147 // delete fpTrackingInformation;
148 // fpTrackingInformation = 0;
149 // }
150 
151  // Note :
152  // G4ITTrackingManager will delete fTrackNode.
153  // fKDNode will be deleted when the KDTree is rebuilt
154 }
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
157 // Methods
160 {
161  if(fpTrack)
162  {
163  fTrackingInformation.RecordCurrentPositionNTime(fpTrack);
164  }
165 }
166 
168 {
169  if(GetITType() == right.GetITType() )
170  {
171  return (this->diff(right)) ;
172  }
173  else
174  {
175  return (GetITType() < right.GetITType());
176  }
177  return false;
178 }
179 
181 {
182  if(GetITType() == right.GetITType() )
183  {
184  return this->equal(right);
185  }
186  return false;
187 }
188 
190 {
191  return !(this->operator==(right));
192 }
Definition: G4IT.hh:82
virtual G4bool equal(const G4IT &right) const =0
void InactiveNode(G4KDNode *)
Definition: G4KDNode.cc:57
void TakeOutBox()
Definition: G4IT.cc:127
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4IT()
Definition: G4IT.cc:61
void RecordCurrentPositionNTime()
Definition: G4IT.cc:159
void RecordCurrentPositionNTime(G4Track *)
G4bool operator<(const G4IT &right) const
Definition: G4IT.cc:167
#define G4ThreadLocal
Definition: tls.hh:52
G4VUserTrackInformation * GetUserInformation() const
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:48
G4DLLIMPORT G4ThreadLocal G4Allocator< G4IT > * aITAllocator
Definition: G4IT.cc:43
bool G4bool
Definition: G4Types.hh:79
G4Track * fpTrack
Definition: G4IT.hh:144
G4bool operator==(const G4IT &right) const
Definition: G4IT.cc:180
G4IT & operator=(const G4IT &)
Definition: G4IT.cc:90
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
virtual const G4ITType GetITType() const =0
virtual ~G4IT()
Definition: G4IT.cc:141
G4bool operator!=(const G4IT &right) const
Definition: G4IT.cc:189
void Extract(G4IT *)
Definition: G4ITBox.cc:87