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