Loading...
Searching...
No Matches
RE01Trajectory.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//
26/// \file runAndEvent/RE01/src/RE01Trajectory.cc
27/// \brief Implementation of the RE01Trajectory class
28//
29//
30//
31
32#include "RE01Trajectory.hh"
33#include "G4ParticleTable.hh"
34#include "G4ParticleTypes.hh"
35#include "G4Polyline.hh"
36#include "G4Circle.hh"
37#include "G4Colour.hh"
38#include "G4AttDefStore.hh"
39#include "G4AttDef.hh"
40#include "G4AttValue.hh"
41#include "G4UIcommand.hh"
42#include "G4VisAttributes.hh"
43#include "G4VVisManager.hh"
44#include "G4UnitsTable.hh"
45#include "G4DynamicParticle.hh"
46#include "G4PrimaryParticle.hh"
48
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 fPositionRecord(0),fParticleDefinition(0)
55{
56 fParticleDefinition = aTrack->GetDefinition();
57 fParticleName = fParticleDefinition->GetParticleName();
58 fPDGCharge = fParticleDefinition->GetPDGCharge();
59 fPDGEncoding = fParticleDefinition->GetPDGEncoding();
60 if(fParticleName=="unknown")
61 {
62 G4PrimaryParticle*pp = aTrack->GetDynamicParticle()->GetPrimaryParticle();
63 if(pp)
64 {
65 if(pp->GetCharge()<DBL_MAX) fPDGCharge = pp->GetCharge();
66 fPDGEncoding = pp->GetPDGcode();
67 if(pp->GetG4code()!=0)
68 {
69 fParticleName += " : ";
70 fParticleName += pp->GetG4code()->GetParticleName();
71 }
72 }
73 }
74 fTrackID = aTrack->GetTrackID();
75 RE01TrackInformation* trackInfo
76 = (RE01TrackInformation*)(aTrack->GetUserInformation());
77 fTrackStatus = trackInfo->GetTrackingStatus();
78 if(fTrackStatus == 1)
79 { fParentID = aTrack->GetParentID(); }
80 else if(fTrackStatus == 2)
81 { fParentID = trackInfo->GetSourceTrackID(); }
82 else
83 { fParentID = -1; }
85 fPositionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition()));
86 fMomentum = aTrack->GetMomentum();
87 fVertexPosition = aTrack->GetPosition();
88 fGlobalTime = aTrack->GetGlobalTime();
89}
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93{
94 size_t i;
95 for(i=0;i<fPositionRecord->size();i++){
96 delete (*fPositionRecord)[i];
97 }
98 fPositionRecord->clear();
99
100 delete fPositionRecord;
101}
102
103//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104void RE01Trajectory::ShowTrajectory(std::ostream& os) const
105{
106 os << G4endl << "TrackID =" << fTrackID
107 << " : ParentID=" << fParentID << " : TrackStatus=" << fTrackStatus << G4endl;
108 os << "Particle name : " << fParticleName << " PDG code : " << fPDGEncoding
109 << " Charge : " << fPDGCharge << G4endl;
110 os << "Original momentum : " <<
111 G4BestUnit(fMomentum,"Energy") << G4endl;
112 os << "Vertex : " << G4BestUnit(fVertexPosition,"Length")
113 << " Global time : " << G4BestUnit(fGlobalTime,"Time") << G4endl;
114 os << " Current trajectory has " << fPositionRecord->size()
115 << " points." << G4endl;
116
117 for( size_t i=0 ; i < fPositionRecord->size() ; i++){
118 G4TrajectoryPoint* aTrajectoryPoint =
120 os << "Point[" << i << "]"
121 << " Position= " << aTrajectoryPoint->GetPosition() << G4endl;
122 }
123}
124
125//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127{
128
129 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
130 G4ThreeVector pos;
131
132 G4Polyline pPolyline;
133 for (size_t i = 0; i < fPositionRecord->size() ; i++) {
134 G4TrajectoryPoint* aTrajectoryPoint =
136 pos = aTrajectoryPoint->GetPosition();
137 pPolyline.push_back( pos );
138 }
139
140 G4Colour colour(0.2,0.2,0.2);
141 if(fParticleDefinition==G4Gamma::GammaDefinition())
142 colour = G4Colour(0.,0.,1.);
143 else if(fParticleDefinition==G4Electron::ElectronDefinition()
144 ||fParticleDefinition==G4Positron::PositronDefinition())
145 colour = G4Colour(1.,1.,0.);
146 else if(fParticleDefinition==G4MuonMinus::MuonMinusDefinition()
147 ||fParticleDefinition==G4MuonPlus::MuonPlusDefinition())
148 colour = G4Colour(0.,1.,0.);
149 else if(fParticleDefinition->GetParticleType()=="meson")
150 {
151 if(fPDGCharge!=0.)
152 colour = G4Colour(1.,0.,0.);
153 else
154 colour = G4Colour(0.5,0.,0.);
155 }
156 else if(fParticleDefinition->GetParticleType()=="baryon")
157 {
158 if(fPDGCharge!=0.)
159 colour = G4Colour(0.,1.,1.);
160 else
161 colour = G4Colour(0.,0.5,0.5);
162 }
163
164 G4VisAttributes attribs(colour);
165 pPolyline.SetVisAttributes(attribs);
166 if(pVVisManager) pVVisManager->Draw(pPolyline);
167}
168
169//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170const std::map<G4String,G4AttDef>* RE01Trajectory::GetAttDefs() const
171{
172 G4bool isNew;
173 std::map<G4String,G4AttDef>* store
174 = G4AttDefStore::GetInstance("RE01Trajectory",isNew);
175 if (isNew) {
176
177 G4String id("ID");
178 (*store)[id] = G4AttDef(id,"Track ID","Bookkeeping","","G4int");
179
180 G4String pid("PID");
181 (*store)[pid] = G4AttDef(pid,"Parent ID","Bookkeeping","","G4int");
182
183 G4String status("Status");
184 (*store)[status] = G4AttDef(status,"Track Status","Bookkeeping","","G4int");
185
186 G4String pn("PN");
187 (*store)[pn] = G4AttDef(pn,"Particle Name","Bookkeeping","","G4String");
188
189 G4String ch("Ch");
190 (*store)[ch] = G4AttDef(ch,"Charge","Physics","e+","G4double");
191
192 G4String pdg("PDG");
193 (*store)[pdg] = G4AttDef(pdg,"PDG Encoding","Bookkeeping","","G4int");
194
195 G4String imom("IMom");
196 (*store)[imom] = G4AttDef(imom, "Momentum of track at start of trajectory",
197 "Physics","G4BestUnit","G4ThreeVector");
198
199 G4String imag("IMag");
200 (*store)[imag] =
201 G4AttDef(imag, "Magnitude of momentum of track at start of trajectory",
202 "Physics","G4BestUnit","G4double");
203
204 G4String vtxPos("VtxPos");
205 (*store)[vtxPos] = G4AttDef(vtxPos, "Vertex position",
206 "Physics","G4BestUnit","G4ThreeVector");
207
208 G4String ntp("NTP");
209 (*store)[ntp] = G4AttDef(ntp,"No. of points","Bookkeeping","","G4int");
210
211 }
212 return store;
213}
214
215//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216std::vector<G4AttValue>* RE01Trajectory::CreateAttValues() const
217{
218 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
219
220 values->push_back
221 (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
222
223 values->push_back
224 (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
225
226 values->push_back
227 (G4AttValue("Status",G4UIcommand::ConvertToString(fTrackStatus),""));
228
229 values->push_back(G4AttValue("PN",fParticleName,""));
230
231 values->push_back
232 (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),""));
233
234 values->push_back
235 (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),""));
236
237 values->push_back
238 (G4AttValue("IMom",G4BestUnit(fMomentum,"Energy"),""));
239
240 values->push_back
241 (G4AttValue("IMag",G4BestUnit(fMomentum.mag(),"Energy"),""));
242
243 values->push_back
244 (G4AttValue("VtxPos",G4BestUnit(fVertexPosition,"Length"),""));
245
246 values->push_back
247 (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
248
249 return values;
250}
251
252//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254{
255 fPositionRecord->push_back(
256 new G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition() ));
257}
258
259//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
261{
262 if(!secondTrajectory) return;
263
264 RE01Trajectory* seco = (RE01Trajectory*)secondTrajectory;
265 G4int ent = seco->GetPointEntries();
266 //
267 // initial point of the second trajectory should not be merged
268 for(int i=1;i<ent;i++)
269 {
270 fPositionRecord->push_back((*(seco->fPositionRecord))[i]);
271 }
272 delete (*seco->fPositionRecord)[0];
273 seco->fPositionRecord->clear();
274
275}
Definition of the RE01TrackInformation class.
G4ThreadLocal G4Allocator< RE01Trajectory > * myTrajectoryAllocator
Definition of the RE01Trajectory class.
std::vector< G4VTrajectoryPoint * > RE01TrajectoryPointContainer
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
virtual ~RE01Trajectory()
G4ThreeVector fVertexPosition
RE01TrajectoryPointContainer * fPositionRecord
RE01Trajectory(const G4Track *aTrack)
G4ParticleDefinition * fParticleDefinition
virtual void ShowTrajectory(std::ostream &os=G4cout) const
G4ThreeVector fMomentum
virtual int GetPointEntries() const
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual void DrawTrajectory() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual void AppendStep(const G4Step *aStep)
G4String fParticleName

Applications | User Support | Publications | Collaboration