Geant4 Cross Reference |
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 // G4ParticleChangeForTransport class implementation 27 // 28 // Author: Hisaya Kurashige, 10 May 1998 29 // -------------------------------------------------------------------- 30 31 #include "G4ParticleChangeForTransport.hh" 32 #include "G4TouchableHandle.hh" 33 #include "G4Track.hh" 34 #include "G4Step.hh" 35 #include "G4TrackFastVector.hh" 36 #include "G4DynamicParticle.hh" 37 38 // -------------------------------------------------------------------- 39 G4ParticleChangeForTransport::G4ParticleChangeForTransport() 40 { 41 // Disable flag that is enabled in G4VParticleChange if G4VERBOSE. 42 debugFlag = false; 43 } 44 45 // -------------------------------------------------------------------- 46 G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep) 47 { 48 // Update the G4Step specific attributes 49 return UpdateStepInfo(pStep); 50 } 51 52 // -------------------------------------------------------------------- 53 G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep) 54 { 55 // Smooth curved tajectory representation: let the Step know about 56 // the auxiliary trajectory points (jacek 30/10/2002) 57 pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer); 58 59 // Most of the code assumes that transportation is always the first process, 60 // so the pre- and post-step point are still equal. 61 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint(); 62 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 63 64 // update momentum direction and energy 65 if(isMomentumChanged) 66 { 67 pPostStepPoint->SetMomentumDirection(theMomentumDirectionChange); 68 pPostStepPoint->SetKineticEnergy(theEnergyChange); 69 } 70 if(isVelocityChanged) 71 pPostStepPoint->SetVelocity(theVelocityChange); 72 73 // update polarization 74 pPostStepPoint->SetPolarization(thePolarizationChange); 75 76 // update position and time 77 pPostStepPoint->SetPosition(thePositionChange); 78 pPostStepPoint->AddGlobalTime(theTimeChange - pPreStepPoint->GetLocalTime()); 79 pPostStepPoint->AddLocalTime(theTimeChange - pPreStepPoint->GetLocalTime()); 80 pPostStepPoint->SetProperTime(theProperTimeChange); 81 82 #ifdef G4VERBOSE 83 if(debugFlag) { CheckIt(*theCurrentTrack); } 84 #endif 85 86 // Update the G4Step specific attributes 87 pStep->SetStepLength( theTrueStepLength ); 88 pStep->SetControlFlag(theSteppingControlFlag); 89 90 return pStep; 91 } 92 93 // -------------------------------------------------------------------- 94 G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep) 95 { 96 // A physics process always calculates the final state of the particle 97 98 // Change volume only if some kinetic energy remains 99 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 100 if(pPostStepPoint->GetKineticEnergy() > 0.0) 101 { 102 // update next touchable 103 // (touchable can be changed only at PostStepDoIt) 104 pPostStepPoint->SetTouchableHandle(theTouchableHandle); 105 106 pPostStepPoint->SetMaterial(theMaterialChange); 107 pPostStepPoint->SetMaterialCutsCouple(theMaterialCutsCoupleChange); 108 pPostStepPoint->SetSensitiveDetector(theSensitiveDetectorChange); 109 } 110 if(this->GetFirstStepInVolume()) 111 { 112 pStep->SetFirstStepFlag(); 113 } 114 else 115 { 116 pStep->ClearFirstStepFlag(); 117 } 118 if(this->GetLastStepInVolume()) 119 { 120 pStep->SetLastStepFlag(); 121 } 122 else 123 { 124 pStep->ClearLastStepFlag(); 125 } 126 // It used to call base class's method 127 // - but this would copy uninitialised data members 128 // return G4ParticleChange::UpdateStepForPostStep(pStep); 129 130 // Copying what the base class does would instead 131 // - also not useful 132 // return G4VParticleChange::UpdateStepInfo(pStep); 133 134 return pStep; 135 } 136 137 // -------------------------------------------------------------------- 138 void G4ParticleChangeForTransport::DumpInfo() const 139 { 140 // use base-class DumpInfo 141 G4ParticleChange::DumpInfo(); 142 G4cout << " Touchable (pointer) : " << std::setw(20) 143 << theTouchableHandle() << G4endl; 144 } 145