Geant4  10.02.p01
WLSTrajectory.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 // $Id: WLSTrajectory.cc 90240 2015-05-21 09:08:13Z gcosmo $
27 //
30 //
31 //
32 #include "G4AttDef.hh"
33 #include "G4AttValue.hh"
34 #include "G4AttDefStore.hh"
35 
36 #include "G4UIcommand.hh"
37 #include "G4UnitsTable.hh"
38 
39 #include "WLSTrajectory.hh"
40 #include "WLSTrajectoryPoint.hh"
41 #include "G4ParticleTable.hh"
42 #include "G4ParticleTypes.hh"
43 
44 #include "G4Polyline.hh"
45 #include "G4Colour.hh"
46 #include "G4VisAttributes.hh"
47 #include "G4VVisManager.hh"
48 #include "G4Polymarker.hh"
49 
50 //#define G4ATTDEBUG
51 #ifdef G4ATTDEBUG
52 #include "G4AttCheck.hh"
53 #endif
54 
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60  : fpPointsContainer(0), fTrackID(0), fParentID(0),
61  fPDGCharge(0.0), fPDGEncoding(0), fParticleName(""),
62  fInitialMomentum(G4ThreeVector())
63 {
64  fParticleDefinition = NULL;
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
75  fTrackID = aTrack->GetTrackID();
76  fParentID = aTrack->GetParentID();
77  fInitialMomentum = aTrack->GetMomentum();
79  // Following is for the first trajectory point
80  fpPointsContainer->push_back(new WLSTrajectoryPoint(aTrack));
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
89  fPDGCharge = right.fPDGCharge;
90  fPDGEncoding = right.fPDGEncoding;
91  fTrackID = right.fTrackID;
92  fParentID = right.fParentID;
95 
96  for(size_t i=0;i<right.fpPointsContainer->size();++i) {
97  WLSTrajectoryPoint* rightPoint
98  = (WLSTrajectoryPoint*)((*(right.fpPointsContainer))[i]);
99  fpPointsContainer->push_back(new WLSTrajectoryPoint(*rightPoint));
100  }
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
106 {
107  for(size_t i=0;i<fpPointsContainer->size();++i){
108  delete (*fpPointsContainer)[i];
109  }
110  fpPointsContainer->clear();
111 
112  delete fpPointsContainer;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
117 void WLSTrajectory::ShowTrajectory(std::ostream& os) const
118 {
119  // Invoke the default implementation in G4VTrajectory...
121  // ... or override with your own code here.
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 
127 {
128  fpPointsContainer->push_back(new WLSTrajectoryPoint(aStep));
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 
134 {
135  return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName));
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  if(!secondTrajectory) return;
143 
144  WLSTrajectory* second = (WLSTrajectory*)secondTrajectory;
145  G4int ent = second->GetPointEntries();
146  // initial point of the second trajectory should not be merged
147  for(G4int i=1; i<ent; ++i) {
148  fpPointsContainer->push_back((*(second->fpPointsContainer))[i]);
149  }
150  delete (*second->fpPointsContainer)[0];
151  second->fpPointsContainer->clear();
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 
156 const std::map<G4String,G4AttDef>* WLSTrajectory::GetAttDefs() const
157 {
158  G4bool isNew;
159  std::map<G4String,G4AttDef>* store
160  = G4AttDefStore::GetInstance("Trajectory",isNew);
161 
162  if (isNew) {
163 
164  G4String ID("ID");
165  (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int");
166 
167  G4String PID("PID");
168  (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int");
169 
170  G4String PN("PN");
171  (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
172 
173  G4String Ch("Ch");
174  (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
175 
176  G4String PDG("PDG");
177  (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
178 
179  G4String IMom("IMom");
180  (*store)[IMom] = G4AttDef(IMom,
181  "Momentum of track at start of trajectory",
182  "Physics","G4BestUnit","G4ThreeVector");
183 
184  G4String IMag("IMag");
185  (*store)[IMag] = G4AttDef(IMag,
186  "Magnitude of momentum of track at start of trajectory",
187  "Physics","G4BestUnit","G4double");
188 
189  G4String NTP("NTP");
190  (*store)[NTP] = G4AttDef(NTP,"No. of points","Bookkeeping","","G4int");
191 
192  }
193  return store;
194 }
195 
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197 
198 std::vector<G4AttValue>* WLSTrajectory::CreateAttValues() const
199 {
200  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
201 
202  values->push_back
204 
205  values->push_back
207 
208  values->push_back(G4AttValue("PN",fParticleName,""));
209 
210  values->push_back
212 
213  values->push_back
215 
216  values->push_back
217  (G4AttValue("IMom",G4BestUnit(fInitialMomentum,"Energy"),""));
218 
219  values->push_back
220  (G4AttValue("IMag",G4BestUnit(fInitialMomentum.mag(),"Energy"),""));
221 
222  values->push_back
224 
225 #ifdef G4ATTDEBUG
226  G4cout << G4AttCheck(values,GetAttDefs());
227 #endif
228  return values;
229 }
G4ParticleDefinition * GetDefinition() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4ThreadLocal G4Allocator< WLSTrajectory > * WLSTrajectoryAllocator
G4int GetParentID() const
virtual void AppendStep(const G4Step *aStep)
CLHEP::Hep3Vector G4ThreeVector
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:371
Definition of the WLSTrajectoryPoint class.
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4String fParticleName
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4ParticleDefinition * GetParticleDefinition()
const G4String & GetParticleName() const
virtual int GetPointEntries() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
static const double second
Definition: G4SIunits.hh:156
virtual std::vector< G4AttValue > * CreateAttValues() const
Definition: G4Step.hh:76
G4int GetTrackID() const
virtual void ShowTrajectory(std::ostream &os=G4cout) const
Definition of the WLSTrajectory class.
G4ThreeVector GetMomentum() const
WLSTrajectoryPointContainer * fpPointsContainer
static G4ParticleTable * GetParticleTable()
G4ParticleDefinition * fParticleDefinition
std::vector< G4VTrajectoryPoint * > WLSTrajectoryPointContainer
G4double fPDGCharge
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
virtual void ShowTrajectory(std::ostream &os=G4cout) const
virtual ~WLSTrajectory()
G4double GetPDGCharge() const
G4ThreeVector fInitialMomentum