Step processing method.
92 {
93
94
95 const G4Track& track = *step->GetTrack();
96 const G4StepPoint& preStepPoint = *step->GetPreStepPoint();
97 const G4StepPoint& postStepPoint = *step->GetPostStepPoint();
98
99
100
101 if (current_trackID != track.GetTrackID()) {
102 current_trackID = track.GetTrackID();
103 current_trackVertex_x = track.GetVertexPosition().x();
104 current_trackVertex_y = track.GetVertexPosition().y();
105 current_trackVertex_z = track.GetVertexPosition().z();
106 current_pdgID = track.GetDefinition()->GetPDGEncoding();
107 current_sensorID = preStepPoint.GetTouchableHandle()->GetReplicaNumber(1);
108
109
110 G4ThreeVector preStepPointPosition = preStepPoint.GetPosition();
111 G4ThreeVector trackMomentum = track.GetMomentum();
112 current_energyDep = 0.;
113 current_nielDep = 0.;
114
115 current_posIN_x = preStepPointPosition.x();
116 current_posIN_y = preStepPointPosition.y();
117 current_posIN_z = preStepPointPosition.z();
118 current_momentum_x = trackMomentum.x();
119 current_momentum_y = trackMomentum.y();
120 current_momentum_z = trackMomentum.z();
121
122
123 G4TouchableHandle theTouchable = preStepPoint.GetTouchableHandle();
124 G4ThreeVector worldDirection = preStepPoint.GetMomentumDirection();
125 G4ThreeVector localDirection = theTouchable->GetHistory()->GetTopTransform().TransformAxis(worldDirection);
126
127 if (localDirection.z() < 0.) {
128 current_thetaAngle = M_PI - acos(-1. * localDirection.z());
129 } else {
130 current_thetaAngle = acos(localDirection.z());
131 }
132
133
134 if (localDirection.x() < 0. && localDirection.y() > 0.) {
135 current_phiAngle = atan(-1. * localDirection.x() / localDirection.y());
136 } else if (localDirection.x() < 0. && localDirection.y() < 0.) {
137 current_phiAngle = M_PI - atan(localDirection.x() / localDirection.y());
138 } else if (localDirection.x() > 0. && localDirection.y() < 0.) {
139 current_phiAngle = M_PI + atan(-1. * localDirection.x() / localDirection.y());
140 } else if (localDirection.x() > 0. && localDirection.y() > 0.) {
141 current_phiAngle = 2. * M_PI - atan(localDirection.x() / localDirection.y());
142 } else if (localDirection.x() < 0. && localDirection.y() == 0.) {
143 current_phiAngle = M_PI / 2.;
144 } else if (localDirection.x() > 0. && localDirection.y() == 0.) {
145 current_phiAngle = 3.* M_PI / 2.;
146 } else if (localDirection.x() == 0. && localDirection.y() > 0.) {
147 current_phiAngle = 0.;
148 } else if (localDirection.x() == 0. && localDirection.y() < 0.) {
149 current_phiAngle = M_PI;
150 }
151
152 G4ThreeVector localINPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(preStepPointPosition);
153 current_posIN_u = localINPosition.y();
154 current_posIN_v = - localINPosition.x();
155 current_posIN_w = localINPosition.z();
156
157 current_globalTime = step->GetPreStepPoint()->GetGlobalTime();
158
159 }
160
161
162 current_energyDep += step->GetTotalEnergyDeposit();
163 current_nielDep += step->GetNonIonizingEnergyDeposit();
164
165
166 if (track.GetNextVolume() != track.GetVolume() || track.GetTrackStatus() >= fStopAndKill) {
167
168 G4ThreeVector postStepPointPosition = postStepPoint.GetPosition();
169
170 current_posOUT_x = postStepPointPosition.x();
171 current_posOUT_y = postStepPointPosition.y();
172 current_posOUT_z = postStepPointPosition.z();
173 G4ThreeVector localOUTPosition = preStepPoint.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
174 postStepPointPosition);
175 current_posOUT_u = localOUTPosition.y();
176 current_posOUT_v = - localOUTPosition.x();
177 current_posOUT_w = localOUTPosition.z();
178
179
180 StoreArray<MCParticle> mcParticles;
181 StoreArray<PlumeSimHit> simHits;
182
183 if (current_energyDep > CLHEP::eV) {
184
185 RelationArray relMCSimHit(mcParticles, simHits);
186 PlumeSimHit* hit = simHits.appendNew(
187 current_pdgID,
188 current_sensorID,
189 current_trackID,
190 current_trackVertex_x / CLHEP::mm,
191 current_trackVertex_y / CLHEP::mm,
192 current_trackVertex_z / CLHEP::mm,
193 current_energyDep / CLHEP::MeV,
194 current_nielDep / CLHEP::MeV,
195 current_posIN_x / CLHEP::mm,
196 current_posIN_y / CLHEP::mm,
197 current_posIN_z / CLHEP::mm,
198 current_posIN_u / CLHEP::mm,
199 current_posIN_v / CLHEP::mm,
200 current_posIN_w / CLHEP::mm,
201 current_posOUT_u / CLHEP::mm,
202 current_posOUT_v / CLHEP::mm,
203 current_posOUT_w / CLHEP::mm,
204 current_momentum_x / CLHEP::GeV,
205 current_momentum_y / CLHEP::GeV,
206 current_momentum_z / CLHEP::GeV,
207 current_thetaAngle / CLHEP::degree,
208 current_phiAngle / CLHEP::degree,
209 current_globalTime / CLHEP::nanosecond
210 );
211
212
213
214 relMCSimHit.add(current_trackID, hit->getArrayIndex(), 1.0);
215 }
216
217
218 current_trackID = 0;
219
220 }
221
222
223
224 if (current_energyDep < CLHEP::eV) return false;
225
226
227 return true;
228 }