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