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

Last change on this file since 1202 was 1196, checked in by garnier, 15 years ago

update CVS release candidate geant4.9.3.01

File size: 7.7 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.4 2009/11/12 09:09:56 allison Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
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
63G4Allocator<G4RichTrajectoryPoint> aRichTrajectoryPointAllocator;
64
65G4RichTrajectoryPoint::G4RichTrajectoryPoint():
66  fpAuxiliaryPointVector(0),
67  fTotEDep(0.),
68  fRemainingEnergy(0.),
69  fpProcess(0),
70  fPreStepPointGlobalTime(0),
71  fPostStepPointGlobalTime(0)
72{}
73
74G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack):
75  G4TrajectoryPoint(aTrack->GetPosition()),
76  fpAuxiliaryPointVector(0),
77  fTotEDep(0.),
78  fRemainingEnergy(aTrack->GetKineticEnergy()),
79  fpProcess(0),
80  fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
81  fPostStepPointGlobalTime(aTrack->GetGlobalTime())
82{}
83
84G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep):
85  G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
86  fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
87  fTotEDep(aStep->GetTotalEnergyDeposit())
88{
89  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
90  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
91  if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) {  // First step
92    fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
93  } else {
94    fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
95  }
96  fpProcess = postStepPoint->GetProcessDefinedStep();
97  fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
98  fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
99
100  /*
101  G4cout << "fpAuxiliaryPointVector "
102         << (void*) fpAuxiliaryPointVector;
103  G4cout << ": ";
104  if (fpAuxiliaryPointVector) {
105    G4cout << "size: " << fpAuxiliaryPointVector->size();
106    for (size_t i = 0; i < fpAuxiliaryPointVector->size(); ++i)
107      G4cout << "\n  " << (*fpAuxiliaryPointVector)[i];
108  } else {
109    G4cout << "non-existent";
110  }
111  G4cout << G4endl;
112
113  static const G4Step* lastStep = 0;
114  if (aStep && aStep == lastStep) {
115    G4cout << "********* aStep is same as last" << G4endl;
116  }
117  lastStep = aStep;
118
119  static std::vector<G4ThreeVector>*  lastAuxiliaryPointVector = 0;
120  if (fpAuxiliaryPointVector &&
121      fpAuxiliaryPointVector == lastAuxiliaryPointVector) {
122    G4cout << "********* fpAuxiliaryPointVector is same as last" << G4endl;
123  }
124  lastAuxiliaryPointVector = fpAuxiliaryPointVector;
125  */
126}
127
128G4RichTrajectoryPoint::G4RichTrajectoryPoint
129(const G4RichTrajectoryPoint &right):
130  G4TrajectoryPoint(right),
131  fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
132  fTotEDep(right.fTotEDep),
133  fRemainingEnergy(right.fRemainingEnergy),
134  fpProcess(right.fpProcess),
135  fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
136  fPostStepPointGlobalTime(right.fPostStepPointGlobalTime)
137{}
138
139G4RichTrajectoryPoint::~G4RichTrajectoryPoint()
140{
141  if(fpAuxiliaryPointVector) {
142    /*
143    G4cout << "Deleting fpAuxiliaryPointVector at "
144           << (void*) fpAuxiliaryPointVector
145           << G4endl;
146    */
147    delete fpAuxiliaryPointVector;
148  }
149}
150
151const std::map<G4String,G4AttDef>*
152G4RichTrajectoryPoint::GetAttDefs() const
153{
154  G4bool isNew;
155  std::map<G4String,G4AttDef>* store
156    = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
157  if (isNew) {
158
159    // Copy base class att defs...
160    *store = *(G4TrajectoryPoint::GetAttDefs());
161
162    G4String ID;
163
164    ID = "Aux";
165    (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
166                            "Physics","G4BestUnit","G4ThreeVector");
167    ID = "TED";
168    (*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
169                            "Physics","G4BestUnit","G4double");
170    ID = "RE";
171    (*store)[ID] = G4AttDef(ID,"Remaining Energy",
172                            "Physics","G4BestUnit","G4double");
173    ID = "PDS";
174    (*store)[ID] = G4AttDef(ID,"Process Defined Step",
175                            "Physics","","G4String");
176    ID = "PTDS";
177    (*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
178                            "Physics","","G4String");
179    ID = "PreT";
180    (*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
181                            "Physics","G4BestUnit","G4double");
182    ID = "PostT";
183    (*store)[ID] = G4AttDef(ID,"Post-step-point global time",
184                            "Physics","G4BestUnit","G4double");
185  }
186  return store;
187}
188
189std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
190{
191  // Create base class att values...
192  std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
193
194  if (fpAuxiliaryPointVector) {
195    std::vector<G4ThreeVector>::iterator iAux;
196    for (iAux = fpAuxiliaryPointVector->begin();
197         iAux != fpAuxiliaryPointVector->end(); ++iAux) {
198      values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
199    }
200  }
201
202  values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
203
204  values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
205
206  if (fpProcess) {
207    values->push_back
208      (G4AttValue("PDS",fpProcess->GetProcessName(),""));
209    values->push_back
210      (G4AttValue
211       ("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),
212        ""));
213  } else {
214    values->push_back
215      (G4AttValue("PDS","User Defined Limit in Current Volume",""));
216    values->push_back(G4AttValue("PTDS","User",""));
217  }
218
219  values->push_back
220    (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
221
222  values->push_back
223    (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
224
225#ifdef G4ATTDEBUG
226  G4cout << G4AttCheck(values,GetAttDefs());
227#endif
228
229  return values;
230}
Note: See TracBrowser for help on using the repository browser.