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 // G4ParticleChangeForLoss << 27 // 26 // 28 // Class description: << 27 // $Id: G4ParticleChangeForLoss.hh,v 1.18 2006/06/29 21:14:23 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01 $ 29 // 29 // 30 // Concrete class for ParticleChange for Energ << 30 // 31 << 31 // ------------------------------------------------------------ 32 // Author: Hisaya Kurashige, 23 March 1998 << 32 // GEANT 4 class header file 33 // Revision: Vladimir Ivantchenko, 16 January << 33 // 34 // 24 August 2 << 34 // 35 // ------------------------------------------- << 35 // ------------------------------------------------------------ 36 #ifndef G4ParticleChangeForLoss_hh << 36 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige 37 #define G4ParticleChangeForLoss_hh 1 << 37 // >> 38 // Modified: >> 39 // 16.01.04 V.Ivanchenko update for model variant of energy loss >> 40 // 15.04.05 V.Ivanchenko inline update methods >> 41 // 30.01.06 V.Ivanchenko add ProposedMomentumDirection for AlongStep >> 42 // and ProposeWeight for PostStep >> 43 // 07.06.06 V.Ivanchenko RemoveProposedMomentumDirection from AlongStep >> 44 // >> 45 // ------------------------------------------------------------ >> 46 // >> 47 // Class Description >> 48 // This class is a concrete class for ParticleChange for EnergyLoss >> 49 // >> 50 #ifndef G4ParticleChangeForLoss_h >> 51 #define G4ParticleChangeForLoss_h 1 38 52 >> 53 #include "globals.hh" >> 54 #include "G4ios.hh" 39 #include "G4VParticleChange.hh" 55 #include "G4VParticleChange.hh" 40 #include "G4DynamicParticle.hh" << 41 56 42 class G4ParticleChangeForLoss final : public G << 57 class G4DynamicParticle; >> 58 >> 59 class G4ParticleChangeForLoss: public G4VParticleChange 43 { 60 { 44 public: 61 public: 45 << 62 // default constructor 46 G4ParticleChangeForLoss(); 63 G4ParticleChangeForLoss(); 47 64 48 ~G4ParticleChangeForLoss() override = defaul << 65 // destructor 49 << 66 virtual ~G4ParticleChangeForLoss(); 50 G4ParticleChangeForLoss(const G4ParticleChan << 51 G4ParticleChangeForLoss& operator=(const G4P << 52 67 >> 68 // with description >> 69 // ---------------------------------------------------- 53 // --- the following methods are for updatin 70 // --- the following methods are for updating G4Step ----- 54 71 55 G4Step* UpdateStepForAlongStep(G4Step* step) << 72 G4Step* UpdateStepForAlongStep(G4Step* Step); 56 G4Step* UpdateStepForPostStep(G4Step* step) << 73 G4Step* UpdateStepForPostStep(G4Step* Step); 57 << 74 // A physics process gives the final state of the particle 58 // Initialize all used properties << 75 // based on information of G4Track 59 inline void InitializeForAlongStep(const G4T << 76 60 inline void InitializeForPostStep(const G4Tr << 77 void InitializeForAlongStep(const G4Track&); 61 << 78 void InitializeForPostStep(const G4Track&); 62 // Get/Set dynamic charge << 79 //Initialize all propoerties by using G4Track information 63 inline G4double GetProposedCharge() const; << 80 64 inline void SetProposedCharge(G4double theCh << 81 void AddSecondary(G4DynamicParticle* aParticle); 65 << 82 // Add next secondary 66 // Get/Set the final kinetic energy of the c << 83 67 inline G4double GetProposedKineticEnergy() c << 84 G4double GetProposedCharge() const; 68 inline void SetProposedKineticEnergy(G4doubl << 85 void SetProposedCharge(G4double theCharge); 69 << 86 // Get/Set theCharge 70 // Get/Propose the MomentumDirection vector: << 87 71 // direction << 88 G4double GetCharge() const; 72 inline const G4ThreeVector& GetProposedMomen << 89 void ProposeCharge(G4double finalCharge); 73 inline void SetProposedMomentumDirection(con << 90 // Get/Propose the final dynamical Charge in G4DynamicParticle 74 inline void ProposeMomentumDirection(const G << 91 75 << 92 G4double GetProposedKineticEnergy() const; 76 inline const G4ThreeVector& GetProposedPolar << 93 void SetProposedKineticEnergy(G4double proposedKinEnergy); 77 inline void ProposePolarization(const G4Thre << 94 // Get/Set the final kinetic energy of the current particle. 78 inline void ProposePolarization(G4double Px, << 95 79 << 96 const G4ThreeVector& GetProposedMomentumDirection() const; 80 void DumpInfo() const final; << 97 void SetProposedMomentumDirection(const G4ThreeVector& dir); >> 98 const G4ThreeVector& GetMomentumDirection() const; >> 99 void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz); >> 100 void ProposeMomentumDirection(const G4ThreeVector& Pfinal); >> 101 // Get/Propose the MomentumDirection vector: it is the final momentum direction. >> 102 >> 103 virtual void DumpInfo() const; >> 104 >> 105 // for Debug >> 106 virtual G4bool CheckIt(const G4Track&); >> 107 >> 108 protected: >> 109 // hide copy constructor and assignment operaor as protected >> 110 G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right); >> 111 G4ParticleChangeForLoss & operator=(const G4ParticleChangeForLoss &right); 81 112 82 private: 113 private: 83 114 84 G4double proposedKinEnergy = 0.0; << 115 const G4Track* currentTrack; 85 // The final kinetic energy of the current p << 116 // The pointer to G4Track 86 117 87 G4double currentCharge = 0.0; << 118 G4double proposedKinEnergy; 88 // The final charge of the current parti << 119 // The final kinetic energy of the current particle. 89 120 90 G4ThreeVector proposedMomentumDirection; << 121 G4double currentCharge; 91 // The final momentum direction of the curre << 122 // The final charge of the current particle. 92 123 93 G4ThreeVector proposedPolarization; << 124 G4ThreeVector proposedMomentumDirection; 94 // The final polarization of the current par << 125 // The final momentum direction of the current particle. 95 }; 126 }; 96 127 97 // ---------------------- << 128 // ------------------------------------------------------------ 98 // Inline methods << 99 // ---------------------- << 100 129 101 inline << 130 inline G4double G4ParticleChangeForLoss::GetProposedKineticEnergy() const 102 G4double G4ParticleChangeForLoss::GetProposedK << 103 { 131 { 104 return proposedKinEnergy; 132 return proposedKinEnergy; 105 } 133 } 106 134 107 inline << 135 inline void G4ParticleChangeForLoss::SetProposedKineticEnergy(G4double energy) 108 void G4ParticleChangeForLoss::SetProposedKinet << 109 { 136 { 110 proposedKinEnergy = energy; 137 proposedKinEnergy = energy; 111 } 138 } 112 139 113 inline G4double G4ParticleChangeForLoss::GetPr 140 inline G4double G4ParticleChangeForLoss::GetProposedCharge() const 114 { 141 { 115 return currentCharge; 142 return currentCharge; 116 } 143 } 117 144 118 inline << 145 inline G4double G4ParticleChangeForLoss::GetCharge() const 119 void G4ParticleChangeForLoss::SetProposedCharg << 146 { >> 147 return currentCharge; >> 148 } >> 149 >> 150 inline void G4ParticleChangeForLoss::SetProposedCharge(G4double theCharge) >> 151 { >> 152 currentCharge = theCharge; >> 153 } >> 154 >> 155 inline void G4ParticleChangeForLoss::ProposeCharge(G4double theCharge) 120 { 156 { 121 currentCharge = theCharge; 157 currentCharge = theCharge; 122 } 158 } 123 159 124 inline 160 inline 125 const G4ThreeVector& << 161 const G4ThreeVector& G4ParticleChangeForLoss::GetProposedMomentumDirection() const 126 G4ParticleChangeForLoss::GetProposedMomentumDi << 127 { 162 { 128 return proposedMomentumDirection; 163 return proposedMomentumDirection; 129 } 164 } 130 165 131 inline 166 inline 132 void G4ParticleChangeForLoss::ProposeMomentumD << 167 const G4ThreeVector& G4ParticleChangeForLoss::GetMomentumDirection() const 133 { 168 { 134 proposedMomentumDirection = dir; << 169 return proposedMomentumDirection; 135 } 170 } 136 171 137 inline 172 inline 138 void << 173 void G4ParticleChangeForLoss::ProposeMomentumDirection(const G4ThreeVector& dir) 139 G4ParticleChangeForLoss::SetProposedMomentumDi << 140 { 174 { 141 proposedMomentumDirection = dir; 175 proposedMomentumDirection = dir; 142 } 176 } 143 177 144 inline 178 inline 145 const G4ThreeVector& G4ParticleChangeForLoss:: << 179 void G4ParticleChangeForLoss::SetProposedMomentumDirection(const G4ThreeVector& dir) 146 { 180 { 147 return proposedPolarization; << 181 proposedMomentumDirection = dir; 148 } 182 } 149 183 150 inline 184 inline 151 void G4ParticleChangeForLoss::ProposePolarizat << 185 void G4ParticleChangeForLoss::ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz) 152 { 186 { 153 proposedPolarization = dir; << 187 proposedMomentumDirection.setX(Px); >> 188 proposedMomentumDirection.setY(Py); >> 189 proposedMomentumDirection.setZ(Pz); 154 } 190 } 155 191 156 inline void G4ParticleChangeForLoss::ProposePo << 192 inline void G4ParticleChangeForLoss::InitializeForAlongStep(const G4Track& track) 157 << 158 << 159 { 193 { 160 proposedPolarization.set(Px, Py, Pz); << 194 theStatusChange = track.GetTrackStatus(); >> 195 theLocalEnergyDeposit = 0.0; >> 196 InitializeSecondaries(track); >> 197 theParentWeight = track.GetWeight(); >> 198 proposedKinEnergy = track.GetKineticEnergy(); >> 199 currentCharge = track.GetDynamicParticle()->GetCharge(); 161 } 200 } 162 201 163 inline << 202 inline void G4ParticleChangeForLoss::InitializeForPostStep(const G4Track& track) 164 void G4ParticleChangeForLoss::InitializeForAlo << 165 { 203 { 166 InitializeSecondaries(); << 204 theStatusChange = track.GetTrackStatus(); 167 InitializeLocalEnergyDeposit(); << 205 theLocalEnergyDeposit = 0.0; 168 InitializeParentWeight(track); << 206 InitializeSecondaries(track); 169 InitializeStatusChange(track); << 207 theParentWeight = track.GetWeight(); 170 proposedKinEnergy = track.GetKineticEnergy() 208 proposedKinEnergy = track.GetKineticEnergy(); 171 currentCharge = track.GetDynamicParticle()-> 209 currentCharge = track.GetDynamicParticle()->GetCharge(); >> 210 proposedMomentumDirection = track.GetMomentumDirection(); >> 211 currentTrack = &track; 172 } 212 } 173 213 174 inline << 214 //---------------------------------------------------------------- 175 void G4ParticleChangeForLoss::InitializeForPos << 215 // methods for updating G4Step >> 216 // >> 217 >> 218 inline G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep) 176 { 219 { 177 InitializeForAlongStep(track); << 220 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 178 proposedMomentumDirection = track.GetMomentu << 221 179 proposedPolarization = track.GetPolarization << 222 // accumulate change of the kinetic energy >> 223 G4double kinEnergy = pPostStepPoint->GetKineticEnergy() + >> 224 (proposedKinEnergy - pStep->GetPreStepPoint()->GetKineticEnergy()); >> 225 >> 226 // update kinetic energy and charge >> 227 if (kinEnergy < DBL_MIN) { >> 228 theLocalEnergyDeposit += kinEnergy; >> 229 kinEnergy = 0.0; >> 230 } else { >> 231 pPostStepPoint->SetCharge( currentCharge ); >> 232 } >> 233 pPostStepPoint->SetKineticEnergy( kinEnergy ); >> 234 >> 235 // update weight >> 236 // this feature is commented out, it should be overwritten in case >> 237 // if energy loss processes will use biasing >> 238 // G4double newWeight = theParentWeight/(pPreStepPoint->GetWeight())*(pPostStepPoint->GetWeight()); >> 239 // pPostStepPoint->SetWeight( newWeight ); >> 240 pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit ); >> 241 return pStep; >> 242 } >> 243 >> 244 inline G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep) >> 245 { >> 246 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); >> 247 pPostStepPoint->SetCharge( currentCharge ); >> 248 pPostStepPoint->SetMomentumDirection( proposedMomentumDirection ); >> 249 pPostStepPoint->SetKineticEnergy( proposedKinEnergy ); >> 250 // update weight >> 251 // this feature is commented out, it should be overwritten in case >> 252 // if energy loss processes will use biasing >> 253 pPostStepPoint->SetWeight( theParentWeight ); >> 254 pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit ); >> 255 return pStep; >> 256 } >> 257 >> 258 inline void G4ParticleChangeForLoss::AddSecondary(G4DynamicParticle* aParticle) >> 259 { >> 260 // create track >> 261 G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(), >> 262 currentTrack->GetPosition()); >> 263 >> 264 // Touchable handle is copied to keep the pointer >> 265 aTrack->SetTouchableHandle(currentTrack->GetTouchableHandle()); >> 266 >> 267 // add a secondary >> 268 G4VParticleChange::AddSecondary(aTrack); 180 } 269 } 181 270 182 #endif 271 #endif >> 272 183 273