00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "G4ParticleChangeForTransport.hh"
00042 #include "G4TouchableHandle.hh"
00043 #include "G4Track.hh"
00044 #include "G4Step.hh"
00045 #include "G4TrackFastVector.hh"
00046 #include "G4DynamicParticle.hh"
00047
00048 G4ParticleChangeForTransport::G4ParticleChangeForTransport()
00049 : G4ParticleChange(), isMomentumChanged(false), theMaterialChange(0),
00050 theMaterialCutsCoupleChange(0), theSensitiveDetectorChange(0),
00051 fpVectorOfAuxiliaryPointsPointer(0)
00052 {
00053 if (verboseLevel>2) {
00054 G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() "
00055 << G4endl;
00056 }
00057 }
00058
00059 G4ParticleChangeForTransport::~G4ParticleChangeForTransport()
00060 {
00061 if (verboseLevel>2) {
00062 G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() "
00063 << G4endl;
00064 }
00065 }
00066
00067 G4ParticleChangeForTransport::
00068 G4ParticleChangeForTransport(const G4ParticleChangeForTransport &r)
00069 : G4ParticleChange(r),
00070 fpVectorOfAuxiliaryPointsPointer(0)
00071 {
00072 if (verboseLevel>0) {
00073 G4cout << "G4ParticleChangeForTransport:: copy constructor is called "
00074 << G4endl;
00075 }
00076 theTouchableHandle = r.theTouchableHandle;
00077 isMomentumChanged = r.isMomentumChanged;
00078 theMaterialChange = r.theMaterialChange;
00079 theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
00080 theSensitiveDetectorChange = r.theSensitiveDetectorChange;
00081 }
00082
00083
00084 G4ParticleChangeForTransport &
00085 G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport &r)
00086 {
00087 if (verboseLevel>1) {
00088 G4cout << "G4ParticleChangeForTransport:: assignment operator is called "
00089 << G4endl;
00090 }
00091 if (this != &r)
00092 {
00093 theListOfSecondaries = r.theListOfSecondaries;
00094 theSizeOftheListOfSecondaries = r.theSizeOftheListOfSecondaries;
00095 theNumberOfSecondaries = r.theNumberOfSecondaries;
00096 theStatusChange = r.theStatusChange;
00097 theTouchableHandle = r.theTouchableHandle;
00098 theMaterialChange = r.theMaterialChange;
00099 theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
00100 theSensitiveDetectorChange = r.theSensitiveDetectorChange;
00101 theMomentumDirectionChange = r.theMomentumDirectionChange;
00102 thePolarizationChange = r.thePolarizationChange;
00103 thePositionChange = r.thePositionChange;
00104 theTimeChange = r.theTimeChange;
00105 theEnergyChange = r.theEnergyChange;
00106 theVelocityChange = r.theVelocityChange;
00107 theTrueStepLength = r.theTrueStepLength;
00108 theLocalEnergyDeposit = r.theLocalEnergyDeposit;
00109 theSteppingControlFlag = r.theSteppingControlFlag;
00110 }
00111 return *this;
00112 }
00113
00114
00115
00116
00117
00118 G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
00119 {
00120
00121 if (verboseLevel>0) {
00122 G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called"
00123 << G4endl;
00124 G4cout << " Nothing happens for this method " << G4endl;
00125 }
00126
00127 return UpdateStepInfo(pStep);
00128 }
00129
00130
00131 G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
00132 {
00133
00134
00135 pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
00152 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
00153 G4Track* aTrack = pStep->GetTrack();
00154 G4double mass = aTrack->GetDynamicParticle()->GetMass();
00155
00156
00157
00158
00159
00160
00161
00162
00163 if (isMomentumChanged) {
00164 G4double energy;
00165 energy= pPostStepPoint->GetKineticEnergy()
00166 + (theEnergyChange - pPreStepPoint->GetKineticEnergy());
00167
00168
00169 G4ThreeVector pMomentum = pPostStepPoint->GetMomentum()
00170 + ( CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass)
00171 - pPreStepPoint->GetMomentum());
00172 G4double tMomentum = pMomentum.mag();
00173 G4ThreeVector direction(1.0,0.0,0.0);
00174 if( tMomentum > 0. ){
00175 G4double inv_Momentum= 1.0 / tMomentum;
00176 direction= pMomentum * inv_Momentum;
00177 }
00178 pPostStepPoint->SetMomentumDirection(direction);
00179 pPostStepPoint->SetKineticEnergy( energy );
00180 }
00181 if (isVelocityChanged) pPostStepPoint->SetVelocity(theVelocityChange);
00182
00183
00184
00185
00186
00187
00188 pPostStepPoint->AddPolarization( thePolarizationChange
00189 - pPreStepPoint->GetPolarization());
00190
00191
00192 pPostStepPoint->AddPosition( thePositionChange
00193 - pPreStepPoint->GetPosition() );
00194 pPostStepPoint->AddGlobalTime( theTimeChange
00195 - pPreStepPoint->GetLocalTime());
00196 pPostStepPoint->AddLocalTime( theTimeChange
00197 - pPreStepPoint->GetLocalTime());
00198 pPostStepPoint->AddProperTime( theProperTimeChange
00199 - pPreStepPoint->GetProperTime());
00200
00201 #ifdef G4VERBOSE
00202 if (debugFlag) CheckIt(*aTrack);
00203 #endif
00204
00205
00206
00207
00208 pStep->SetControlFlag( theSteppingControlFlag );
00209 return pStep;
00210
00211 }
00212
00213 G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
00214 {
00215
00216
00217
00218 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
00219 if(pPostStepPoint->GetKineticEnergy() > 0.0) {
00220
00221
00222
00223 pPostStepPoint->SetTouchableHandle( theTouchableHandle );
00224
00225 pPostStepPoint->SetMaterial( theMaterialChange );
00226 pPostStepPoint->SetMaterialCutsCouple( theMaterialCutsCoupleChange );
00227 pPostStepPoint->SetSensitiveDetector( theSensitiveDetectorChange );
00228 }
00229 if( this->GetLastStepInVolume() ){
00230 pStep->SetLastStepFlag();
00231 }else{
00232 pStep->ClearLastStepFlag();
00233 }
00234
00235
00236
00237
00238
00239
00240
00241
00242 return pStep;
00243 }
00244
00245
00246
00247
00248
00249
00250 void G4ParticleChangeForTransport::DumpInfo() const
00251 {
00252
00253 G4ParticleChange::DumpInfo();
00254
00255 G4int oldprc = G4cout.precision(3);
00256 G4cout << " Touchable (pointer) : "
00257 << std::setw(20) << theTouchableHandle() << G4endl;
00258 G4cout.precision(oldprc);
00259 }
00260