| 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 | //
|
|---|
| 27 | // $Id: G4ParticleChangeForTransport.cc,v 1.19 2006/11/03 17:45:04 japost Exp $
|
|---|
| 28 | // GEANT4 tag $Name: HEAD $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // --------------------------------------------------------------
|
|---|
| 32 | // GEANT 4 class implementation file
|
|---|
| 33 | //
|
|---|
| 34 | //
|
|---|
| 35 | //
|
|---|
| 36 | // ------------------------------------------------------------
|
|---|
| 37 | // Implemented for the new scheme 10 May. 1998 H.Kurahige
|
|---|
| 38 | // Correct tratment of fpNextTouchable 12 May. 1998 H.Kurashige
|
|---|
| 39 | // Change to the next volume only if energy>0 19 Jan. 2004 V.Ivanchenko
|
|---|
| 40 | // --------------------------------------------------------------
|
|---|
| 41 |
|
|---|
| 42 | #include "G4ParticleChangeForTransport.hh"
|
|---|
| 43 | #include "G4TouchableHandle.hh"
|
|---|
| 44 | #include "G4Track.hh"
|
|---|
| 45 | #include "G4Step.hh"
|
|---|
| 46 | #include "G4TrackFastVector.hh"
|
|---|
| 47 | #include "G4DynamicParticle.hh"
|
|---|
| 48 |
|
|---|
| 49 | G4ParticleChangeForTransport::G4ParticleChangeForTransport():G4ParticleChange()
|
|---|
| 50 | {
|
|---|
| 51 | if (verboseLevel>2) {
|
|---|
| 52 | G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() " << G4endl;
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | G4ParticleChangeForTransport::~G4ParticleChangeForTransport()
|
|---|
| 57 | {
|
|---|
| 58 | if (verboseLevel>2) {
|
|---|
| 59 | G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() " << G4endl;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | G4ParticleChangeForTransport::G4ParticleChangeForTransport(const G4ParticleChangeForTransport &right):G4ParticleChange(right)
|
|---|
| 65 | {
|
|---|
| 66 | if (verboseLevel>0) {
|
|---|
| 67 | G4cout << "G4ParticleChangeForTransport:: copy constructor is called " << G4endl;
|
|---|
| 68 | }
|
|---|
| 69 | theTouchableHandle = right.theTouchableHandle;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | // assignemnt operator
|
|---|
| 73 | G4ParticleChangeForTransport & G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport &right)
|
|---|
| 74 | {
|
|---|
| 75 | if (verboseLevel>1) {
|
|---|
| 76 | G4cout << "G4ParticleChangeForTransport:: assignment operator is called " << G4endl;
|
|---|
| 77 | }
|
|---|
| 78 | if (this != &right)
|
|---|
| 79 | {
|
|---|
| 80 | theListOfSecondaries = right.theListOfSecondaries;
|
|---|
| 81 | theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
|
|---|
| 82 | theNumberOfSecondaries = right.theNumberOfSecondaries;
|
|---|
| 83 | theStatusChange = right.theStatusChange;
|
|---|
| 84 | theTouchableHandle = right.theTouchableHandle;
|
|---|
| 85 | theMaterialChange = right.theMaterialChange;
|
|---|
| 86 | theMaterialCutsCoupleChange = right.theMaterialCutsCoupleChange;
|
|---|
| 87 | theSensitiveDetectorChange = right.theSensitiveDetectorChange;
|
|---|
| 88 | theMomentumDirectionChange = right.theMomentumDirectionChange;
|
|---|
| 89 | thePolarizationChange = right.thePolarizationChange;
|
|---|
| 90 | thePositionChange = right.thePositionChange;
|
|---|
| 91 | theTimeChange = right.theTimeChange;
|
|---|
| 92 | theEnergyChange = right.theEnergyChange;
|
|---|
| 93 | theTrueStepLength = right.theTrueStepLength;
|
|---|
| 94 | theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
|---|
| 95 | theSteppingControlFlag = right.theSteppingControlFlag;
|
|---|
| 96 | }
|
|---|
| 97 | return *this;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | //----------------------------------------------------------------
|
|---|
| 101 | // methods for updating G4Step
|
|---|
| 102 | //
|
|---|
| 103 |
|
|---|
| 104 | G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
|
|---|
| 105 | {
|
|---|
| 106 | // Nothing happens for AtRestDoIt
|
|---|
| 107 | if (verboseLevel>0) {
|
|---|
| 108 | G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called" << G4endl;
|
|---|
| 109 | G4cout << " Nothing happens for this method " << G4endl;
|
|---|
| 110 | }
|
|---|
| 111 | // Update the G4Step specific attributes
|
|---|
| 112 | return UpdateStepInfo(pStep);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
|
|---|
| 117 | {
|
|---|
| 118 | // Smooth curved tajectory representation: let the Step know about
|
|---|
| 119 | // the auxiliary trajectory points (jacek 30/10/2002)
|
|---|
| 120 | pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
|
|---|
| 121 |
|
|---|
| 122 | // copy of G4ParticleChange::UpdateStepForAlongStep
|
|---|
| 123 | // i.e. no effect for touchable
|
|---|
| 124 |
|
|---|
| 125 | // A physics process always calculates the final state of the
|
|---|
| 126 | // particle relative to the initial state at the beginning
|
|---|
| 127 | // of the Step, i.e., based on information of G4Track (or
|
|---|
| 128 | // equivalently the PreStepPoint).
|
|---|
| 129 | // So, the differences (delta) between these two states have to be
|
|---|
| 130 | // calculated and be accumulated in PostStepPoint.
|
|---|
| 131 |
|
|---|
| 132 | // Take note that the return type of GetMomentumChange is a
|
|---|
| 133 | // pointer to G4ThreeVector. Also it is a normalized
|
|---|
| 134 | // momentum vector.
|
|---|
| 135 |
|
|---|
| 136 | G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
|---|
| 137 | G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
|---|
| 138 | G4Track* aTrack = pStep->GetTrack();
|
|---|
| 139 | G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
|---|
| 140 |
|
|---|
| 141 | // uodate kinetic energy
|
|---|
| 142 | // now assume that no energy change in transportation
|
|---|
| 143 | // However it is not true in electric fields
|
|---|
| 144 | // Case for changing energy will be implemented in future
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 | // update momentum direction and energy
|
|---|
| 148 | if (isMomentumChanged) {
|
|---|
| 149 | G4double energy;
|
|---|
| 150 | energy= pPostStepPoint->GetKineticEnergy()
|
|---|
| 151 | + (theEnergyChange - pPreStepPoint->GetKineticEnergy());
|
|---|
| 152 |
|
|---|
| 153 | // calculate new momentum
|
|---|
| 154 | G4ThreeVector pMomentum = pPostStepPoint->GetMomentum()
|
|---|
| 155 | + ( CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass)
|
|---|
| 156 | - pPreStepPoint->GetMomentum());
|
|---|
| 157 | G4double tMomentum = pMomentum.mag();
|
|---|
| 158 | G4ThreeVector direction(1.0,0.0,0.0);
|
|---|
| 159 | if( tMomentum > 0. ){
|
|---|
| 160 | G4double inv_Momentum= 1.0 / tMomentum;
|
|---|
| 161 | direction= pMomentum * inv_Momentum;
|
|---|
| 162 | }
|
|---|
| 163 | pPostStepPoint->SetMomentumDirection(direction);
|
|---|
| 164 | pPostStepPoint->SetKineticEnergy( energy );
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | // stop case should not occur
|
|---|
| 168 | //pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 | // update polarization
|
|---|
| 172 | pPostStepPoint->AddPolarization( thePolarizationChange
|
|---|
| 173 | - pPreStepPoint->GetPolarization());
|
|---|
| 174 |
|
|---|
| 175 | // update position and time
|
|---|
| 176 | pPostStepPoint->AddPosition( thePositionChange
|
|---|
| 177 | - pPreStepPoint->GetPosition() );
|
|---|
| 178 | pPostStepPoint->AddGlobalTime( theTimeChange
|
|---|
| 179 | - pPreStepPoint->GetGlobalTime());
|
|---|
| 180 | pPostStepPoint->AddLocalTime( theTimeChange
|
|---|
| 181 | - pPreStepPoint->GetGlobalTime());
|
|---|
| 182 | pPostStepPoint->AddProperTime( theProperTimeChange
|
|---|
| 183 | - pPreStepPoint->GetProperTime());
|
|---|
| 184 |
|
|---|
| 185 | #ifdef G4VERBOSE
|
|---|
| 186 | if (debugFlag) CheckIt(*aTrack);
|
|---|
| 187 | #endif
|
|---|
| 188 |
|
|---|
| 189 | // Update the G4Step specific attributes
|
|---|
| 190 | //pStep->SetStepLength( theTrueStepLength );
|
|---|
| 191 | // pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
|
|---|
| 192 | pStep->SetControlFlag( theSteppingControlFlag );
|
|---|
| 193 | return pStep;
|
|---|
| 194 | // return UpdateStepInfo(pStep);
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
|
|---|
| 198 | {
|
|---|
| 199 | // A physics process always calculates the final state of the particle
|
|---|
| 200 |
|
|---|
| 201 | // Change volume only if some kinetic energy remains
|
|---|
| 202 | G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
|---|
| 203 | if(pPostStepPoint->GetKineticEnergy() > 0.0) {
|
|---|
| 204 |
|
|---|
| 205 | // update next touchable
|
|---|
| 206 | // (touchable can be changed only at PostStepDoIt)
|
|---|
| 207 | pPostStepPoint->SetTouchableHandle( theTouchableHandle );
|
|---|
| 208 |
|
|---|
| 209 | pPostStepPoint->SetMaterial( theMaterialChange );
|
|---|
| 210 | pPostStepPoint->SetMaterialCutsCouple( theMaterialCutsCoupleChange );
|
|---|
| 211 | pPostStepPoint->SetSensitiveDetector( theSensitiveDetectorChange );
|
|---|
| 212 | }
|
|---|
| 213 | if( this->GetLastStepInVolume() ){
|
|---|
| 214 | pStep->SetLastStepFlag();
|
|---|
| 215 | }else{
|
|---|
| 216 | pStep->ClearLastStepFlag();
|
|---|
| 217 | }
|
|---|
| 218 | // It used to call base class's method
|
|---|
| 219 | // - but this would copy uninitialised data members
|
|---|
| 220 | // return G4ParticleChange::UpdateStepForPostStep(pStep);
|
|---|
| 221 |
|
|---|
| 222 | // Copying what the base class does would instead
|
|---|
| 223 | // - also not useful
|
|---|
| 224 | // return G4VParticleChange::UpdateStepInfo(pStep);
|
|---|
| 225 |
|
|---|
| 226 | return pStep;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | //----------------------------------------------------------------
|
|---|
| 230 | // methods for printing messages
|
|---|
| 231 | //
|
|---|
| 232 |
|
|---|
| 233 | void G4ParticleChangeForTransport::DumpInfo() const
|
|---|
| 234 | {
|
|---|
| 235 | // use base-class DumpInfo
|
|---|
| 236 | G4ParticleChange::DumpInfo();
|
|---|
| 237 |
|
|---|
| 238 | G4cout.precision(3);
|
|---|
| 239 | G4cout << " Touchable (pointer) : "
|
|---|
| 240 | << std::setw(20) << theTouchableHandle()
|
|---|
| 241 | << G4endl;
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|