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: G4RichTrajectory.cc,v 1.7 2009/11/12 09:09:56 allison Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // --------------------------------------------------------------- |
---|
31 | // |
---|
32 | // G4RichTrajectory.cc |
---|
33 | // |
---|
34 | // Contact: |
---|
35 | // Questions and comments on G4Trajectory, on which this is based, |
---|
36 | // should be sent to |
---|
37 | // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) |
---|
38 | // Makoto Asai (e-mail: asai@kekvax.kek.jp) |
---|
39 | // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) |
---|
40 | // and on the extended code to: |
---|
41 | // John Allison (e-mail: John.Allison@manchester.ac.uk) |
---|
42 | // Joseph Perl (e-mail: perl@slac.stanford.edu) |
---|
43 | // |
---|
44 | // --------------------------------------------------------------- |
---|
45 | |
---|
46 | #include "G4RichTrajectory.hh" |
---|
47 | #include "G4RichTrajectoryPoint.hh" |
---|
48 | #include "G4AttDefStore.hh" |
---|
49 | #include "G4AttDef.hh" |
---|
50 | #include "G4AttValue.hh" |
---|
51 | #include "G4UnitsTable.hh" |
---|
52 | #include "G4VProcess.hh" |
---|
53 | |
---|
54 | //#define G4ATTDEBUG |
---|
55 | #ifdef G4ATTDEBUG |
---|
56 | #include "G4AttCheck.hh" |
---|
57 | #endif |
---|
58 | |
---|
59 | G4Allocator<G4RichTrajectory> aRichTrajectoryAllocator; |
---|
60 | |
---|
61 | G4RichTrajectory::G4RichTrajectory(): |
---|
62 | fpRichPointsContainer(0), |
---|
63 | fpInitialVolume(0), |
---|
64 | fpInitialNextVolume(0), |
---|
65 | fpCreatorProcess(0), |
---|
66 | fFinalKineticEnergy(0.) |
---|
67 | {} |
---|
68 | |
---|
69 | G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack): |
---|
70 | G4Trajectory(aTrack) // Note: this initialises the base class data |
---|
71 | // members and, unfortunately but never mind, |
---|
72 | // creates a G4TrajectoryPoint in |
---|
73 | // TrajectoryPointContainer that we cannot |
---|
74 | // access because it's private. We store the |
---|
75 | // same information (plus more) in a |
---|
76 | // G4RichTrajectoryPoint in the |
---|
77 | // RichTrajectoryPointsContainer |
---|
78 | { |
---|
79 | fpInitialVolume = aTrack->GetVolume(); |
---|
80 | fpInitialNextVolume = aTrack->GetNextVolume(); |
---|
81 | fpCreatorProcess = aTrack->GetCreatorProcess(); |
---|
82 | fpRichPointsContainer = new RichTrajectoryPointsContainer; |
---|
83 | // Insert the first rich trajectory point (see note above)... |
---|
84 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack)); |
---|
85 | // On construction, set final KE to initial KE. |
---|
86 | // Final KE is updated at the addition of every step - see AppendStep. |
---|
87 | fFinalKineticEnergy = aTrack->GetKineticEnergy(); |
---|
88 | } |
---|
89 | |
---|
90 | G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right): |
---|
91 | G4Trajectory(right) |
---|
92 | { |
---|
93 | fpInitialVolume = right.fpInitialVolume; |
---|
94 | fpInitialNextVolume = right.fpInitialNextVolume; |
---|
95 | fpCreatorProcess = right.fpCreatorProcess; |
---|
96 | fpRichPointsContainer = new RichTrajectoryPointsContainer; |
---|
97 | fFinalKineticEnergy = right.fFinalKineticEnergy; |
---|
98 | for(size_t i=0;i<right.fpRichPointsContainer->size();i++) |
---|
99 | { |
---|
100 | G4RichTrajectoryPoint* rightPoint = |
---|
101 | (G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]); |
---|
102 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint)); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | G4RichTrajectory::~G4RichTrajectory() |
---|
107 | { |
---|
108 | if (fpRichPointsContainer) { |
---|
109 | // fpRichPointsContainer->clearAndDestroy(); |
---|
110 | size_t i; |
---|
111 | for(i=0;i<fpRichPointsContainer->size();i++){ |
---|
112 | delete (*fpRichPointsContainer)[i]; |
---|
113 | } |
---|
114 | fpRichPointsContainer->clear(); |
---|
115 | delete fpRichPointsContainer; |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | void G4RichTrajectory::AppendStep(const G4Step* aStep) |
---|
120 | { |
---|
121 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep)); |
---|
122 | // Except for first step, which is a sort of virtual step to start |
---|
123 | // the track, compute the final energy. |
---|
124 | if (aStep->GetTrack()->GetCurrentStepNumber() > 0) { |
---|
125 | fFinalKineticEnergy = |
---|
126 | aStep->GetPreStepPoint()->GetKineticEnergy() - |
---|
127 | aStep->GetTotalEnergyDeposit(); |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) |
---|
132 | { |
---|
133 | if(!secondTrajectory) return; |
---|
134 | |
---|
135 | G4Trajectory::MergeTrajectory(secondTrajectory); |
---|
136 | |
---|
137 | G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory; |
---|
138 | G4int ent = seco->GetPointEntries(); |
---|
139 | for(G4int i=1;i<ent;i++) { |
---|
140 | // initial point of the second trajectory should not be merged |
---|
141 | fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]); |
---|
142 | // fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1)); |
---|
143 | } |
---|
144 | delete (*seco->fpRichPointsContainer)[0]; |
---|
145 | seco->fpRichPointsContainer->clear(); |
---|
146 | } |
---|
147 | |
---|
148 | const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const |
---|
149 | { |
---|
150 | G4bool isNew; |
---|
151 | std::map<G4String,G4AttDef>* store |
---|
152 | = G4AttDefStore::GetInstance("G4RichTrajectory",isNew); |
---|
153 | if (isNew) { |
---|
154 | |
---|
155 | // Get att defs from base class... |
---|
156 | *store = *(G4Trajectory::GetAttDefs()); |
---|
157 | |
---|
158 | G4String ID; |
---|
159 | |
---|
160 | ID = "IVN"; |
---|
161 | (*store)[ID] = G4AttDef(ID,"Initial Volume Name", |
---|
162 | "Physics","","G4String"); |
---|
163 | |
---|
164 | ID = "INVN"; |
---|
165 | (*store)[ID] = G4AttDef(ID,"Initial Next Volume Name", |
---|
166 | "Physics","","G4String"); |
---|
167 | |
---|
168 | ID = "CPN"; |
---|
169 | (*store)[ID] = G4AttDef(ID,"Creator Process Name", |
---|
170 | "Physics","","G4String"); |
---|
171 | |
---|
172 | ID = "CPTN"; |
---|
173 | (*store)[ID] = G4AttDef(ID,"Creator Process Type Name", |
---|
174 | "Physics","","G4String"); |
---|
175 | |
---|
176 | ID = "FKE"; |
---|
177 | (*store)[ID] = G4AttDef(ID,"Final kinetic energy", |
---|
178 | "Physics","G4BestUnit","G4double"); |
---|
179 | |
---|
180 | } |
---|
181 | |
---|
182 | return store; |
---|
183 | } |
---|
184 | |
---|
185 | std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const |
---|
186 | { |
---|
187 | // Create base class att values... |
---|
188 | std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues(); |
---|
189 | |
---|
190 | values->push_back(G4AttValue("IVN",fpInitialVolume->GetName(),"")); |
---|
191 | |
---|
192 | values->push_back(G4AttValue("INVN",fpInitialNextVolume->GetName(),"")); |
---|
193 | |
---|
194 | if (fpCreatorProcess) { |
---|
195 | values->push_back(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),"")); |
---|
196 | G4ProcessType type = fpCreatorProcess->GetProcessType(); |
---|
197 | values->push_back(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),"")); |
---|
198 | } else { |
---|
199 | values->push_back(G4AttValue("CPN","User Defined","")); |
---|
200 | values->push_back(G4AttValue("CPTN","User","")); |
---|
201 | } |
---|
202 | |
---|
203 | values->push_back |
---|
204 | (G4AttValue("FKE",G4BestUnit(fFinalKineticEnergy,"Energy"),"")); |
---|
205 | |
---|
206 | #ifdef G4ATTDEBUG |
---|
207 | G4cout << G4AttCheck(values,GetAttDefs()); |
---|
208 | #endif |
---|
209 | |
---|
210 | return values; |
---|
211 | } |
---|