Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE04Trajectory.cc
Go to the documentation of this file.
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 //
28 //
29 // $Id: $
30 //
31 #include "RE04Trajectory.hh"
32 #include "RE04TrajectoryPoint.hh"
33 #include "G4ParticleTable.hh"
34 #include "G4AttDefStore.hh"
35 #include "G4AttDef.hh"
36 #include "G4AttValue.hh"
37 #include "G4UIcommand.hh"
38 #include "G4UnitsTable.hh"
39 
40 //#define G4ATTDEBUG
41 #ifdef G4ATTDEBUG
42 #include "G4AttCheck.hh"
43 #endif
44 
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 : fPositionRecord(0), fTrackID(0), fParentID(0),
50  fPDGEncoding( 0 ), fPDGCharge(0.0), fParticleName(""),
51  fInitialKineticEnergy( 0. ), fInitialMomentum( G4ThreeVector() )
52 {;}
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 {
57  G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
58  fParticleName = fpParticleDefinition->GetParticleName();
59  fPDGCharge = fpParticleDefinition->GetPDGCharge();
60  fPDGEncoding = fpParticleDefinition->GetPDGEncoding();
61  fTrackID = aTrack->GetTrackID();
62  fParentID = aTrack->GetParentID();
63  fInitialKineticEnergy = aTrack->GetKineticEnergy();
64  fInitialMomentum = aTrack->GetMomentum();
65  fPositionRecord = new TrajectoryPointContainer();
66  // Following is for the first trajectory point
67  fPositionRecord->push_back(new RE04TrajectoryPoint(
68  aTrack->GetPosition(),aTrack->GetMaterial()));
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 {
74  fParticleName = right.fParticleName;
75  fPDGCharge = right.fPDGCharge;
76  fPDGEncoding = right.fPDGEncoding;
77  fTrackID = right.fTrackID;
78  fParentID = right.fParentID;
79  fInitialKineticEnergy = right.fInitialKineticEnergy;
80  fInitialMomentum = right.fInitialMomentum;
81  fPositionRecord = new TrajectoryPointContainer();
82 
83  for(size_t i=0;i<right.fPositionRecord->size();i++)
84  {
85  RE04TrajectoryPoint* rightPoint
86  = (RE04TrajectoryPoint*)((*(right.fPositionRecord))[i]);
87  fPositionRecord->push_back(new RE04TrajectoryPoint(*rightPoint));
88  }
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 {
94  if (fPositionRecord) {
95  // fPositionRecord->clearAndDestroy();
96  size_t i;
97  for(i=0;i<fPositionRecord->size();i++){
98  delete (*fPositionRecord)[i];
99  }
100  fPositionRecord->clear();
101  delete fPositionRecord;
102  }
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 void RE04Trajectory::ShowTrajectory(std::ostream& os) const
107 {
108  // Invoke the default implementation in G4VTrajectory...
110  // ... or override with your own code here.
111 }
112 
113 /***
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 void RE04Trajectory::DrawTrajectory() const
116 {
117  // Invoke the default implementation in G4VTrajectory...
118  G4VTrajectory::DrawTrajectory();
119  // ... or override with your own code here.
120 }
121 ***/
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 {
126  // Invoke the default implementation in G4VTrajectory...
128  // ... or override with your own code here.
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 const std::map<G4String,G4AttDef>* RE04Trajectory::GetAttDefs() const
133 {
134  G4bool isNew;
135  std::map<G4String,G4AttDef>* store
136  = G4AttDefStore::GetInstance("RE04Trajectory",isNew);
137  if (isNew) {
138 
139  G4String id("ID");
140  (*store)[id] = G4AttDef(id,"Track ID","Physics","","G4int");
141 
142  G4String pid("PID");
143  (*store)[pid] = G4AttDef(pid,"Parent ID","Physics","","G4int");
144 
145  G4String pn("PN");
146  (*store)[pn] = G4AttDef(pn,"Particle Name","Physics","","G4String");
147 
148  G4String ch("Ch");
149  (*store)[ch] = G4AttDef(ch,"Charge","Physics","e+","G4double");
150 
151  G4String pdg("PDG");
152  (*store)[pdg] = G4AttDef(pdg,"PDG Encoding","Physics","","G4int");
153 
154  G4String ike("IKE");
155  (*store)[ike] =
156  G4AttDef(ike, "Initial kinetic energy",
157  "Physics","G4BestUnit","G4double");
158 
159  G4String iMom("IMom");
160  (*store)[iMom] = G4AttDef(iMom, "Initial momentum",
161  "Physics","G4BestUnit","G4ThreeVector");
162 
163  G4String iMag("IMag");
164  (*store)[iMag] =
165  G4AttDef(iMag, "Initial momentum magnitude",
166  "Physics","G4BestUnit","G4double");
167 
168  G4String ntp("NTP");
169  (*store)[ntp] = G4AttDef(ntp,"No. of points","Physics","","G4int");
170 
171  }
172  return store;
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 std::vector<G4AttValue>* RE04Trajectory::CreateAttValues() const
177 {
178  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
179 
180  values->push_back
181  (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
182 
183  values->push_back
184  (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
185 
186  values->push_back(G4AttValue("PN",fParticleName,""));
187 
188  values->push_back
189  (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),""));
190 
191  values->push_back
192  (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),""));
193 
194  values->push_back
195  (G4AttValue("IKE",G4BestUnit(fInitialKineticEnergy,"Energy"),""));
196 
197  values->push_back
198  (G4AttValue("IMom",G4BestUnit(fInitialMomentum,"Energy"),""));
199 
200  values->push_back
201  (G4AttValue("IMag",G4BestUnit(fInitialMomentum.mag(),"Energy"),""));
202 
203  values->push_back
205 
206 #ifdef G4ATTDEBUG
207  G4cout << G4AttCheck(values,GetAttDefs());
208 #endif
209 
210  return values;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
215 {
216  fPositionRecord->push_back( new RE04TrajectoryPoint(
217  aStep->GetPostStepPoint()->GetPosition(),
218  aStep->GetPreStepPoint()->GetMaterial() ));
219 }
220 
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
223 {
224  return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName));
225 }
226 
227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
229 {
230  if(!secondTrajectory) return;
231 
232  RE04Trajectory* seco = (RE04Trajectory*)secondTrajectory;
233  G4int ent = seco->GetPointEntries();
234  for(G4int i=1;i<ent;i++) // initial point of the second trajectory
235  // should not be merged
236  {
237  fPositionRecord->push_back((*(seco->fPositionRecord))[i]);
238  // fPositionRecord->push_back(seco->fPositionRecord->removeAt(1));
239  }
240  delete (*seco->fPositionRecord)[0];
241  seco->fPositionRecord->clear();
242 }
243 
244