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