This routine will be called when the appropriate signal arrives.
195 const G4TouchableHistory* touchable = static_cast<const G4TouchableHistory*>(
step->GetTrack()->GetTouchable());
197 LogInfo(
"TrackingMaterialProducer") <<
"TrackingMaterialProducer:\t[...] skipping "
198 << touchable->GetVolume()->GetName() << std::endl;
203 const G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
204 double length =
step->GetStepLength() / cm;
205 double X0 = material->GetRadlen() / cm;
206 double Ne = material->GetElectronDensity() * cm3;
207 double Xi = Ne / 6.0221415e23 * 0.307075 / 2;
208 double radiationLengths = length /
X0;
212 G4ThreeVector globalPosPre =
step->GetPreStepPoint()->GetPosition();
213 G4ThreeVector globalPosPost =
step->GetPostStepPoint()->GetPosition();
214 GlobalPoint globalPositionIn(globalPosPre.x() / cm, globalPosPre.y() / cm, globalPosPre.z() / cm);
215 GlobalPoint globalPositionOut(globalPosPost.x() / cm, globalPosPost.y() / cm, globalPosPost.z() / cm);
217 G4StepPoint* prePoint =
step->GetPreStepPoint();
218 G4StepPoint* postPoint =
step->GetPostStepPoint();
219 const CLHEP::Hep3Vector& postPos = postPoint->GetPosition();
225 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHGCalEta &&
232 << postPoint->GetMomentum().eta() <<
" "
233 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
237 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHFnoseEta &&
240 << postPoint->GetMomentum().eta() <<
" "
241 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
248 bool enter_sensitive =
false;
249 bool leave_sensitive =
false;
250 double cosThetaPre = 0.0;
251 double cosThetaPost = 0.0;
253 const G4VPhysicalVolume* sensitive =
nullptr;
257 const G4VSolid& solid = *touchable->GetSolid(
level);
259 G4ThreeVector
pos =
transform.Inverse().TransformPoint(G4ThreeVector(0., 0., 0.));
262 G4ThreeVector localPosPre =
transform.TransformPoint(globalPosPre);
263 EInside statusPre = solid.Inside(localPosPre);
264 if (statusPre == kSurface) {
265 enter_sensitive =
true;
266 G4ThreeVector globalDirPre =
step->GetPreStepPoint()->GetMomentumDirection();
267 G4ThreeVector localDirPre =
transform.TransformAxis(globalDirPre);
268 G4ThreeVector normalPre = solid.SurfaceNormal(localPosPre);
269 cosThetaPre = normalPre.cosTheta(-localDirPre);
272 G4ThreeVector localPosPost =
transform.TransformPoint(globalPosPost);
273 EInside statusPost = solid.Inside(localPosPost);
274 if (statusPost == kSurface) {
275 leave_sensitive =
true;
276 G4ThreeVector globalDirPost =
step->GetPostStepPoint()->GetMomentumDirection();
277 G4ThreeVector localDirPost =
transform.TransformAxis(globalDirPost);
278 G4ThreeVector normalPost = solid.SurfaceNormal(localPosPost);
279 cosThetaPost = normalPost.cosTheta(localDirPost);
291 LogInfo(
"TrackingMaterialProducer") <<
"Track was near sensitive volume " << sensitive->GetName() << std::endl;
293 LogInfo(
"TrackingMaterialProducer") <<
"Track was near non-sensitive volume " << touchable->GetVolume()->GetName()
295 LogInfo(
"TrackingMaterialProducer") <<
"Step length: " << length <<
" cm\n"
296 <<
"globalPreStep(r,z): (" << globalPositionIn.perp() <<
", "
297 << globalPositionIn.z() <<
") cm\n"
298 <<
"globalPostStep(r,z): (" << globalPositionOut.perp() <<
", "
299 << globalPositionOut.z() <<
") cm\n"
300 <<
"position(r,z): (" <<
position.perp() <<
", " <<
position.z() <<
") cm\n"
301 <<
"Radiation lengths: " << radiationLengths <<
" \t\t(X0: " <<
X0
303 <<
"Energy loss: " <<
energyLoss <<
" MeV \t(Xi: " << Xi
305 <<
"Track was " << (enter_sensitive ?
"entering " :
"in none ")
306 <<
"sensitive volume\n"
307 <<
"Track was " << (leave_sensitive ?
"leaving " :
"in none ")
308 <<
"sensitive volume\n";