Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleChangeForTransport.cc
이 파일의 문서화 페이지로 가기
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 87698 2014-12-17 09:41:28Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 //
34 //
35 // ------------------------------------------------------------
36 // Implemented for the new scheme 10 May. 1998 H.Kurahige
37 // Correct tratment of fpNextTouchable 12 May. 1998 H.Kurashige
38 // Change to the next volume only if energy>0 19 Jan. 2004 V.Ivanchenko
39 // --------------------------------------------------------------
40 
42 #include "G4TouchableHandle.hh"
43 #include "G4Track.hh"
44 #include "G4Step.hh"
45 #include "G4TrackFastVector.hh"
46 #include "G4DynamicParticle.hh"
47 
49  : G4ParticleChange(), isMomentumChanged(false), theMaterialChange(0),
50  theMaterialCutsCoupleChange(0), theSensitiveDetectorChange(0),
51  fpVectorOfAuxiliaryPointsPointer(0)
52 {
53  if (verboseLevel>2) {
54  G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() "
55  << G4endl;
56  }
57 }
58 
60 {
61  if (verboseLevel>2) {
62  G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() "
63  << G4endl;
64  }
65 }
66 
69  : G4ParticleChange(r),
70  fpVectorOfAuxiliaryPointsPointer(0)
71 {
72  if (verboseLevel>0) {
73  G4cout << "G4ParticleChangeForTransport:: copy constructor is called "
74  << G4endl;
75  }
81 }
82 
83 // assignemnt operator
86 {
87  if (verboseLevel>1) {
88  G4cout << "G4ParticleChangeForTransport:: assignment operator is called "
89  << G4endl;
90  }
91  if (this != &r)
92  {
110  }
111  return *this;
112 }
113 
114 //----------------------------------------------------------------
115 // methods for updating G4Step
116 //
117 
119 {
120  // Nothing happens for AtRestDoIt
121  if (verboseLevel>0) {
122  G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called"
123  << G4endl;
124  G4cout << " Nothing happens for this method " << G4endl;
125  }
126  // Update the G4Step specific attributes
127  return UpdateStepInfo(pStep);
128 }
129 
130 
132 {
133  // Smooth curved tajectory representation: let the Step know about
134  // the auxiliary trajectory points (jacek 30/10/2002)
136 
137  // copy of G4ParticleChange::UpdateStepForAlongStep
138  // i.e. no effect for touchable
139 
140  // A physics process always calculates the final state of the
141  // particle relative to the initial state at the beginning
142  // of the Step, i.e., based on information of G4Track (or
143  // equivalently the PreStepPoint).
144  // So, the differences (delta) between these two states have to be
145  // calculated and be accumulated in PostStepPoint.
146 
147  // Take note that the return type of GetMomentumChange is a
148  // pointer to G4ThreeVector. Also it is a normalized
149  // momentum vector.
150 
151  G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
152  G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
153  G4Track* aTrack = pStep->GetTrack();
154  G4double mass = aTrack->GetDynamicParticle()->GetMass();
155 
156  // uodate kinetic energy
157  // now assume that no energy change in transportation
158  // However it is not true in electric fields
159  // Case for changing energy will be implemented in future
160 
161 
162  // update momentum direction and energy
163  if (isMomentumChanged) {
165  energy= pPostStepPoint->GetKineticEnergy()
166  + (theEnergyChange - pPreStepPoint->GetKineticEnergy());
167 
168  // calculate new momentum
169  G4ThreeVector pMomentum = pPostStepPoint->GetMomentum()
171  - pPreStepPoint->GetMomentum());
172  G4double tMomentum = pMomentum.mag();
173  G4ThreeVector direction(1.0,0.0,0.0);
174  if( tMomentum > 0. ){
175  G4double inv_Momentum= 1.0 / tMomentum;
176  direction= pMomentum * inv_Momentum;
177  }
178  pPostStepPoint->SetMomentumDirection(direction);
179  pPostStepPoint->SetKineticEnergy( energy );
180  }
181  if (isVelocityChanged) pPostStepPoint->SetVelocity(theVelocityChange);
182 
183  // stop case should not occur
184  //pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
185 
186 
187  // update polarization
188  pPostStepPoint->AddPolarization( thePolarizationChange
189  - pPreStepPoint->GetPolarization());
190 
191  // update position and time
192  pPostStepPoint->AddPosition( thePositionChange
193  - pPreStepPoint->GetPosition() );
194  pPostStepPoint->AddGlobalTime( theTimeChange
195  - pPreStepPoint->GetLocalTime());
196  pPostStepPoint->AddLocalTime( theTimeChange
197  - pPreStepPoint->GetLocalTime());
198  pPostStepPoint->AddProperTime( theProperTimeChange
199  - pPreStepPoint->GetProperTime());
200 
201 #ifdef G4VERBOSE
202  if (debugFlag) CheckIt(*aTrack);
203 #endif
204 
205  // Update the G4Step specific attributes
206  //pStep->SetStepLength( theTrueStepLength );
207  // pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
209  return pStep;
210  // return UpdateStepInfo(pStep);
211 }
212 
214 {
215  // A physics process always calculates the final state of the particle
216 
217  // Change volume only if some kinetic energy remains
218  G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
219  if(pPostStepPoint->GetKineticEnergy() > 0.0) {
220 
221  // update next touchable
222  // (touchable can be changed only at PostStepDoIt)
223  pPostStepPoint->SetTouchableHandle( theTouchableHandle );
224 
225  pPostStepPoint->SetMaterial( theMaterialChange );
228  }
229  if( this->GetFirstStepInVolume() ){
230  pStep->SetFirstStepFlag();
231  }else{
232  pStep->ClearFirstStepFlag();
233  }
234  if( this->GetLastStepInVolume() ){
235  pStep->SetLastStepFlag();
236  }else{
237  pStep->ClearLastStepFlag();
238  }
239  // It used to call base class's method
240  // - but this would copy uninitialised data members
241  // return G4ParticleChange::UpdateStepForPostStep(pStep);
242 
243  // Copying what the base class does would instead
244  // - also not useful
245  // return G4VParticleChange::UpdateStepInfo(pStep);
246 
247  return pStep;
248 }
249 
250 
251 //----------------------------------------------------------------
252 // methods for printing messages
253 //
254 
256 {
257 // use base-class DumpInfo
259 
260  G4int oldprc = G4cout.precision(3);
261  G4cout << " Touchable (pointer) : "
262  << std::setw(20) << theTouchableHandle() << G4endl;
263  G4cout.precision(oldprc);
264 }
265 
void AddLocalTime(const G4double aValue)
G4ThreeVector CalcMomentum(G4double energy, G4ThreeVector direction, G4double mass) const
G4ThreeVector thePolarizationChange
G4double GetProperTime() const
G4TrackFastVector * theListOfSecondaries
void SetSensitiveDetector(G4VSensitiveDetector *)
G4StepPoint * GetPreStepPoint() const
virtual G4Step * UpdateStepForAlongStep(G4Step *Step)
#define G4endl
Definition: G4ios.hh:61
void SetVelocity(G4double v)
void SetMomentumDirection(const G4ThreeVector &aValue)
void AddPolarization(const G4ThreeVector &aValue)
G4ParticleChangeForTransport & operator=(const G4ParticleChangeForTransport &right)
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *theNewVectorPointer)
Definition: G4Step.hh:239
void AddProperTime(const G4double aValue)
virtual G4Step * UpdateStepForAtRest(G4Step *Step)
G4SteppingControl theSteppingControlFlag
G4Step * UpdateStepInfo(G4Step *Step)
G4ThreeVector thePositionChange
double G4double
Definition: G4Types.hh:76
void AddGlobalTime(const G4double aValue)
G4bool GetFirstStepInVolume() const
G4TrackStatus theStatusChange
void SetKineticEnergy(const G4double aValue)
std::vector< G4ThreeVector > * fpVectorOfAuxiliaryPointsPointer
const G4ThreeVector & GetPosition() const
double energy
Definition: plottest35.C:25
G4Track * GetTrack() const
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
G4double GetKineticEnergy() const
const G4MaterialCutsCouple * theMaterialCutsCoupleChange
const G4ThreeVector & GetPolarization() const
virtual void DumpInfo() const
double mag() const
int G4int
Definition: G4Types.hh:78
void SetLastStepFlag()
void SetMaterialCutsCouple(const G4MaterialCutsCouple *)
G4GLOB_DLL std::ostream G4cout
void ClearFirstStepFlag()
G4bool GetLastStepInVolume() const
void SetFirstStepFlag()
void SetMaterial(G4Material *)
G4ThreeVector GetMomentum() const
G4double GetMass() const
void AddPosition(const G4ThreeVector &aValue)
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4ThreeVector theMomentumDirectionChange
virtual G4bool CheckIt(const G4Track &)
G4double GetLocalTime() const
const G4DynamicParticle * GetDynamicParticle() const
void SetControlFlag(G4SteppingControl StepControlFlag)
virtual G4Step * UpdateStepForPostStep(G4Step *Step)
G4VSensitiveDetector * theSensitiveDetectorChange
void ClearLastStepFlag()
G4double theProperTimeChange