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