source: trunk/source/tracking/src/G4RichTrajectoryPoint.cc@ 1238

Last change on this file since 1238 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 8.9 KB
Line 
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: G4RichTrajectoryPoint.cc,v 1.5 2009/11/24 10:04:14 perl Exp $
28// GEANT4 tag $Name: geant4-09-03 $
29//
30//
31// ---------------------------------------------------------------
32//
33// G4RichTrajectoryPoint.cc
34//
35// Contact:
36// Questions and comments on G4TrajectoryPoint, on which this is based,
37// should be sent to
38// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
39// Makoto Asai (e-mail: asai@kekvax.kek.jp)
40// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
41// and on the extended code to:
42// John Allison (e-mail: John.Allison@manchester.ac.uk)
43// Joseph Perl (e-mail: perl@slac.stanford.edu)
44//
45// ---------------------------------------------------------------
46
47#include "G4RichTrajectoryPoint.hh"
48
49#include "G4Track.hh"
50#include "G4Step.hh"
51#include "G4VProcess.hh"
52
53#include "G4AttDefStore.hh"
54#include "G4AttDef.hh"
55#include "G4AttValue.hh"
56#include "G4UnitsTable.hh"
57
58//#define G4ATTDEBUG
59#ifdef G4ATTDEBUG
60#include "G4AttCheck.hh"
61#endif
62
63#include <sstream>
64
65G4Allocator<G4RichTrajectoryPoint> aRichTrajectoryPointAllocator;
66
67G4RichTrajectoryPoint::G4RichTrajectoryPoint():
68 fpAuxiliaryPointVector(0),
69 fTotEDep(0.),
70 fRemainingEnergy(0.),
71 fpProcess(0),
72 fPreStepPointGlobalTime(0),
73 fPostStepPointGlobalTime(0)
74{}
75
76G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack):
77 G4TrajectoryPoint(aTrack->GetPosition()),
78 fpAuxiliaryPointVector(0),
79 fTotEDep(0.),
80 fRemainingEnergy(aTrack->GetKineticEnergy()),
81 fpProcess(0),
82 fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
83 fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
84 fpPreStepPointVolume(aTrack->GetTouchableHandle()),
85 fpPostStepPointVolume(aTrack->GetNextTouchableHandle())
86{}
87
88G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep):
89 G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
90 fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
91 fTotEDep(aStep->GetTotalEnergyDeposit())
92{
93 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
94 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
95 if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) { // First step
96 fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
97 } else {
98 fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
99 }
100 fpProcess = postStepPoint->GetProcessDefinedStep();
101 fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
102 fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
103 fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
104 fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
105
106 /*
107 G4cout << "fpAuxiliaryPointVector "
108 << (void*) fpAuxiliaryPointVector;
109 G4cout << ": ";
110 if (fpAuxiliaryPointVector) {
111 G4cout << "size: " << fpAuxiliaryPointVector->size();
112 for (size_t i = 0; i < fpAuxiliaryPointVector->size(); ++i)
113 G4cout << "\n " << (*fpAuxiliaryPointVector)[i];
114 } else {
115 G4cout << "non-existent";
116 }
117 G4cout << G4endl;
118
119 static const G4Step* lastStep = 0;
120 if (aStep && aStep == lastStep) {
121 G4cout << "********* aStep is same as last" << G4endl;
122 }
123 lastStep = aStep;
124
125 static std::vector<G4ThreeVector>* lastAuxiliaryPointVector = 0;
126 if (fpAuxiliaryPointVector &&
127 fpAuxiliaryPointVector == lastAuxiliaryPointVector) {
128 G4cout << "********* fpAuxiliaryPointVector is same as last" << G4endl;
129 }
130 lastAuxiliaryPointVector = fpAuxiliaryPointVector;
131 */
132}
133
134G4RichTrajectoryPoint::G4RichTrajectoryPoint
135(const G4RichTrajectoryPoint &right):
136 G4TrajectoryPoint(right),
137 fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
138 fTotEDep(right.fTotEDep),
139 fRemainingEnergy(right.fRemainingEnergy),
140 fpProcess(right.fpProcess),
141 fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
142 fPostStepPointGlobalTime(right.fPostStepPointGlobalTime)
143{}
144
145G4RichTrajectoryPoint::~G4RichTrajectoryPoint()
146{
147 if(fpAuxiliaryPointVector) {
148 /*
149 G4cout << "Deleting fpAuxiliaryPointVector at "
150 << (void*) fpAuxiliaryPointVector
151 << G4endl;
152 */
153 delete fpAuxiliaryPointVector;
154 }
155}
156
157const std::map<G4String,G4AttDef>*
158G4RichTrajectoryPoint::GetAttDefs() const
159{
160 G4bool isNew;
161 std::map<G4String,G4AttDef>* store
162 = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
163 if (isNew) {
164
165 // Copy base class att defs...
166 *store = *(G4TrajectoryPoint::GetAttDefs());
167
168 G4String ID;
169
170 ID = "Aux";
171 (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
172 "Physics","G4BestUnit","G4ThreeVector");
173 ID = "TED";
174 (*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
175 "Physics","G4BestUnit","G4double");
176 ID = "RE";
177 (*store)[ID] = G4AttDef(ID,"Remaining Energy",
178 "Physics","G4BestUnit","G4double");
179 ID = "PDS";
180 (*store)[ID] = G4AttDef(ID,"Process Defined Step",
181 "Physics","","G4String");
182 ID = "PTDS";
183 (*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
184 "Physics","","G4String");
185 ID = "PreT";
186 (*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
187 "Physics","G4BestUnit","G4double");
188 ID = "PostT";
189 (*store)[ID] = G4AttDef(ID,"Post-step-point global time",
190 "Physics","G4BestUnit","G4double");
191 ID = "PreVPath";
192 (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
193 "Physics","","G4String");
194 ID = "PostVPath";
195 (*store)[ID] = G4AttDef(ID,"Post-step Volume Path",
196 "Physics","","G4String");
197 }
198 return store;
199}
200
201static G4String Path(const G4TouchableHandle& th)
202{
203 std::ostringstream oss;
204 G4int depth = th->GetHistoryDepth();
205 for (G4int i = depth; i >= 0; --i) {
206 oss << th->GetVolume(i)->GetName()
207 << ':' << th->GetCopyNumber(i);
208 if (i != 0) oss << '/';
209 }
210 return oss.str();
211}
212
213std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
214{
215 // Create base class att values...
216 std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
217
218 if (fpAuxiliaryPointVector) {
219 std::vector<G4ThreeVector>::iterator iAux;
220 for (iAux = fpAuxiliaryPointVector->begin();
221 iAux != fpAuxiliaryPointVector->end(); ++iAux) {
222 values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
223 }
224 }
225
226 values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
227
228 values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
229
230 if (fpProcess) {
231 values->push_back
232 (G4AttValue("PDS",fpProcess->GetProcessName(),""));
233 values->push_back
234 (G4AttValue
235 ("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),
236 ""));
237 } else {
238 values->push_back
239 (G4AttValue("PDS","User Defined Limit in Current Volume",""));
240 values->push_back(G4AttValue("PTDS","User",""));
241 }
242
243 values->push_back
244 (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
245
246 values->push_back
247 (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
248
249 if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume()) {
250 values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
251 } else {
252 values->push_back(G4AttValue("PreVPath","None",""));
253 }
254
255 if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume()) {
256 values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
257 } else {
258 values->push_back(G4AttValue("PostVPath","None",""));
259 }
260
261#ifdef G4ATTDEBUG
262 G4cout << G4AttCheck(values,GetAttDefs());
263#endif
264
265 return values;
266}
Note: See TracBrowser for help on using the repository browser.