ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Trajectory.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Trajectory.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 // G4Trajectory.cc
31 //
32 // Contact:
33 // Questions and comments to this code should be sent to
34 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
35 // Makoto Asai (e-mail: asai@kekvax.kek.jp)
36 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
37 //
38 // ---------------------------------------------------------------
39 
40 #include "G4Trajectory.hh"
41 #include "G4TrajectoryPoint.hh"
42 #include "G4ParticleTable.hh"
43 #include "G4AttDefStore.hh"
44 #include "G4AttDef.hh"
45 #include "G4AttValue.hh"
46 #include "G4UIcommand.hh"
47 #include "G4UnitsTable.hh"
48 
49 //#define G4ATTDEBUG
50 #ifdef G4ATTDEBUG
51 #include "G4AttCheck.hh"
52 #endif
53 
55 {
57  return _instance;
58 }
59 
61 : positionRecord(0), fTrackID(0), fParentID(0),
62  PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
63  initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
64 {;}
65 
67 {
68  G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
69  ParticleName = fpParticleDefinition->GetParticleName();
70  PDGCharge = fpParticleDefinition->GetPDGCharge();
71  PDGEncoding = fpParticleDefinition->GetPDGEncoding();
72  fTrackID = aTrack->GetTrackID();
73  fParentID = aTrack->GetParentID();
75  initialMomentum = aTrack->GetMomentum();
77  // Following is for the first trajectory point
78  positionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition()));
79 }
80 
82 {
83  ParticleName = right.ParticleName;
84  PDGCharge = right.PDGCharge;
85  PDGEncoding = right.PDGEncoding;
86  fTrackID = right.fTrackID;
87  fParentID = right.fParentID;
91 
92  for(size_t i=0;i<right.positionRecord->size();i++)
93  {
94  G4TrajectoryPoint* rightPoint = (G4TrajectoryPoint*)((*(right.positionRecord))[i]);
95  positionRecord->push_back(new G4TrajectoryPoint(*rightPoint));
96  }
97 }
98 
100 {
101  if (positionRecord) {
102  size_t i;
103  for(i=0;i<positionRecord->size();i++){
104  delete (*positionRecord)[i];
105  }
106  positionRecord->clear();
107  delete positionRecord;
108  }
109 }
110 
111 void G4Trajectory::ShowTrajectory(std::ostream& os) const
112 {
113  // Invoke the default implementation in G4VTrajectory...
115  // ... or override with your own code here.
116 }
117 
119 {
120  // Invoke the default implementation in G4VTrajectory...
122  // ... or override with your own code here.
123 }
124 
125 const std::map<G4String,G4AttDef>* G4Trajectory::GetAttDefs() const
126 {
127  G4bool isNew;
128  std::map<G4String,G4AttDef>* store
129  = G4AttDefStore::GetInstance("G4Trajectory",isNew);
130  if (isNew) {
131 
132  G4String ID("ID");
133  (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
134 
135  G4String PID("PID");
136  (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
137 
138  G4String PN("PN");
139  (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
140 
141  G4String Ch("Ch");
142  (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
143 
144  G4String PDG("PDG");
145  (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
146 
147  G4String IKE("IKE");
148  (*store)[IKE] =
149  G4AttDef(IKE, "Initial kinetic energy",
150  "Physics","G4BestUnit","G4double");
151 
152  G4String IMom("IMom");
153  (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
154  "Physics","G4BestUnit","G4ThreeVector");
155 
156  G4String IMag("IMag");
157  (*store)[IMag] =
158  G4AttDef(IMag, "Initial momentum magnitude",
159  "Physics","G4BestUnit","G4double");
160 
161  G4String NTP("NTP");
162  (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
163 
164  }
165  return store;
166 }
167 
168 std::vector<G4AttValue>* G4Trajectory::CreateAttValues() const
169 {
170  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
171 
172  values->push_back
174 
175  values->push_back
177 
178  values->push_back(G4AttValue("PN",ParticleName,""));
179 
180  values->push_back
182 
183  values->push_back
185 
186  values->push_back
187  (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
188 
189  values->push_back
190  (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
191 
192  values->push_back
193  (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
194 
195  values->push_back
197 
198 #ifdef G4ATTDEBUG
199  G4cout << G4AttCheck(values,GetAttDefs());
200 #endif
201 
202  return values;
203 }
204 
206 {
207  positionRecord->push_back( new G4TrajectoryPoint(aStep->GetPostStepPoint()->
208  GetPosition() ));
209 }
210 
212 {
213  return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
214 }
215 
217 {
218  if(!secondTrajectory) return;
219 
220  G4Trajectory* seco = (G4Trajectory*)secondTrajectory;
221  G4int ent = seco->GetPointEntries();
222  for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
223  {
224  positionRecord->push_back((*(seco->positionRecord))[i]);
225  }
226  delete (*seco->positionRecord)[0];
227  seco->positionRecord->clear();
228 }