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 68795 2013-04-05 13:24:46Z gcosmo $
30 //---------------------------------------------------------------
32 //-----------------------------------------------------------------
33 // In-line definitions
34 //-----------------------------------------------------------------
38 G4StepPoint* G4Step::GetPreStepPoint() const
40 return fpPreStepPoint;
44 void G4Step::SetPreStepPoint(G4StepPoint* value)
46 fpPreStepPoint = value;
50 G4StepPoint* G4Step::GetPostStepPoint() const
52 return fpPostStepPoint;
56 void G4Step::SetPostStepPoint(G4StepPoint* value)
58 fpPostStepPoint = value;
62 G4double G4Step::GetStepLength() const
68 void G4Step::SetStepLength(G4double value)
74 G4ThreeVector G4Step::GetDeltaPosition() const
76 return fpPostStepPoint->GetPosition()
77 - fpPreStepPoint->GetPosition();
81 G4double G4Step::GetDeltaTime() const
83 return fpPostStepPoint->GetLocalTime()
84 - fpPreStepPoint->GetLocalTime();
89 G4double G4Step::GetTotalEnergyDeposit() const
91 return fTotalEnergyDeposit;
95 void G4Step::SetTotalEnergyDeposit(G4double value)
97 fTotalEnergyDeposit = value;
101 G4double G4Step::GetNonIonizingEnergyDeposit() const
103 return fNonIonizingEnergyDeposit;
107 void G4Step::SetNonIonizingEnergyDeposit(G4double value)
109 fNonIonizingEnergyDeposit = value;
113 void G4Step::AddTotalEnergyDeposit(G4double value)
115 fTotalEnergyDeposit += value;
119 void G4Step::ResetTotalEnergyDeposit()
121 fTotalEnergyDeposit = 0.;
122 fNonIonizingEnergyDeposit = 0.;
126 void G4Step::AddNonIonizingEnergyDeposit(G4double value)
128 fNonIonizingEnergyDeposit += value;
132 void G4Step::ResetNonIonizingEnergyDeposit()
134 fNonIonizingEnergyDeposit = 0.;
138 void G4Step::SetControlFlag(G4SteppingControl value)
140 fpSteppingControlFlag = value;
144 G4SteppingControl G4Step::GetControlFlag() const
146 return fpSteppingControlFlag;
150 void G4Step::CopyPostToPreStepPoint( )
152 //This method is called at the beggining of each step
153 *(fpPreStepPoint) = *(fpPostStepPoint);
154 fpPostStepPoint->SetStepStatus(fUndefined);
156 // store number of secondaries
157 nSecondaryByLastStep = fSecondary->size();
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"
169 G4Track* G4Step::GetTrack() const
175 void G4Step::SetTrack(G4Track* value)
181 // Other member functions
183 void G4Step::InitializeStep( G4Track* aValue )
185 // Initialize G4Step attributes
187 fTotalEnergyDeposit = 0.;
188 fNonIonizingEnergyDeposit = 0.;
190 fpTrack->SetStepLength(0.);
192 nSecondaryByLastStep = 0;
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());
216 // should be placed after SetMaterial for preStep point
217 fpPreStepPoint->SetVelocity(fpTrack->CalculateVelocity());
219 (*fpPostStepPoint) = (*fpPreStepPoint);
223 void G4Step::UpdateTrack( )
225 // To avoid the circular dependency between G4Track, G4Step
226 // and G4StepPoint, G4Step has to manage the update actions.
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());
237 G4DynamicParticle* pParticle = (G4DynamicParticle*)(fpTrack->GetDynamicParticle());
238 pParticle->SetMass(fpPostStepPoint->GetMass());
239 pParticle->SetCharge(fpPostStepPoint->GetCharge());
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());
249 fpTrack->SetVelocity(fpPostStepPoint->GetVelocity());
252 inline const G4TrackVector* G4Step::GetSecondary() const
257 inline G4TrackVector* G4Step::GetfSecondary()
262 inline void G4Step::SetSecondary(G4TrackVector* value)
268 G4TrackVector* G4Step::NewSecondaryVector()
270 fSecondary=new G4TrackVector();
274 inline void G4Step::DeleteSecondaryVector()
276 if (fSecondary !=0) {
283 inline G4bool G4Step::IsFirstStepInVolume() const
285 return fFirstStepInVolume;
288 inline G4bool G4Step::IsLastStepInVolume() const
290 return fLastStepInVolume;
294 inline void G4Step::SetFirstStepFlag()
296 fFirstStepInVolume = true;
299 inline void G4Step::ClearFirstStepFlag()
301 fFirstStepInVolume = false;
304 inline void G4Step::SetLastStepFlag()
306 fLastStepInVolume = true;
309 inline void G4Step::ClearLastStepFlag()
311 fLastStepInVolume = false;