Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4IT.cc 94218 2015-11-09 08:24:48Z gcosmo $ 26 // 27 // 27 // Author: Mathieu Karamitros (kara (AT) cenbg 28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 28 // 29 // 29 // History: 30 // History: 30 // ----------- 31 // ----------- 31 // 10 Oct 2011 M.Karamitros created 32 // 10 Oct 2011 M.Karamitros created 32 // 33 // 33 // ------------------------------------------- 34 // ------------------------------------------------------------------- 34 35 35 #include "G4IT.hh" 36 #include "G4IT.hh" 36 #include "G4KDTree.hh" 37 #include "G4KDTree.hh" 37 #include "G4ITBox.hh" 38 #include "G4ITBox.hh" 38 #include "G4Track.hh" 39 #include "G4Track.hh" 39 #include "G4TrackList.hh" 40 #include "G4TrackList.hh" 40 #include "G4TrackingInformation.hh" 41 #include "G4TrackingInformation.hh" 41 42 42 using namespace std; 43 using namespace std; 43 44 44 //-------------------------------------------- 45 //------------------------------------------------------------------------------ 45 // 46 // 46 // Static functions 47 // Static functions 47 // 48 // 48 G4IT* GetIT(const G4Track* track) 49 G4IT* GetIT(const G4Track* track) 49 { 50 { 50 return (dynamic_cast<G4IT*>(track->GetUserIn 51 return (dynamic_cast<G4IT*>(track->GetUserInformation())); 51 } 52 } 52 53 53 G4IT* GetIT(const G4Track& track) 54 G4IT* GetIT(const G4Track& track) 54 { 55 { 55 return (dynamic_cast<G4IT*>(track.GetUserInf 56 return (dynamic_cast<G4IT*>(track.GetUserInformation())); 56 } 57 } 57 58 58 template<> << 59 G4KDNode<G4IT>::~G4KDNode(){ << 60 fPoint->SetNode(nullptr); << 61 } << 62 << 63 //-------------------------------------------- 59 //------------------------------------------------------------------------------ 64 // 60 // 65 // Constructors / Destructors 61 // Constructors / Destructors 66 // 62 // 67 G4IT::G4IT() : 63 G4IT::G4IT() : 68 G4VUserTrackInformation("G4IT"), 64 G4VUserTrackInformation("G4IT"), 69 fpTrack(nullptr), << 65 fpTrack(0), 70 fpPreviousIT(nullptr), << 66 fpPreviousIT(0), 71 fpNextIT(nullptr), << 67 fpNextIT(0), 72 fpTrackingInformation(new G4TrackingInform 68 fpTrackingInformation(new G4TrackingInformation()) 73 { 69 { 74 fpITBox = nullptr; << 70 fpITBox = 0; 75 fpKDNode = nullptr; << 71 fpKDNode = 0; 76 fpTrackNode = nullptr; << 72 fpTrackNode = 0; 77 fParentID_A = 0; 73 fParentID_A = 0; 78 fParentID_B = 0; 74 fParentID_B = 0; 79 } 75 } 80 76 81 // Use only by inheriting classes 77 // Use only by inheriting classes 82 G4IT::G4IT(const G4IT& /*right*/) : 78 G4IT::G4IT(const G4IT& /*right*/) : 83 G4VUserTrackInformation("G4IT"), 79 G4VUserTrackInformation("G4IT"), 84 fpTrack(nullptr), << 80 fpTrack(0), 85 fpPreviousIT(nullptr), << 81 fpPreviousIT(0), 86 fpNextIT(nullptr), << 82 fpNextIT(0), 87 fpTrackingInformation(new G4TrackingInform 83 fpTrackingInformation(new G4TrackingInformation()) 88 { 84 { 89 fpITBox = nullptr; << 85 fpITBox = 0; 90 fpKDNode = nullptr; << 86 fpKDNode = 0; 91 fpTrackNode = nullptr; << 87 fpTrackNode = 0; 92 fParentID_A = 0; 88 fParentID_A = 0; 93 fParentID_B = 0; 89 fParentID_B = 0; 94 } 90 } 95 91 96 // Should not be used 92 // Should not be used 97 G4IT& G4IT::operator=(const G4IT& right) 93 G4IT& G4IT::operator=(const G4IT& right) 98 { 94 { 99 G4ExceptionDescription exceptionDescription; 95 G4ExceptionDescription exceptionDescription; 100 exceptionDescription 96 exceptionDescription 101 << "The assignment operator of G4IT shou 97 << "The assignment operator of G4IT should not be used, " 102 "this feature is not supported." 98 "this feature is not supported." 103 << "If really needed, please contact the 99 << "If really needed, please contact the developers."; 104 G4Exception("G4IT::operator=(const G4IT& rig 100 G4Exception("G4IT::operator=(const G4IT& right)", 105 "G4IT001", 101 "G4IT001", 106 FatalException, 102 FatalException, 107 exceptionDescription); 103 exceptionDescription); 108 104 109 if (this == &right) return *this; 105 if (this == &right) return *this; 110 106 111 fpTrack = nullptr; << 107 fpTrack = 0; 112 fpITBox = nullptr; << 108 fpITBox = 0; 113 fpPreviousIT = nullptr; << 109 fpPreviousIT = 0; 114 fpNextIT = nullptr; << 110 fpNextIT = 0; 115 fpKDNode = nullptr; << 111 fpKDNode = 0; 116 fParentID_A = 0; 112 fParentID_A = 0; 117 fParentID_B = 0; 113 fParentID_B = 0; 118 fpTrackingInformation = nullptr; << 114 fpTrackingInformation = 0; 119 fpTrackNode = nullptr; << 115 fpTrackNode = 0; 120 116 121 return *this; 117 return *this; 122 } 118 } 123 119 124 G4IT::G4IT(G4Track * aTrack) : 120 G4IT::G4IT(G4Track * aTrack) : 125 G4VUserTrackInformation("G4IT"), 121 G4VUserTrackInformation("G4IT"), 126 fpPreviousIT(nullptr), << 122 fpPreviousIT(0), 127 fpNextIT(nullptr), << 123 fpNextIT(0), 128 fpTrackingInformation(new G4TrackingInform 124 fpTrackingInformation(new G4TrackingInformation()) 129 { 125 { 130 fpITBox = nullptr; << 126 fpITBox = 0; 131 fpTrack = aTrack; 127 fpTrack = aTrack; 132 fpKDNode = nullptr; << 128 fpKDNode = 0; 133 fpTrackNode = nullptr; << 129 fpTrackNode = 0; 134 fParentID_A = 0; 130 fParentID_A = 0; 135 fParentID_B = 0; 131 fParentID_B = 0; 136 RecordCurrentPositionNTime(); 132 RecordCurrentPositionNTime(); 137 } 133 } 138 134 139 void G4IT::TakeOutBox() 135 void G4IT::TakeOutBox() 140 { 136 { 141 if(fpITBox != nullptr) << 137 if(fpITBox) 142 { 138 { 143 fpITBox->Extract(this); 139 fpITBox->Extract(this); 144 fpITBox = nullptr; << 145 } 140 } 146 141 147 if(fpTrackNode != nullptr) << 142 if(fpTrackNode) 148 { 143 { 149 delete fpTrackNode; 144 delete fpTrackNode; 150 fpTrackNode = nullptr; << 145 fpTrackNode = 0; 151 } 146 } 152 147 153 if(fpKDNode != nullptr) << 148 if(fpKDNode) 154 { 149 { 155 InactiveNode(fpKDNode); 150 InactiveNode(fpKDNode); 156 fpKDNode = nullptr; << 151 fpKDNode = 0; 157 } 152 } 158 } 153 } 159 154 160 G4IT::~G4IT() 155 G4IT::~G4IT() 161 { 156 { 162 TakeOutBox(); 157 TakeOutBox(); 163 158 164 if(fpTrackingInformation != nullptr) << 159 if(fpTrackingInformation) 165 { 160 { 166 delete fpTrackingInformation; 161 delete fpTrackingInformation; 167 fpTrackingInformation = nullptr; << 162 fpTrackingInformation = 0; 168 } 163 } 169 164 170 // Note : 165 // Note : 171 // G4ITTrackingManager will delete fTrackNode. 166 // G4ITTrackingManager will delete fTrackNode. 172 // fKDNode will be deleted when the KDTree is 167 // fKDNode will be deleted when the KDTree is rebuilt 173 } 168 } 174 169 175 //-------------------------------------------- 170 //------------------------------------------------------------------------------ 176 /// 171 /// 177 // Methods 172 // Methods 178 /// 173 /// 179 174 180 G4bool G4IT::operator<(const G4IT& right) cons 175 G4bool G4IT::operator<(const G4IT& right) const 181 { 176 { 182 if (GetITType() == right.GetITType()) 177 if (GetITType() == right.GetITType()) 183 { 178 { 184 return (this->diff(right)); 179 return (this->diff(right)); 185 } 180 } 186 << 181 else 187 return (GetITType() < right.GetITType()); << 182 { 188 << 183 return (GetITType() < right.GetITType()); >> 184 } >> 185 return false; 189 } 186 } 190 187 191 G4bool G4IT::operator==(const G4IT& right) con 188 G4bool G4IT::operator==(const G4IT& right) const 192 { 189 { 193 if (GetITType() == right.GetITType()) 190 if (GetITType() == right.GetITType()) 194 { 191 { 195 return this->equal(right); 192 return this->equal(right); 196 } 193 } 197 return false; 194 return false; 198 } 195 } 199 196 200 G4bool G4IT::operator!=(const G4IT& right) con 197 G4bool G4IT::operator!=(const G4IT& right) const 201 { 198 { 202 return !(this->operator==(right)); 199 return !(this->operator==(right)); 203 } 200 } 204 201 >> 202 >> 203 205 double G4IT::operator[](int i) const 204 double G4IT::operator[](int i) const 206 { 205 { 207 return fpTrack->GetPosition()[i]; 206 return fpTrack->GetPosition()[i]; 208 } 207 } 209 208 210 //-------------------------------------------- 209 //------------------------------------------------------------------------------ 211 210 212 const G4ThreeVector& G4IT::GetPosition() const 211 const G4ThreeVector& G4IT::GetPosition() const 213 { 212 { 214 if (fpTrack != nullptr) return GetTrack()->G << 213 if (fpTrack) return GetTrack()->GetPosition(); 215 return *(new G4ThreeVector()); 214 return *(new G4ThreeVector()); 216 } 215 } 217 216 218 void G4IT::RecordCurrentPositionNTime() 217 void G4IT::RecordCurrentPositionNTime() 219 { 218 { 220 if (fpTrack != nullptr) << 219 if (fpTrack) 221 { 220 { 222 fpTrackingInformation->RecordCurrentPositi 221 fpTrackingInformation->RecordCurrentPositionNTime(fpTrack); 223 } 222 } 224 } 223 } 225 224 226 G4double G4IT::GetPreStepGlobalTime() const 225 G4double G4IT::GetPreStepGlobalTime() const 227 { 226 { 228 return fpTrackingInformation->GetPreStepGlob 227 return fpTrackingInformation->GetPreStepGlobalTime(); 229 } 228 } 230 229 231 G4double G4IT::GetPreStepLocalTime() const 230 G4double G4IT::GetPreStepLocalTime() const 232 { 231 { 233 return fpTrackingInformation->GetPreStepLoca 232 return fpTrackingInformation->GetPreStepLocalTime(); 234 } 233 } 235 234 236 const G4ThreeVector& G4IT::GetPreStepPosition( 235 const G4ThreeVector& G4IT::GetPreStepPosition() const 237 { 236 { 238 return fpTrackingInformation->GetPreStepPosi 237 return fpTrackingInformation->GetPreStepPosition(); 239 } 238 } 240 239 241 240