Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Step.cc
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// G4Step class implementation
27//
28// Authors:
29// Katsuya Amako (e-mail: [email protected])
30// Takashi Sasaki (e-mail: [email protected])
31// Revisions:
32// Hisaya Kurashige, 1998-2007
33// --------------------------------------------------------------------
34
35#include "G4Step.hh"
36
37// --------------------------------------------------------------------
39{
40 fpPreStepPoint = new G4StepPoint();
41 fpPostStepPoint = new G4StepPoint();
42
43 secondaryInCurrentStep = new std::vector<const G4Track*>;
44}
45
46// --------------------------------------------------------------------
48{
49 delete fpPreStepPoint;
50 fpPreStepPoint = nullptr;
51 delete fpPostStepPoint;
52 fpPostStepPoint = nullptr;
53
54 secondaryInCurrentStep->clear();
55 delete secondaryInCurrentStep;
56 secondaryInCurrentStep = nullptr;
57
58 if(fSecondary != nullptr)
59 {
60 fSecondary->clear();
61 delete fSecondary;
62 }
63 fSecondary = nullptr;
64}
65
66// --------------------------------------------------------------------
68 : fTotalEnergyDeposit(right.fTotalEnergyDeposit)
69 , fNonIonizingEnergyDeposit(right.fNonIonizingEnergyDeposit)
70 , fStepLength(right.fStepLength)
71 , fpTrack(right.fpTrack)
72 , fpSteppingControlFlag(right.fpSteppingControlFlag)
73 , fFirstStepInVolume(right.fFirstStepInVolume)
74 , fLastStepInVolume(right.fLastStepInVolume)
75 , nSecondaryByLastStep(right.nSecondaryByLastStep)
76 , secondaryInCurrentStep(right.secondaryInCurrentStep)
77 , fpVectorOfAuxiliaryPointsPointer(right.fpVectorOfAuxiliaryPointsPointer)
78{
79 if(right.fpPreStepPoint != nullptr)
80 {
81 fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
82 }
83 else
84 {
85 fpPreStepPoint = new G4StepPoint();
86 }
87 if(right.fpPostStepPoint != nullptr)
88 {
89 fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
90 }
91 else
92 {
93 fpPostStepPoint = new G4StepPoint();
94 }
95
96 if(right.fSecondary != nullptr)
97 {
98 fSecondary = new G4TrackVector(*(right.fSecondary));
99 }
100 else
101 {
102 fSecondary = new G4TrackVector();
103 }
104
105 // secondaryInCurrentStep is cleared
106 secondaryInCurrentStep = new std::vector<const G4Track*>;
107}
108
109// --------------------------------------------------------------------
111{
112 if(this != &right)
113 {
116 fStepLength = right.fStepLength;
117 fpTrack = right.fpTrack;
118 fpSteppingControlFlag = right.fpSteppingControlFlag;
119 fFirstStepInVolume = right.fFirstStepInVolume;
120 fLastStepInVolume = right.fLastStepInVolume;
121 nSecondaryByLastStep = right.nSecondaryByLastStep;
122 secondaryInCurrentStep = right.secondaryInCurrentStep;
123 fpVectorOfAuxiliaryPointsPointer = right.fpVectorOfAuxiliaryPointsPointer;
124
125 if(fpPreStepPoint != nullptr)
126 {
127 delete fpPreStepPoint;
128 }
129 if(right.fpPreStepPoint != nullptr)
130 {
131 fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
132 }
133 else
134 {
135 fpPreStepPoint = new G4StepPoint();
136 }
137 if(fpPostStepPoint != nullptr)
138 {
139 delete fpPostStepPoint;
140 }
141 if(right.fpPostStepPoint != nullptr)
142 {
143 fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
144 }
145 else
146 {
147 fpPostStepPoint = new G4StepPoint();
148 }
149
150 if(fSecondary != nullptr)
151 {
152 fSecondary->clear();
153 delete fSecondary;
154 }
155 if(right.fSecondary != nullptr)
156 {
157 fSecondary = new G4TrackVector(*(right.fSecondary));
158 }
159 else
160 {
161 fSecondary = new G4TrackVector();
162 }
163
164 // secondaryInCurrentStep is not copied
165 if(secondaryInCurrentStep != nullptr)
166 {
167 secondaryInCurrentStep->clear();
168 delete secondaryInCurrentStep;
169 }
170 secondaryInCurrentStep = new std::vector<const G4Track*>;
171 }
172 return *this;
173}
174
175// --------------------------------------------------------------------
177{
178 static G4ThreadLocal G4bool isFirstTime = true;
179 if(isFirstTime)
180 {
181 isFirstTime = false;
182#ifdef G4VERBOSE
183 G4Exception("G4Step::GetDeltaMomentum()", "Warning", JustWarning,
184 "This method is obsolete and will be removed soon");
185#endif
186 }
187
188 return fpPostStepPoint->GetMomentum() - fpPreStepPoint->GetMomentum();
189}
190
191// --------------------------------------------------------------------
193{
194 static G4ThreadLocal G4bool isFirstTime = true;
195 if(isFirstTime)
196 {
197 isFirstTime = false;
198#ifdef G4VERBOSE
199 G4Exception("G4Step::GetDeltaEnergy()", "Warning", JustWarning,
200 "This method is obsolete and will be removed soon");
201#endif
202 }
203
204 return fpPostStepPoint->GetKineticEnergy() -
205 fpPreStepPoint->GetKineticEnergy();
206}
207
208// --------------------------------------------------------------------
209const std::vector<const G4Track*>* G4Step::GetSecondaryInCurrentStep() const
210{
211 secondaryInCurrentStep->clear();
212 G4int nSecondary = fSecondary->size();
213 for(G4int i = nSecondaryByLastStep; i < nSecondary; ++i)
214 {
215 secondaryInCurrentStep->push_back((*fSecondary)[i]);
216 }
217 return secondaryInCurrentStep;
218}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::vector< G4Track * > G4TrackVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4ThreeVector GetMomentum() const
G4double GetKineticEnergy() const
Definition: G4Step.hh:62
~G4Step()
Definition: G4Step.cc:47
G4double GetDeltaEnergy() const
Definition: G4Step.cc:192
G4ThreeVector GetDeltaMomentum() const
Definition: G4Step.cc:176
G4Step()
Definition: G4Step.cc:38
G4Step & operator=(const G4Step &)
Definition: G4Step.cc:110
const std::vector< const G4Track * > * GetSecondaryInCurrentStep() const
Definition: G4Step.cc:209
G4double fNonIonizingEnergyDeposit
Definition: G4Step.hh:177
G4double fTotalEnergyDeposit
Definition: G4Step.hh:174
#define G4ThreadLocal
Definition: tls.hh:77