Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RichTrajectoryPoint.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//
27// $Id$
28//
29//
30// ---------------------------------------------------------------
31//
32// G4RichTrajectoryPoint.cc
33//
34// Contact:
35// Questions and comments on G4TrajectoryPoint, on which this is based,
36// should be sent to
37// Katsuya Amako (e-mail: [email protected])
38// Makoto Asai (e-mail: [email protected])
39// Takashi Sasaki (e-mail: [email protected])
40// and on the extended code to:
41// John Allison (e-mail: [email protected])
42// Joseph Perl (e-mail: [email protected])
43//
44// ---------------------------------------------------------------
45
47
48#include "G4Track.hh"
49#include "G4Step.hh"
50#include "G4VProcess.hh"
51
52#include "G4AttDefStore.hh"
53#include "G4AttDef.hh"
54#include "G4AttValue.hh"
55#include "G4UnitsTable.hh"
56
57//#define G4ATTDEBUG
58#ifdef G4ATTDEBUG
59#include "G4AttCheck.hh"
60#endif
61
62#include <sstream>
63
65
67 fpAuxiliaryPointVector(0),
68 fTotEDep(0.),
69 fRemainingEnergy(0.),
70 fpProcess(0),
71 fPreStepPointStatus(fUndefined),
72 fPostStepPointStatus(fUndefined),
73 fPreStepPointGlobalTime(0),
74 fPostStepPointGlobalTime(0),
75 fPreStepPointWeight(1.),
76 fPostStepPointWeight(1.)
77{}
78
80 G4TrajectoryPoint(aTrack->GetPosition()),
81 fpAuxiliaryPointVector(0),
82 fTotEDep(0.),
83 fRemainingEnergy(aTrack->GetKineticEnergy()),
84 fpProcess(0),
85 fPreStepPointStatus(fUndefined),
86 fPostStepPointStatus(fUndefined),
87 fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
88 fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
89 fpPreStepPointVolume(aTrack->GetTouchableHandle()),
90 fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
91 fPreStepPointWeight(aTrack->GetWeight()),
92 fPostStepPointWeight(aTrack->GetWeight())
93{}
94
96 G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
97 fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
98 fTotEDep(aStep->GetTotalEnergyDeposit())
99{
100 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
101 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
102 if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) { // First step
103 fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
104 } else {
105 fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
106 }
107 fpProcess = postStepPoint->GetProcessDefinedStep();
108 fPreStepPointStatus = preStepPoint->GetStepStatus();
109 fPostStepPointStatus = postStepPoint->GetStepStatus();
110 fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
111 fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
112 fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
113 fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
114 fPreStepPointWeight = preStepPoint->GetWeight();
115 fPostStepPointWeight = postStepPoint->GetWeight();
116
117 /*
118 G4cout << "fpAuxiliaryPointVector "
119 << (void*) fpAuxiliaryPointVector;
120 G4cout << ": ";
121 if (fpAuxiliaryPointVector) {
122 G4cout << "size: " << fpAuxiliaryPointVector->size();
123 for (size_t i = 0; i < fpAuxiliaryPointVector->size(); ++i)
124 G4cout << "\n " << (*fpAuxiliaryPointVector)[i];
125 } else {
126 G4cout << "non-existent";
127 }
128 G4cout << G4endl;
129
130 static const G4Step* lastStep = 0;
131 if (aStep && aStep == lastStep) {
132 G4cout << "********* aStep is same as last" << G4endl;
133 }
134 lastStep = aStep;
135
136 static std::vector<G4ThreeVector>* lastAuxiliaryPointVector = 0;
137 if (fpAuxiliaryPointVector &&
138 fpAuxiliaryPointVector == lastAuxiliaryPointVector) {
139 G4cout << "********* fpAuxiliaryPointVector is same as last" << G4endl;
140 }
141 lastAuxiliaryPointVector = fpAuxiliaryPointVector;
142 */
143}
144
146(const G4RichTrajectoryPoint &right):
147 G4TrajectoryPoint(right),
148 fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
149 fTotEDep(right.fTotEDep),
150 fRemainingEnergy(right.fRemainingEnergy),
151 fpProcess(right.fpProcess),
152 fPreStepPointStatus(right.fPreStepPointStatus),
153 fPostStepPointStatus(right.fPostStepPointStatus),
154 fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
155 fPostStepPointGlobalTime(right.fPostStepPointGlobalTime),
156 fpPreStepPointVolume(right.fpPreStepPointVolume),
157 fpPostStepPointVolume(right.fpPostStepPointVolume),
158 fPreStepPointWeight(right.fPreStepPointWeight),
159 fPostStepPointWeight(right.fPostStepPointWeight)
160{}
161
163{
164 if(fpAuxiliaryPointVector) {
165 /*
166 G4cout << "Deleting fpAuxiliaryPointVector at "
167 << (void*) fpAuxiliaryPointVector
168 << G4endl;
169 */
170 delete fpAuxiliaryPointVector;
171 }
172}
173
174const std::map<G4String,G4AttDef>*
176{
177 G4bool isNew;
178 std::map<G4String,G4AttDef>* store
179 = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
180 if (isNew) {
181
182 // Copy base class att defs...
183 *store = *(G4TrajectoryPoint::GetAttDefs());
184
185 G4String ID;
186
187 ID = "Aux";
188 (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
189 "Physics","G4BestUnit","G4ThreeVector");
190 ID = "TED";
191 (*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
192 "Physics","G4BestUnit","G4double");
193 ID = "RE";
194 (*store)[ID] = G4AttDef(ID,"Remaining Energy",
195 "Physics","G4BestUnit","G4double");
196 ID = "PDS";
197 (*store)[ID] = G4AttDef(ID,"Process Defined Step",
198 "Physics","","G4String");
199 ID = "PTDS";
200 (*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
201 "Physics","","G4String");
202 ID = "PreStatus";
203 (*store)[ID] = G4AttDef(ID,"Pre-step-point status",
204 "Physics","","G4String");
205 ID = "PostStatus";
206 (*store)[ID] = G4AttDef(ID,"Post-step-point status",
207 "Physics","","G4String");
208 ID = "PreT";
209 (*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
210 "Physics","G4BestUnit","G4double");
211 ID = "PostT";
212 (*store)[ID] = G4AttDef(ID,"Post-step-point global time",
213 "Physics","G4BestUnit","G4double");
214 ID = "PreVPath";
215 (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
216 "Physics","","G4String");
217 ID = "PostVPath";
218 (*store)[ID] = G4AttDef(ID,"Post-step Volume Path",
219 "Physics","","G4String");
220 ID = "PreW";
221 (*store)[ID] = G4AttDef(ID,"Pre-step-point weight",
222 "Physics","","G4double");
223 ID = "PostW";
224 (*store)[ID] = G4AttDef(ID,"Post-step-point weight",
225 "Physics","","G4double");
226 }
227 return store;
228}
229
230static G4String Status(G4StepStatus stps)
231{
232 G4String status;
233 switch (stps) {
234 case fWorldBoundary: status = "fWorldBoundary"; break;
235 case fGeomBoundary: status = "fGeomBoundary"; break;
236 case fAtRestDoItProc: status = "fAtRestDoItProc"; break;
237 case fAlongStepDoItProc: status = "fAlongStepDoItProc"; break;
238 case fPostStepDoItProc: status = "fPostStepDoItProc"; break;
239 case fUserDefinedLimit: status = "fUserDefinedLimit"; break;
240 case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break;
241 case fUndefined: status = "fUndefined"; break;
242 default: status = "Not recognised"; break;
243 }
244 return status;
245}
246
247static G4String Path(const G4TouchableHandle& th)
248{
249 std::ostringstream oss;
250 G4int depth = th->GetHistoryDepth();
251 for (G4int i = depth; i >= 0; --i) {
252 oss << th->GetVolume(i)->GetName()
253 << ':' << th->GetCopyNumber(i);
254 if (i != 0) oss << '/';
255 }
256 return oss.str();
257}
258
259std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
260{
261 // Create base class att values...
262 std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
263
264 if (fpAuxiliaryPointVector) {
265 std::vector<G4ThreeVector>::iterator iAux;
266 for (iAux = fpAuxiliaryPointVector->begin();
267 iAux != fpAuxiliaryPointVector->end(); ++iAux) {
268 values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
269 }
270 }
271
272 values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
273
274 values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
275
276 if (fpProcess) {
277 values->push_back
278 (G4AttValue("PDS",fpProcess->GetProcessName(),""));
279 values->push_back
282 ""));
283 } else {
284 values->push_back(G4AttValue("PDS","None",""));
285 values->push_back(G4AttValue("PTDS","None",""));
286 }
287
288 values->push_back
289 (G4AttValue("PreStatus",Status(fPreStepPointStatus),""));
290
291 values->push_back
292 (G4AttValue("PostStatus",Status(fPostStepPointStatus),""));
293
294 values->push_back
295 (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
296
297 values->push_back
298 (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
299
300 if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume()) {
301 values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
302 } else {
303 values->push_back(G4AttValue("PreVPath","None",""));
304 }
305
306 if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume()) {
307 values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
308 } else {
309 values->push_back(G4AttValue("PostVPath","None",""));
310 }
311
312 {
313 std::ostringstream oss;
314 oss << fPreStepPointWeight;
315 values->push_back
316 (G4AttValue("PreW",oss.str(),""));
317 }
318
319 {
320 std::ostringstream oss;
321 oss << fPostStepPointWeight;
322 values->push_back
323 (G4AttValue("PostW",oss.str(),""));
324 }
325
326#ifdef G4ATTDEBUG
327 G4cout << G4AttCheck(values,GetAttDefs());
328#endif
329
330 return values;
331}
G4Allocator< G4RichTrajectoryPoint > aRichTrajectoryPointAllocator
G4StepStatus
Definition: G4StepStatus.hh:51
@ fGeomBoundary
Definition: G4StepStatus.hh:54
@ fWorldBoundary
Definition: G4StepStatus.hh:52
@ fUserDefinedLimit
Definition: G4StepStatus.hh:62
@ fUndefined
Definition: G4StepStatus.hh:66
@ fPostStepDoItProc
Definition: G4StepStatus.hh:60
@ fAtRestDoItProc
Definition: G4StepStatus.hh:56
@ fAlongStepDoItProc
Definition: G4StepStatus.hh:58
@ fExclusivelyForcedProc
Definition: G4StepStatus.hh:64
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4DLLIMPORT std::ostream G4cout
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual std::vector< G4AttValue > * CreateAttValues() const
G4StepStatus GetStepStatus() const
G4double GetGlobalTime() const
const G4VProcess * GetProcessDefinedStep() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetKineticEnergy() const
G4double GetWeight() const
Definition: G4Step.hh:78
G4Track * GetTrack() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
G4int GetCurrentStepNumber() const
G4double GetKineticEnergy() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual std::vector< G4AttValue > * CreateAttValues() const
const G4String & GetName() const
static const G4String & GetProcessTypeName(G4ProcessType)
Definition: G4VProcess.cc:150
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:385
const G4String & GetProcessName() const
Definition: G4VProcess.hh:379
G4int GetCopyNumber(G4int depth=0) const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
virtual G4int GetHistoryDepth() const
Definition: G4VTouchable.cc:79
std::map< G4String, G4AttDef > * GetInstance(G4String storeKey, G4bool &isNew)