ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RichTrajectoryPoint.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RichTrajectoryPoint.cc
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 //
28 //
29 // ---------------------------------------------------------------
30 //
31 // G4RichTrajectoryPoint.cc
32 //
33 // Contact:
34 // Questions and comments on G4TrajectoryPoint, on which this is based,
35 // should be sent to
36 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
37 // Makoto Asai (e-mail: asai@kekvax.kek.jp)
38 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
39 // and on the extended code to:
40 // John Allison (e-mail: John.Allison@manchester.ac.uk)
41 // Joseph Perl (e-mail: perl@slac.stanford.edu)
42 //
43 // ---------------------------------------------------------------
44 
45 #include "G4RichTrajectoryPoint.hh"
46 
47 #include "G4Track.hh"
48 #include "G4Step.hh"
49 #include "G4VProcess.hh"
50 
51 #include "G4AttDefStore.hh"
52 #include "G4AttDef.hh"
53 #include "G4AttValue.hh"
54 #include "G4UnitsTable.hh"
55 
56 //#define G4ATTDEBUG
57 #ifdef G4ATTDEBUG
58 #include "G4AttCheck.hh"
59 #endif
60 
61 #include <sstream>
62 
64 {
66  return _instance;
67 }
68 
70  fpAuxiliaryPointVector(0),
71  fTotEDep(0.),
72  fRemainingEnergy(0.),
73  fpProcess(0),
74  fPreStepPointStatus(fUndefined),
75  fPostStepPointStatus(fUndefined),
76  fPreStepPointGlobalTime(0),
77  fPostStepPointGlobalTime(0),
78  fPreStepPointWeight(1.),
79  fPostStepPointWeight(1.)
80 {}
81 
83  G4TrajectoryPoint(aTrack->GetPosition()),
84  fpAuxiliaryPointVector(0),
85  fTotEDep(0.),
86  fRemainingEnergy(aTrack->GetKineticEnergy()),
87  fpProcess(0),
88  fPreStepPointStatus(fUndefined),
89  fPostStepPointStatus(fUndefined),
90  fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
91  fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
92  fpPreStepPointVolume(aTrack->GetTouchableHandle()),
93  fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
94  fPreStepPointWeight(aTrack->GetWeight()),
95  fPostStepPointWeight(aTrack->GetWeight())
96 {}
97 
99  G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
100  fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
101  fTotEDep(aStep->GetTotalEnergyDeposit())
102 {
103  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
104  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
105  if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) { // First step
107  } else {
108  fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
109  }
110  fpProcess = postStepPoint->GetProcessDefinedStep();
111  fPreStepPointStatus = preStepPoint->GetStepStatus();
112  fPostStepPointStatus = postStepPoint->GetStepStatus();
113  fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
114  fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
115  fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
116  fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
117  fPreStepPointWeight = preStepPoint->GetWeight();
118  fPostStepPointWeight = postStepPoint->GetWeight();
119 }
120 
123  G4TrajectoryPoint(right),
124  fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
125  fTotEDep(right.fTotEDep),
126  fRemainingEnergy(right.fRemainingEnergy),
127  fpProcess(right.fpProcess),
128  fPreStepPointStatus(right.fPreStepPointStatus),
129  fPostStepPointStatus(right.fPostStepPointStatus),
130  fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
131  fPostStepPointGlobalTime(right.fPostStepPointGlobalTime),
132  fpPreStepPointVolume(right.fpPreStepPointVolume),
133  fpPostStepPointVolume(right.fpPostStepPointVolume),
134  fPreStepPointWeight(right.fPreStepPointWeight),
135  fPostStepPointWeight(right.fPostStepPointWeight)
136 {}
137 
139 {
141  /*
142  G4cout << "Deleting fpAuxiliaryPointVector at "
143  << (void*) fpAuxiliaryPointVector
144  << G4endl;
145  */
146  delete fpAuxiliaryPointVector;
147  }
148 }
149 
150 const std::map<G4String,G4AttDef>*
152 {
153  G4bool isNew;
154  std::map<G4String,G4AttDef>* store
155  = G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
156  if (isNew) {
157 
158  // Copy base class att defs...
159  *store = *(G4TrajectoryPoint::GetAttDefs());
160 
161  G4String ID;
162 
163  ID = "Aux";
164  (*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
165  "Physics","G4BestUnit","G4ThreeVector");
166  ID = "TED";
167  (*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
168  "Physics","G4BestUnit","G4double");
169  ID = "RE";
170  (*store)[ID] = G4AttDef(ID,"Remaining Energy",
171  "Physics","G4BestUnit","G4double");
172  ID = "PDS";
173  (*store)[ID] = G4AttDef(ID,"Process Defined Step",
174  "Physics","","G4String");
175  ID = "PTDS";
176  (*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
177  "Physics","","G4String");
178  ID = "PreStatus";
179  (*store)[ID] = G4AttDef(ID,"Pre-step-point status",
180  "Physics","","G4String");
181  ID = "PostStatus";
182  (*store)[ID] = G4AttDef(ID,"Post-step-point status",
183  "Physics","","G4String");
184  ID = "PreT";
185  (*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
186  "Physics","G4BestUnit","G4double");
187  ID = "PostT";
188  (*store)[ID] = G4AttDef(ID,"Post-step-point global time",
189  "Physics","G4BestUnit","G4double");
190  ID = "PreVPath";
191  (*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
192  "Physics","","G4String");
193  ID = "PostVPath";
194  (*store)[ID] = G4AttDef(ID,"Post-step Volume Path",
195  "Physics","","G4String");
196  ID = "PreW";
197  (*store)[ID] = G4AttDef(ID,"Pre-step-point weight",
198  "Physics","","G4double");
199  ID = "PostW";
200  (*store)[ID] = G4AttDef(ID,"Post-step-point weight",
201  "Physics","","G4double");
202  }
203  return store;
204 }
205 
207 {
208  G4String status;
209  switch (stps) {
210  case fWorldBoundary: status = "fWorldBoundary"; break;
211  case fGeomBoundary: status = "fGeomBoundary"; break;
212  case fAtRestDoItProc: status = "fAtRestDoItProc"; break;
213  case fAlongStepDoItProc: status = "fAlongStepDoItProc"; break;
214  case fPostStepDoItProc: status = "fPostStepDoItProc"; break;
215  case fUserDefinedLimit: status = "fUserDefinedLimit"; break;
216  case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break;
217  case fUndefined: status = "fUndefined"; break;
218  default: status = "Not recognised"; break;
219  }
220  return status;
221 }
222 
223 static G4String Path(const G4TouchableHandle& th)
224 {
225  std::ostringstream oss;
226  G4int depth = th->GetHistoryDepth();
227  for (G4int i = depth; i >= 0; --i) {
228  oss << th->GetVolume(i)->GetName()
229  << ':' << th->GetCopyNumber(i);
230  if (i != 0) oss << '/';
231  }
232  return oss.str();
233 }
234 
235 std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
236 {
237  // Create base class att values...
238  std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
239 
241  std::vector<G4ThreeVector>::iterator iAux;
242  for (iAux = fpAuxiliaryPointVector->begin();
243  iAux != fpAuxiliaryPointVector->end(); ++iAux) {
244  values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
245  }
246  }
247 
248  values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
249 
250  values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
251 
252  if (fpProcess) {
253  values->push_back
254  (G4AttValue("PDS",fpProcess->GetProcessName(),""));
255  values->push_back
256  (G4AttValue
258  ""));
259  } else {
260  values->push_back(G4AttValue("PDS","None",""));
261  values->push_back(G4AttValue("PTDS","None",""));
262  }
263 
264  values->push_back
265  (G4AttValue("PreStatus",Status(fPreStepPointStatus),""));
266 
267  values->push_back
268  (G4AttValue("PostStatus",Status(fPostStepPointStatus),""));
269 
270  values->push_back
271  (G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
272 
273  values->push_back
274  (G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
275 
277  values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
278  } else {
279  values->push_back(G4AttValue("PreVPath","None",""));
280  }
281 
283  values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
284  } else {
285  values->push_back(G4AttValue("PostVPath","None",""));
286  }
287 
288  {
289  std::ostringstream oss;
290  oss << fPreStepPointWeight;
291  values->push_back
292  (G4AttValue("PreW",oss.str(),""));
293  }
294 
295  {
296  std::ostringstream oss;
297  oss << fPostStepPointWeight;
298  values->push_back
299  (G4AttValue("PostW",oss.str(),""));
300  }
301 
302 #ifdef G4ATTDEBUG
303  G4cout << G4AttCheck(values,GetAttDefs());
304 #endif
305 
306  return values;
307 }