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 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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