Geant4 11.2.2
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// G4RichTrajectoryPoint class implementation
27//
28// Contact:
29// Questions and comments on G4TrajectoryPoint, on which this is based,
30// should be sent to
31// Katsuya Amako (e-mail: [email protected])
32// Makoto Asai (e-mail: [email protected])
33// Takashi Sasaki (e-mail: [email protected])
34// and on the extended code to:
35// John Allison (e-mail: [email protected])
36// Joseph Perl (e-mail: [email protected])
37// --------------------------------------------------------------------
38
40
41#include "G4AttDef.hh"
42#include "G4AttDefStore.hh"
43#include "G4AttValue.hh"
44#include "G4Step.hh"
45#include "G4Track.hh"
46#include "G4UnitsTable.hh"
47#include "G4VProcess.hh"
48
49// #define G4ATTDEBUG
50#ifdef G4ATTDEBUG
51# include "G4AttCheck.hh"
52#endif
53
54#include <sstream>
55
61
63
65 : G4TrajectoryPoint(aTrack->GetPosition()),
66 fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
67 fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
68 fpPreStepPointVolume(aTrack->GetTouchableHandle()),
69 fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
70 fPreStepPointWeight(aTrack->GetWeight()),
71 fPostStepPointWeight(aTrack->GetWeight())
72{}
73
75 : G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
76 fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
77 fTotEDep(aStep->GetTotalEnergyDeposit())
78{
79 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
80 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
81 if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) // First step
82 {
83 fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
84 }
85 else {
86 fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
87 }
88 fpProcess = postStepPoint->GetProcessDefinedStep();
89 fPreStepPointStatus = preStepPoint->GetStepStatus();
90 fPostStepPointStatus = postStepPoint->GetStepStatus();
91 fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
92 fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
93 fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
94 fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
95 fPreStepPointWeight = preStepPoint->GetWeight();
96 fPostStepPointWeight = postStepPoint->GetWeight();
97}
98
99// This is certainly wrong. the fpAuxiliaryPointVector is owned by this class,
100// and must be deep copied. Note also the copy-assignment operator is deleted.
101// However, G4RichTrajectory requires a copy constructor....
103
104G4RichTrajectoryPoint::~G4RichTrajectoryPoint() { delete fpAuxiliaryPointVector; }
105
106const std::map<G4String, G4AttDef>* G4RichTrajectoryPoint::GetAttDefs() const
107{
108 G4bool isNew;
109 std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectoryPoint", isNew);
110 if (isNew) {
111 // Copy base class att defs...
112 *store = *(G4TrajectoryPoint::GetAttDefs());
113
114 G4String ID;
115
116 ID = "Aux";
117 (*store)[ID] =
118 G4AttDef(ID, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
119 ID = "TED";
120 (*store)[ID] = G4AttDef(ID, "Total Energy Deposit", "Physics", "G4BestUnit", "G4double");
121 ID = "RE";
122 (*store)[ID] = G4AttDef(ID, "Remaining Energy", "Physics", "G4BestUnit", "G4double");
123 ID = "PDS";
124 (*store)[ID] = G4AttDef(ID, "Process Defined Step", "Physics", "", "G4String");
125 ID = "PTDS";
126 (*store)[ID] = G4AttDef(ID, "Process Type Defined Step", "Physics", "", "G4String");
127 ID = "PreStatus";
128 (*store)[ID] = G4AttDef(ID, "Pre-step-point status", "Physics", "", "G4String");
129 ID = "PostStatus";
130 (*store)[ID] = G4AttDef(ID, "Post-step-point status", "Physics", "", "G4String");
131 ID = "PreT";
132 (*store)[ID] = G4AttDef(ID, "Pre-step-point global time", "Physics", "G4BestUnit", "G4double");
133 ID = "PostT";
134 (*store)[ID] = G4AttDef(ID, "Post-step-point global time", "Physics", "G4BestUnit", "G4double");
135 ID = "PreVPath";
136 (*store)[ID] = G4AttDef(ID, "Pre-step Volume Path", "Physics", "", "G4String");
137 ID = "PostVPath";
138 (*store)[ID] = G4AttDef(ID, "Post-step Volume Path", "Physics", "", "G4String");
139 ID = "PreW";
140 (*store)[ID] = G4AttDef(ID, "Pre-step-point weight", "Physics", "", "G4double");
141 ID = "PostW";
142 (*store)[ID] = G4AttDef(ID, "Post-step-point weight", "Physics", "", "G4double");
143 }
144 return store;
145}
146
147static G4String Status(G4StepStatus stps)
148{
149 G4String status;
150 switch (stps) {
151 case fWorldBoundary:
152 status = "fWorldBoundary";
153 break;
154 case fGeomBoundary:
155 status = "fGeomBoundary";
156 break;
157 case fAtRestDoItProc:
158 status = "fAtRestDoItProc";
159 break;
161 status = "fAlongStepDoItProc";
162 break;
164 status = "fPostStepDoItProc";
165 break;
167 status = "fUserDefinedLimit";
168 break;
170 status = "fExclusivelyForcedProc";
171 break;
172 case fUndefined:
173 status = "fUndefined";
174 break;
175 default:
176 status = "Not recognised";
177 break;
178 }
179 return status;
180}
181
182static G4String Path(const G4TouchableHandle& th)
183{
184 std::ostringstream oss;
185 G4int depth = th->GetHistoryDepth();
186 for (G4int i = depth; i >= 0; --i) {
187 oss << th->GetVolume(i)->GetName() << ':' << th->GetCopyNumber(i);
188 if (i != 0) oss << '/';
189 }
190 return oss.str();
191}
192
193std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
194{
195 // Create base class att values...
196
197 std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
198
199 if (fpAuxiliaryPointVector != nullptr) {
200 for (const auto& iAux : *fpAuxiliaryPointVector) {
201 values->push_back(G4AttValue("Aux", G4BestUnit(iAux, "Length"), ""));
202 }
203 }
204
205 values->push_back(G4AttValue("TED", G4BestUnit(fTotEDep, "Energy"), ""));
206 values->push_back(G4AttValue("RE", G4BestUnit(fRemainingEnergy, "Energy"), ""));
207
208 if (fpProcess != nullptr) {
209 values->push_back(G4AttValue("PDS", fpProcess->GetProcessName(), ""));
210 values->push_back(
211 G4AttValue("PTDS", G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()), ""));
212 }
213 else {
214 values->push_back(G4AttValue("PDS", "None", ""));
215 values->push_back(G4AttValue("PTDS", "None", ""));
216 }
217
218 values->push_back(G4AttValue("PreStatus", Status(fPreStepPointStatus), ""));
219
220 values->push_back(G4AttValue("PostStatus", Status(fPostStepPointStatus), ""));
221
222 values->push_back(G4AttValue("PreT", G4BestUnit(fPreStepPointGlobalTime, "Time"), ""));
223
224 values->push_back(G4AttValue("PostT", G4BestUnit(fPostStepPointGlobalTime, "Time"), ""));
225
226 if (fpPreStepPointVolume && (fpPreStepPointVolume->GetVolume() != nullptr)) {
227 values->push_back(G4AttValue("PreVPath", Path(fpPreStepPointVolume), ""));
228 }
229 else {
230 values->push_back(G4AttValue("PreVPath", "None", ""));
231 }
232
233 if (fpPostStepPointVolume && (fpPostStepPointVolume->GetVolume() != nullptr)) {
234 values->push_back(G4AttValue("PostVPath", Path(fpPostStepPointVolume), ""));
235 }
236 else {
237 values->push_back(G4AttValue("PostVPath", "None", ""));
238 }
239
240 std::ostringstream oss1;
241 oss1 << fPreStepPointWeight;
242 values->push_back(G4AttValue("PreW", oss1.str(), ""));
243
244 std::ostringstream oss2;
245 oss2 << fPostStepPointWeight;
246 values->push_back(G4AttValue("PostW", oss2.str(), ""));
247
248#ifdef G4ATTDEBUG
249 G4cout << G4AttCheck(values, GetAttDefs());
250#endif
251
252 return values;
253}
G4Allocator< G4RichTrajectoryPoint > *& aRichTrajectoryPointAllocator()
G4StepStatus
@ fGeomBoundary
@ fWorldBoundary
@ fUserDefinedLimit
@ fUndefined
@ fPostStepDoItProc
@ fAtRestDoItProc
@ fAlongStepDoItProc
@ fExclusivelyForcedProc
#define G4BestUnit(a, b)
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
const std::map< G4String, G4AttDef > * GetAttDefs() const override
std::vector< G4AttValue > * CreateAttValues() const override
G4StepStatus GetStepStatus() const
G4double GetGlobalTime() const
const G4VProcess * GetProcessDefinedStep() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetWeight() const
G4Track * GetTrack() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
G4int GetCopyNumber(G4int depth=0) const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
virtual G4int GetHistoryDepth() const
G4int GetCurrentStepNumber() const
const std::map< G4String, G4AttDef > * GetAttDefs() const override
std::vector< G4AttValue > * CreateAttValues() const override
const G4String & GetName() const
static const G4String & GetProcessTypeName(G4ProcessType)
G4ProcessType GetProcessType() const
const G4String & GetProcessName() const
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
#define G4ThreadLocalStatic
Definition tls.hh:76