Geant4  10.00.p01
G4Step.icc
Go to the documentation of this file.
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: G4Step.icc 68795 2013-04-05 13:24:46Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 //-----------------------------------------------------------------
33 // In-line definitions
34 //-----------------------------------------------------------------
35 
36 // Get/Set functions
37 inline
38  G4StepPoint* G4Step::GetPreStepPoint() const
39  {
40  return fpPreStepPoint;
41  }
42 
43 inline
44  void G4Step::SetPreStepPoint(G4StepPoint* value)
45  {
46  fpPreStepPoint = value;
47  }
48 
49 inline
50  G4StepPoint* G4Step::GetPostStepPoint() const
51  {
52  return fpPostStepPoint;
53  }
54 
55 inline
56  void G4Step::SetPostStepPoint(G4StepPoint* value)
57  {
58  fpPostStepPoint = value;
59  }
60 
61 inline
62  G4double G4Step::GetStepLength() const
63  {
64  return fStepLength;
65  }
66 
67 inline
68  void G4Step::SetStepLength(G4double value)
69  {
70  fStepLength = value;
71  }
72 
73 inline
74  G4ThreeVector G4Step::GetDeltaPosition() const
75  {
76  return fpPostStepPoint->GetPosition()
77  - fpPreStepPoint->GetPosition();
78  }
79 
80 inline
81  G4double G4Step::GetDeltaTime() const
82  {
83  return fpPostStepPoint->GetLocalTime()
84  - fpPreStepPoint->GetLocalTime();
85  }
86 
87 
88 inline
89  G4double G4Step::GetTotalEnergyDeposit() const
90  {
91  return fTotalEnergyDeposit;
92  }
93 
94 inline
95  void G4Step::SetTotalEnergyDeposit(G4double value)
96  {
97  fTotalEnergyDeposit = value;
98  }
99 
100 inline
101  G4double G4Step::GetNonIonizingEnergyDeposit() const
102  {
103  return fNonIonizingEnergyDeposit;
104  }
105 
106 inline
107  void G4Step::SetNonIonizingEnergyDeposit(G4double value)
108  {
109  fNonIonizingEnergyDeposit = value;
110  }
111 
112 inline
113  void G4Step::AddTotalEnergyDeposit(G4double value)
114  {
115  fTotalEnergyDeposit += value;
116  }
117 
118 inline
119  void G4Step::ResetTotalEnergyDeposit()
120  {
121  fTotalEnergyDeposit = 0.;
122  fNonIonizingEnergyDeposit = 0.;
123  }
124 
125 inline
126  void G4Step::AddNonIonizingEnergyDeposit(G4double value)
127  {
128  fNonIonizingEnergyDeposit += value;
129  }
130 
131 inline
132  void G4Step::ResetNonIonizingEnergyDeposit()
133  {
134  fNonIonizingEnergyDeposit = 0.;
135  }
136 
137 inline
138  void G4Step::SetControlFlag(G4SteppingControl value)
139  {
140  fpSteppingControlFlag = value;
141  }
142 
143 inline
144  G4SteppingControl G4Step::GetControlFlag() const
145  {
146  return fpSteppingControlFlag;
147  }
148 
149 inline
150  void G4Step::CopyPostToPreStepPoint( )
151  {
152  //This method is called at the beggining of each step
153  *(fpPreStepPoint) = *(fpPostStepPoint);
154  fpPostStepPoint->SetStepStatus(fUndefined);
155 
156  // store number of secondaries
157  nSecondaryByLastStep = fSecondary->size();
158 }
159 
160 
161 //-------------------------------------------------------------
162 // To implement bi-directional association between G4Step and
163 // and G4Track, a combined usage of 'forward declaration' and
164 // 'include' is necessary.
165 //-------------------------------------------------------------
166 #include "G4Track.hh"
167 
168 inline
169  G4Track* G4Step::GetTrack() const
170  {
171  return fpTrack;
172  }
173 
174 inline
175  void G4Step::SetTrack(G4Track* value)
176  {
177  fpTrack = value;
178  }
179 
180 
181 // Other member functions
182 inline
183  void G4Step::InitializeStep( G4Track* aValue )
184  {
185  // Initialize G4Step attributes
186  fStepLength = 0.;
187  fTotalEnergyDeposit = 0.;
188  fNonIonizingEnergyDeposit = 0.;
189  fpTrack = aValue;
190  fpTrack->SetStepLength(0.);
191 
192  nSecondaryByLastStep = 0;
193 
194  // Initialize G4StepPoint attributes.
195  // To avoid the circular dependency between G4Track, G4Step
196  // and G4StepPoint, G4Step has to manage the copy actions.
197  fpPreStepPoint->SetPosition(fpTrack->GetPosition());
198  fpPreStepPoint->SetGlobalTime(fpTrack->GetGlobalTime());
199  fpPreStepPoint->SetLocalTime(fpTrack->GetLocalTime());
200  fpPreStepPoint->SetProperTime(fpTrack->GetProperTime());
201  fpPreStepPoint->SetMomentumDirection(fpTrack->GetMomentumDirection());
202  fpPreStepPoint->SetKineticEnergy(fpTrack->GetKineticEnergy());
203  fpPreStepPoint->SetTouchableHandle(fpTrack->GetTouchableHandle());
204  fpPreStepPoint->SetMaterial( fpTrack->GetTouchable()->GetVolume()->GetLogicalVolume()->GetMaterial());
205  fpPreStepPoint->SetMaterialCutsCouple( fpTrack->GetTouchable()->GetVolume()->GetLogicalVolume()->GetMaterialCutsCouple());
206  fpPreStepPoint->SetSensitiveDetector( fpTrack->GetTouchable()->GetVolume()->GetLogicalVolume()->GetSensitiveDetector());
207  fpPreStepPoint->SetPolarization(fpTrack->GetPolarization());
208  fpPreStepPoint->SetSafety(0.);
209  fpPreStepPoint->SetStepStatus(fUndefined);
210  fpPreStepPoint->SetProcessDefinedStep(0);
211  fpPreStepPoint->SetMass(fpTrack->GetDynamicParticle()->GetMass());
212  fpPreStepPoint->SetCharge(fpTrack->GetDynamicParticle()->GetCharge());
213  fpPreStepPoint->SetWeight(fpTrack->GetWeight());
214 
215  // Set Velocity
216  // should be placed after SetMaterial for preStep point
217  fpPreStepPoint->SetVelocity(fpTrack->CalculateVelocity());
218 
219  (*fpPostStepPoint) = (*fpPreStepPoint);
220  }
221 
222 inline
223  void G4Step::UpdateTrack( )
224  {
225  // To avoid the circular dependency between G4Track, G4Step
226  // and G4StepPoint, G4Step has to manage the update actions.
227  // position, time
228  fpTrack->SetPosition(fpPostStepPoint->GetPosition());
229  fpTrack->SetGlobalTime(fpPostStepPoint->GetGlobalTime());
230  fpTrack->SetLocalTime(fpPostStepPoint->GetLocalTime());
231  fpTrack->SetProperTime(fpPostStepPoint->GetProperTime());
232  // energy, momentum, polarization
233  fpTrack->SetMomentumDirection(fpPostStepPoint->GetMomentumDirection());
234  fpTrack->SetKineticEnergy(fpPostStepPoint->GetKineticEnergy());
235  fpTrack->SetPolarization(fpPostStepPoint->GetPolarization());
236  // mass charge
237  G4DynamicParticle* pParticle = (G4DynamicParticle*)(fpTrack->GetDynamicParticle());
238  pParticle->SetMass(fpPostStepPoint->GetMass());
239  pParticle->SetCharge(fpPostStepPoint->GetCharge());
240  // step length
241  fpTrack->SetStepLength(fStepLength);
242  // NextTouchable is updated
243  // (G4Track::Touchable points touchable of Pre-StepPoint)
244  fpTrack->SetNextTouchableHandle(fpPostStepPoint->GetTouchableHandle());
245  fpTrack->SetWeight(fpPostStepPoint->GetWeight());
246 
247 
248  // set velocity
249  fpTrack->SetVelocity(fpPostStepPoint->GetVelocity());
250 }
251 
252 inline const G4TrackVector* G4Step::GetSecondary() const
253 {
254  return fSecondary;
255 }
256 
257 inline G4TrackVector* G4Step::GetfSecondary()
258 {
259  return fSecondary;
260 }
261 
262 inline void G4Step::SetSecondary(G4TrackVector* value)
263 {
264  fSecondary=value;
265 }
266 
267 inline
268  G4TrackVector* G4Step::NewSecondaryVector()
269 {
270  fSecondary=new G4TrackVector();
271  return fSecondary;
272 }
273 
274 inline void G4Step::DeleteSecondaryVector()
275 {
276  if (fSecondary !=0) {
277  fSecondary->clear();
278  delete fSecondary;
279  fSecondary = 0;
280  }
281 }
282 
283 inline G4bool G4Step::IsFirstStepInVolume() const
284 {
285  return fFirstStepInVolume;
286 }
287 
288 inline G4bool G4Step::IsLastStepInVolume() const
289 {
290  return fLastStepInVolume;
291 }
292 
293 
294  inline void G4Step::SetFirstStepFlag()
295 {
296  fFirstStepInVolume = true;
297 }
298 
299  inline void G4Step::ClearFirstStepFlag()
300 {
301  fFirstStepInVolume = false;
302 }
303 
304  inline void G4Step::SetLastStepFlag()
305 {
306  fLastStepInVolume = true;
307 }
308 
309  inline void G4Step::ClearLastStepFlag()
310 {
311  fLastStepInVolume = false;
312 }
313