EDepSimTrajectoryPoint.cc
Go to the documentation of this file.
3 
4 #include <G4Track.hh>
5 #include <G4Step.hh>
6 #include <G4VProcess.hh>
7 #include <G4StepStatus.hh>
8 #include <G4ProcessType.hh>
9 
10 #include <G4AttDefStore.hh>
11 #include <G4AttDef.hh>
12 #include <G4AttValue.hh>
13 #include <G4UnitsTable.hh>
14 
15 #include <TGeoManager.h>
16 
17 #include <EDepSimLog.hh>
18 
19 G4Allocator<EDepSim::TrajectoryPoint> aTrajPointAllocator;
20 
22  : fTime(0.), fMomentum(0.,0.,0.),
23  fStepStatus(fUndefined),
24  fProcessType(fNotDefined), fProcessSubType(0),
25  fProcessName("NotDefined"), fPhysVolName("OutofWorld"),
26  fPrevPosition(0,0,0) { }
27 
29  : G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()) {
30  fTime = aStep->GetPostStepPoint()->GetGlobalTime();
31  fMomentum = aStep->GetPostStepPoint()->GetMomentum();
32  fStepStatus = aStep->GetPostStepPoint()->GetStepStatus();
33  if (aStep->GetPostStepPoint()->GetPhysicalVolume()) {
35  = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
36  }
37  else {
38  fPhysVolName == "OutOfWorld";
39  }
40  fPrevPosition = aStep->GetPreStepPoint()->GetPosition();
41  // Check if the G4VProcess for the defining process is available. It
42  // isn't available for steps defined by the user, step limits, or some
43  // other "bookkeeping" pseudo interactions.
44  if (aStep->GetPostStepPoint()->GetProcessDefinedStep()) {
45  fProcessType = aStep->GetPostStepPoint()->
46  GetProcessDefinedStep()->GetProcessType();
47  fProcessSubType = aStep->GetPostStepPoint()->
48  GetProcessDefinedStep()->GetProcessSubType();
49  fProcessName = aStep->GetPostStepPoint()->
50  GetProcessDefinedStep()->GetProcessName();
51  fProcessDeposit = aStep->GetTotalEnergyDeposit();
52  }
53 }
54 
56  : G4TrajectoryPoint(aTrack->GetPosition()) {
57  fTime = aTrack->GetGlobalTime();
58  fMomentum = aTrack->GetMomentum();
59  fStepStatus = fUndefined;
60  if (aTrack->GetVolume()) {
61  fPhysVolName = aTrack->GetVolume()->GetName();
62  }
63  else {
64  fPhysVolName == "OutOfWorld";
65  }
66  fPrevPosition = aTrack->GetPosition();
67  const G4VProcess* proc = aTrack->GetCreatorProcess();
68  if (proc) {
69  fProcessType = proc->GetProcessType();
70  fProcessSubType = proc->GetProcessSubType();
71  fProcessName = proc->GetProcessName();
72  fProcessDeposit = 0.0;
73  }
74 }
75 
77  : G4TrajectoryPoint(right) {
78  fTime = right.fTime;
79  fMomentum = right.fMomentum;
80  fStepStatus = right.fStepStatus;
81  fProcessType = right.fProcessType;
83  fProcessName = right.fProcessName;
85  fPhysVolName = right.fPhysVolName;
87 }
88 
90 
91 const std::map<G4String,G4AttDef>* EDepSim::TrajectoryPoint::GetAttDefs() const {
92  G4bool isNew;
93 
94  std::map<G4String,G4AttDef>* store
95  = G4AttDefStore::GetInstance("EDepSim::TrajectoryPoint",isNew);
96 
97  if (isNew) {
98 
99  G4String Time("Time");
100  (*store)[Time] =
101  G4AttDef(Time, "Time", "Physics","G4BestUnit","G4double");
102 
103  G4String Momentum("Momentum");
104  (*store)[Momentum] =
105  G4AttDef(Momentum, "Momentum", "Physics",
106  "G4BestUnit","G4ThreeVector");
107 
108  G4String StepStatus("StepStatus");
109  (*store)[StepStatus] =
110  G4AttDef(StepStatus, "StepStatus", "Physics", "", "G4StepStatus");
111 
112  G4String VolumeName("VolumeName");
113  (*store)[VolumeName] =
114  G4AttDef(VolumeName, "VolumeName", "Physics", "", "G4String");
115 
116  G4String VolumeNode("VolumeNode");
117  (*store)[VolumeNode] =
118  G4AttDef(VolumeNode, "VolumeNode", "Physics", "", "G4int");
119 
120  }
121  return store;
122 }
123 
124 std::vector<G4AttValue>* EDepSim::TrajectoryPoint::CreateAttValues() const {
125  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
126 
127  values->push_back(G4AttValue("Time",G4BestUnit(fTime,"Time"),""));
128 
129  values->push_back(G4AttValue("Momentum",
130  G4BestUnit(fMomentum,"Momentum"),""));
131  values->push_back(G4AttValue("StepStatus",fStepStatus,""));
132 
133  values->push_back(G4AttValue("PhysVolName",fPhysVolName,""));
134 
135 #ifdef G4ATTDEBUG
136  EDepSimInfo(G4AttCheck(values,GetAttDefs()));
137 #endif
138 
139  return values;
140 }
141 
143  gGeoManager->PushPath();
144  int node
145  = EDepSim::RootGeometryManager::Get()->GetNodeId(0.5*(GetPosition()
146  +fPrevPosition));
147  gGeoManager->PopPath();
148  return node;
149 }
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4Allocator< EDepSim::TrajectoryPoint > aTrajPointAllocator
#define EDepSimInfo(outStream)
Definition: EDepSimLog.hh:752
Q_UINT16 values[128]
int GetNodeId(const G4ThreeVector &pos)
Get a volume ID base on the volume position.
virtual std::vector< G4AttValue > * CreateAttValues() const
static EDepSim::RootGeometryManager * Get(void)
If a persistency manager has not been created, create one.