ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RichTrajectory.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RichTrajectory.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 // G4RichTrajectory.cc
31 //
32 // Contact:
33 // Questions and comments on G4Trajectory, on which this is based,
34 // should be sent to
35 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
36 // Makoto Asai (e-mail: asai@kekvax.kek.jp)
37 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
38 // and on the extended code to:
39 // John Allison (e-mail: John.Allison@manchester.ac.uk)
40 // Joseph Perl (e-mail: perl@slac.stanford.edu)
41 //
42 // ---------------------------------------------------------------
43 
44 #include "G4RichTrajectory.hh"
45 #include "G4RichTrajectoryPoint.hh"
46 #include "G4AttDefStore.hh"
47 #include "G4AttDef.hh"
48 #include "G4AttValue.hh"
49 #include "G4UIcommand.hh"
50 #include "G4UnitsTable.hh"
51 #include "G4VProcess.hh"
52 
53 //#define G4ATTDEBUG
54 #ifdef G4ATTDEBUG
55 #include "G4AttCheck.hh"
56 #endif
57 
58 #include <sstream>
59 
61 {
63  return _instance;
64 }
65 
67  fpRichPointsContainer(0),
68  fpCreatorProcess(0),
69  fCreatorModelID(0),
70  fpEndingProcess(0),
71  fFinalKineticEnergy(0.)
72 {
73 }
74 
76  G4Trajectory(aTrack) // Note: this initialises the base class data
77  // members and, unfortunately but never mind,
78  // creates a G4TrajectoryPoint in
79  // TrajectoryPointContainer that we cannot
80  // access because it's private. We store the
81  // same information (plus more) in a
82  // G4RichTrajectoryPoint in the
83  // RichTrajectoryPointsContainer
84 {
89  // On construction, set final values to initial values.
90  // Final values are updated at the addition of every step - see AppendStep.
95  // Insert the first rich trajectory point (see note above)...
97  fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
98 }
99 
101  G4Trajectory(right)
102 {
112  for(size_t i=0;i<right.fpRichPointsContainer->size();i++)
113  {
114  G4RichTrajectoryPoint* rightPoint =
116  fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
117  }
118 }
119 
121 {
122  if (fpRichPointsContainer) {
123  // fpRichPointsContainer->clearAndDestroy();
124  size_t i;
125  for(i=0;i<fpRichPointsContainer->size();i++){
126  delete (*fpRichPointsContainer)[i];
127  }
128  fpRichPointsContainer->clear();
129  delete fpRichPointsContainer;
130  }
131 }
132 
134 {
135  fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
136  // Except for first step, which is a sort of virtual step to start
137  // the track, compute the final values...
138  const G4Track* track = aStep->GetTrack();
139  const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
140  if (track->GetCurrentStepNumber() > 0) {
143  fpEndingProcess = postStepPoint->GetProcessDefinedStep();
145  aStep->GetPreStepPoint()->GetKineticEnergy() -
146  aStep->GetTotalEnergyDeposit();
147  }
148 }
149 
151 {
152  if(!secondTrajectory) return;
153 
154  G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
155  G4int ent = seco->GetPointEntries();
156  for(G4int i=1;i<ent;i++) {
157  // initial point of the second trajectory should not be merged
158  fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
159  // fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1));
160  }
161  delete (*seco->fpRichPointsContainer)[0];
162  seco->fpRichPointsContainer->clear();
163 }
164 
165 void G4RichTrajectory::ShowTrajectory(std::ostream& os) const
166 {
167  // Invoke the default implementation in G4VTrajectory...
169  // ... or override with your own code here.
170 }
171 
173 {
174  // Invoke the default implementation in G4VTrajectory...
176  // ... or override with your own code here.
177 }
178 
179 const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
180 {
181  G4bool isNew;
182  std::map<G4String,G4AttDef>* store
183  = G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
184  if (isNew) {
185 
186  // Get att defs from base class...
187  *store = *(G4Trajectory::GetAttDefs());
188 
189  G4String ID;
190 
191  ID = "IVPath";
192  (*store)[ID] = G4AttDef(ID,"Initial Volume Path",
193  "Physics","","G4String");
194 
195  ID = "INVPath";
196  (*store)[ID] = G4AttDef(ID,"Initial Next Volume Path",
197  "Physics","","G4String");
198 
199  ID = "CPN";
200  (*store)[ID] = G4AttDef(ID,"Creator Process Name",
201  "Physics","","G4String");
202 
203  ID = "CPTN";
204  (*store)[ID] = G4AttDef(ID,"Creator Process Type Name",
205  "Physics","","G4String");
206 
207  ID = "CMID";
208  (*store)[ID] = G4AttDef(ID,"Creator Model ID",
209  "Physics","","G4int");
210 
211  ID = "CMN";
212  (*store)[ID] = G4AttDef(ID,"Creator Model Name",
213  "Physics","","G4String");
214 
215  ID = "FVPath";
216  (*store)[ID] = G4AttDef(ID,"Final Volume Path",
217  "Physics","","G4String");
218 
219  ID = "FNVPath";
220  (*store)[ID] = G4AttDef(ID,"Final Next Volume Path",
221  "Physics","","G4String");
222 
223  ID = "EPN";
224  (*store)[ID] = G4AttDef(ID,"Ending Process Name",
225  "Physics","","G4String");
226 
227  ID = "EPTN";
228  (*store)[ID] = G4AttDef(ID,"Ending Process Type Name",
229  "Physics","","G4String");
230 
231  ID = "FKE";
232  (*store)[ID] = G4AttDef(ID,"Final kinetic energy",
233  "Physics","G4BestUnit","G4double");
234 
235  }
236 
237  return store;
238 }
239 
240 static G4String Path(const G4TouchableHandle& th)
241 {
242  std::ostringstream oss;
243  G4int depth = th->GetHistoryDepth();
244  for (G4int i = depth; i >= 0; --i) {
245  oss << th->GetVolume(i)->GetName()
246  << ':' << th->GetCopyNumber(i);
247  if (i != 0) oss << '/';
248  }
249  return oss.str();
250 }
251 
252 std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
253 {
254  // Create base class att values...
255  std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
256 
258  values->push_back(G4AttValue("IVPath",Path(fpInitialVolume),""));
259  } else {
260  values->push_back(G4AttValue("IVPath","None",""));
261  }
262 
264  values->push_back(G4AttValue("INVPath",Path(fpInitialNextVolume),""));
265  } else {
266  values->push_back(G4AttValue("INVPath","None",""));
267  }
268 
269  if (fpCreatorProcess) {
270  values->push_back
273  values->push_back
274  (G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),""));
275  values->push_back
277  const G4String& creatorModelName =
279  values->push_back(G4AttValue("CMN",creatorModelName,""));
280  } else {
281  values->push_back(G4AttValue("CPN","None",""));
282  values->push_back(G4AttValue("CPTN","None",""));
283  values->push_back(G4AttValue("CMID","None",""));
284  values->push_back(G4AttValue("CMN","None",""));
285  }
286 
288  values->push_back(G4AttValue("FVPath",Path(fpFinalVolume),""));
289  } else {
290  values->push_back(G4AttValue("FVPath","None",""));
291  }
292 
294  values->push_back(G4AttValue("FNVPath",Path(fpFinalNextVolume),""));
295  } else {
296  values->push_back(G4AttValue("FNVPath","None",""));
297  }
298 
299  if (fpEndingProcess) {
300  values->push_back(G4AttValue("EPN",fpEndingProcess->GetProcessName(),""));
302  values->push_back(G4AttValue("EPTN",G4VProcess::GetProcessTypeName(type),""));
303  } else {
304  values->push_back(G4AttValue("EPN","None",""));
305  values->push_back(G4AttValue("EPTN","None",""));
306  }
307 
308  values->push_back
309  (G4AttValue("FKE",G4BestUnit(fFinalKineticEnergy,"Energy"),""));
310 
311 #ifdef G4ATTDEBUG
312  G4cout << G4AttCheck(values,GetAttDefs());
313 #endif
314 
315  return values;
316 }