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