Geant4  10.03
G4VParticleChange.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: G4VParticleChange.icc 68795 2013-04-05 13:24:46Z gcosmo $
28 //
29 // remove obsolete methods of SetXXX 19 Sep, 04 H.Kurashige
30 //----------------------------------------------------------------
31 //----------------------------------------------------------------
32 // Set/Get inline functions
33 //
34 inline
35  G4Track* G4VParticleChange::GetSecondary(G4int anIndex) const
36 {
37  return (*theListOfSecondaries)[anIndex];
38 }
39 
40 inline
41  G4int G4VParticleChange::GetNumberOfSecondaries() const
42 {
43  return theNumberOfSecondaries;
44 }
45 
46 inline
47  void G4VParticleChange::ProposeTrackStatus(G4TrackStatus aStatus)
48 {
49  theStatusChange = aStatus;
50 }
51 
52 inline
53  G4TrackStatus G4VParticleChange::GetTrackStatus() const
54 {
55  return theStatusChange;
56 }
57 
58 inline
59 G4SteppingControl G4VParticleChange::GetSteppingControl() const
60 {
61  return theSteppingControlFlag;
62 }
63 
64 inline
65 void G4VParticleChange::ProposeSteppingControl(G4SteppingControl StepControlFlag)
66 {
67  theSteppingControlFlag = StepControlFlag;
68 }
69 
70 inline
71 G4bool G4VParticleChange::GetFirstStepInVolume() const
72 {
73  return theFirstStepInVolume;
74 }
75 
76 inline
77 G4bool G4VParticleChange::GetLastStepInVolume() const
78 {
79  return theLastStepInVolume;
80 }
81 
82 inline
83 void G4VParticleChange::ProposeFirstStepInVolume(G4bool flag)
84 {
85  theFirstStepInVolume = flag;
86 }
87 
88 inline
89 void G4VParticleChange::ProposeLastStepInVolume(G4bool flag)
90 {
91  theLastStepInVolume = flag;
92 }
93 
94 //----------------------------------------------------------------
95 // Set/Get inline functions
96 //
97 
98 inline
99  G4double G4VParticleChange::GetLocalEnergyDeposit() const
100 {
101  return theLocalEnergyDeposit;
102 }
103 
104 inline
105  void G4VParticleChange::ProposeLocalEnergyDeposit(G4double anEnergyPart)
106 {
107  theLocalEnergyDeposit = anEnergyPart;
108 }
109 
110 inline
111  G4double G4VParticleChange::GetNonIonizingEnergyDeposit() const
112 {
113  return theNonIonizingEnergyDeposit;
114 }
115 
116 inline
117  void G4VParticleChange::ProposeNonIonizingEnergyDeposit(G4double anEnergyPart)
118 {
119  theNonIonizingEnergyDeposit = anEnergyPart;
120 }
121 
122 inline
123  G4double G4VParticleChange::GetTrueStepLength() const
124 {
125  return theTrueStepLength;
126 }
127 
128 inline
129  void G4VParticleChange::ProposeTrueStepLength(G4double aLength)
130 {
131  theTrueStepLength = aLength;
132 }
133 
134 
135 inline
136  void G4VParticleChange::SetVerboseLevel(G4int vLevel)
137 {
138  verboseLevel = vLevel;
139 }
140 
141 inline
142  G4int G4VParticleChange::GetVerboseLevel() const
143 {
144  return verboseLevel;
145 }
146 
147 inline
148  G4double G4VParticleChange::GetParentWeight() const
149 {
150  return theParentWeight;
151 }
152 
153 inline
154  G4double G4VParticleChange::GetWeight() const
155 {
156  return theParentWeight;
157 }
158 
159 
160 //----------------------------------------------------------------
161 // inline functions for Initialization
162 //
163 
164 inline
165  void G4VParticleChange::InitializeLocalEnergyDeposit(const G4Track&)
166 {
167  // clear theLocalEnergyDeposited
168  theLocalEnergyDeposit = 0.0;
169  theNonIonizingEnergyDeposit = 0.0;
170 }
171 
172 inline
173  void G4VParticleChange::InitializeSteppingControl(const G4Track& )
174 {
175  // SteppingControlFlag
176  theSteppingControlFlag = NormalCondition;
177 }
178 
179 inline
180  void G4VParticleChange::Clear()
181 {
182  theNumberOfSecondaries = 0;
183  theFirstStepInVolume = false;
184  theLastStepInVolume = false;
185 }
186 
187 //----------------------------------------------------------------
188 // functions for Initialization
189 //
190 
191 inline void G4VParticleChange::InitializeStatusChange(const G4Track& track)
192 {
193  // set TrackStatus equal to the parent track's one
194  theStatusChange = track.GetTrackStatus();
195 }
196 
197 inline void G4VParticleChange::InitializeParentWeight(const G4Track& track)
198 {
199  // set the parent track's weight
200  theParentWeight = track.GetWeight();
201  isParentWeightProposed = false;
202 }
203 
204 inline void G4VParticleChange::InitializeParentGlobalTime(const G4Track& track)
205 {
206  // set the parent track's global time at the pre-step point
207  theParentGlobalTime = track.GetStep()->GetPreStepPoint()->GetGlobalTime();
208 }
209 
210 
211 inline void G4VParticleChange::InitializeTrueStepLength(const G4Track& track)
212 {
213  // Reset theTrueStepLength
214  // !! Caution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
215  theTrueStepLength = track.GetStep()->GetStepLength();
216  // !! TrueStepLength should be copied from G4Step not G4Track
217  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
218 }
219 
220 //----------------------------------------------------------------
221 // methods for initialize
222 inline
223 void G4VParticleChange::InitializeStepInVolumeFlags(const G4Track& track)
224 {
225  const G4Step* aStep = track.GetStep();
226  theFirstStepInVolume = aStep-> IsFirstStepInVolume();
227  theLastStepInVolume = aStep-> IsLastStepInVolume();
228 }
229 
230 inline void G4VParticleChange::InitializeSecondaries(const G4Track&)
231 {
232  // clear secondaries
233  if (theNumberOfSecondaries>0) {
234 #ifdef G4VERBOSE
235  if (verboseLevel>0) {
236  G4cerr << "G4VParticleChange::Initialize() Warning ";
237  G4cerr << "theListOfSecondaries is not empty " << G4endl;
238  G4cerr << "All objects in theListOfSecondaries are destroyed!" << G4endl;
239  }
240 #endif
241  for (G4int index= 0; index<theNumberOfSecondaries; index++){
242  if ( (*theListOfSecondaries)[index] ){
243  delete (*theListOfSecondaries)[index] ;
244  }
245  }
246  }
247  theNumberOfSecondaries = 0;
248 }
249 
250 //----------------------------------------------------------------
251 // methods for handling secondaries
252 //
253 
254 inline void G4VParticleChange::SetNumberOfSecondaries(G4int totSecondaries)
255 {
256  // check if tracks still exist in theListOfSecondaries
257  if (theNumberOfSecondaries>0) {
258 #ifdef G4VERBOSE
259  if (verboseLevel>0) {
260  G4cerr << "G4VParticleChange::SetNumberOfSecondaries() Warning ";
261  G4cerr << "theListOfSecondaries is not empty ";
262  }
263 #endif
264  for (G4int index= 0; index<theNumberOfSecondaries; index++){
265  if ( (*theListOfSecondaries)[index] ){
266  delete (*theListOfSecondaries)[index] ;
267  }
268  }
269  }
270  theNumberOfSecondaries = 0;
271  theSizeOftheListOfSecondaries = totSecondaries;
272 
273  // Initialize ListOfSecondaries
274  theListOfSecondaries->Initialize(totSecondaries);
275 }
276 
277 inline void G4VParticleChange::Initialize(const G4Track& track)
278 {
279  InitializeStatusChange(track);
280  InitializeLocalEnergyDeposit(track);
281  InitializeSteppingControl(track);
282  InitializeTrueStepLength(track);
283  InitializeSecondaries(track);
284  InitializeParentWeight(track);
285  InitializeParentGlobalTime(track);
286  InitializeStepInVolumeFlags(track);
287 }
288 
289 inline
290  void G4VParticleChange::ClearDebugFlag()
291 {
292  debugFlag = false;
293 }
294 
295 inline
296  void G4VParticleChange::SetDebugFlag()
297 {
298  debugFlag = true;
299 }
300 
301 inline
302  G4bool G4VParticleChange::GetDebugFlag() const
303 {
304  return debugFlag;
305 }
306 
307 inline
308  void G4VParticleChange::SetSecondaryWeightByProcess(G4bool flag)
309 {
310  fSetSecondaryWeightByProcess = flag;
311 }
312 
313 inline
314  G4bool G4VParticleChange::IsSecondaryWeightSetByProcess() const
315 {
316  return fSetSecondaryWeightByProcess;
317 }
318 
319 inline
320  void G4VParticleChange::ProposeWeight(G4double w)
321 {
322  theParentWeight = w;
323  isParentWeightProposed = true;
324 }
325 
326 inline
327  void G4VParticleChange::ProposeParentWeight(G4double w)
328 {
329  ProposeWeight(w);
330 }
331