2 // ********************************************************************
3 // * License and Disclaimer *
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. *
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. *
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 // ********************************************************************
27 // $Id: G4Step.icc 81898 2014-06-06 13:43:20Z gcosmo $
30 //---------------------------------------------------------------
32 //-----------------------------------------------------------------
33 // In-line definitions
34 //-----------------------------------------------------------------
38 G4StepPoint* G4Step::GetPreStepPoint() const
40 return fpPreStepPoint;
44 void G4Step::SetPreStepPoint(G4StepPoint* value)
46 delete fpPreStepPoint;
47 fpPreStepPoint = value;
51 G4StepPoint* G4Step::GetPostStepPoint() const
53 return fpPostStepPoint;
57 void G4Step::SetPostStepPoint(G4StepPoint* value)
59 delete fpPostStepPoint;
60 fpPostStepPoint = value;
64 G4double G4Step::GetStepLength() const
70 void G4Step::SetStepLength(G4double value)
76 G4ThreeVector G4Step::GetDeltaPosition() const
78 return fpPostStepPoint->GetPosition()
79 - fpPreStepPoint->GetPosition();
83 G4double G4Step::GetDeltaTime() const
85 return fpPostStepPoint->GetLocalTime()
86 - fpPreStepPoint->GetLocalTime();
91 G4double G4Step::GetTotalEnergyDeposit() const
93 return fTotalEnergyDeposit;
97 void G4Step::SetTotalEnergyDeposit(G4double value)
99 fTotalEnergyDeposit = value;
103 G4double G4Step::GetNonIonizingEnergyDeposit() const
105 return fNonIonizingEnergyDeposit;
109 void G4Step::SetNonIonizingEnergyDeposit(G4double value)
111 fNonIonizingEnergyDeposit = value;
115 void G4Step::AddTotalEnergyDeposit(G4double value)
117 fTotalEnergyDeposit += value;
121 void G4Step::ResetTotalEnergyDeposit()
123 fTotalEnergyDeposit = 0.;
124 fNonIonizingEnergyDeposit = 0.;
128 void G4Step::AddNonIonizingEnergyDeposit(G4double value)
130 fNonIonizingEnergyDeposit += value;
134 void G4Step::ResetNonIonizingEnergyDeposit()
136 fNonIonizingEnergyDeposit = 0.;
140 void G4Step::SetControlFlag(G4SteppingControl value)
142 fpSteppingControlFlag = value;
146 G4SteppingControl G4Step::GetControlFlag() const
148 return fpSteppingControlFlag;
152 void G4Step::CopyPostToPreStepPoint( )
154 //This method is called at the beggining of each step
155 *(fpPreStepPoint) = *(fpPostStepPoint);
156 fpPostStepPoint->SetStepStatus(fUndefined);
158 // store number of secondaries
159 nSecondaryByLastStep = fSecondary->size();
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"
171 G4Track* G4Step::GetTrack() const
177 void G4Step::SetTrack(G4Track* value)
183 // Other member functions
185 void G4Step::InitializeStep( G4Track* aValue )
187 // Initialize G4Step attributes
189 fTotalEnergyDeposit = 0.;
190 fNonIonizingEnergyDeposit = 0.;
192 fpTrack->SetStepLength(0.);
194 nSecondaryByLastStep = 0;
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());
218 // should be placed after SetMaterial for preStep point
219 fpPreStepPoint->SetVelocity(fpTrack->CalculateVelocity());
221 (*fpPostStepPoint) = (*fpPreStepPoint);
225 void G4Step::UpdateTrack( )
227 // To avoid the circular dependency between G4Track, G4Step
228 // and G4StepPoint, G4Step has to manage the update actions.
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());
239 G4DynamicParticle* pParticle = (G4DynamicParticle*)(fpTrack->GetDynamicParticle());
240 pParticle->SetMass(fpPostStepPoint->GetMass());
241 pParticle->SetCharge(fpPostStepPoint->GetCharge());
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());
251 fpTrack->SetVelocity(fpPostStepPoint->GetVelocity());
254 inline const G4TrackVector* G4Step::GetSecondary() const
259 inline G4TrackVector* G4Step::GetfSecondary()
264 inline void G4Step::SetSecondary(G4TrackVector* value)
270 G4TrackVector* G4Step::NewSecondaryVector()
272 fSecondary=new G4TrackVector();
276 inline void G4Step::DeleteSecondaryVector()
278 if (fSecondary !=0) {
285 inline G4bool G4Step::IsFirstStepInVolume() const
287 return fFirstStepInVolume;
290 inline G4bool G4Step::IsLastStepInVolume() const
292 return fLastStepInVolume;
296 inline void G4Step::SetFirstStepFlag()
298 fFirstStepInVolume = true;
301 inline void G4Step::ClearFirstStepFlag()
303 fFirstStepInVolume = false;
306 inline void G4Step::SetLastStepFlag()
308 fLastStepInVolume = true;
311 inline void G4Step::ClearLastStepFlag()
313 fLastStepInVolume = false;