This routine will be called when the appropriate signal arrives.
197 const G4TouchableHistory* touchable = static_cast<const G4TouchableHistory*>(
step->GetTrack()->GetTouchable());
199 LogInfo(
"TrackingMaterialProducer") <<
"TrackingMaterialProducer:\t[...] skipping "
200 << touchable->GetVolume()->GetName() << std::endl;
205 const G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
206 double length =
step->GetStepLength() / cm;
207 double X0 = material->GetRadlen() / cm;
208 double Ne = material->GetElectronDensity() * cm3;
209 double Xi = Ne / 6.0221415e23 * 0.307075 / 2;
210 double radiationLengths = length /
X0;
214 G4ThreeVector globalPosPre =
step->GetPreStepPoint()->GetPosition();
215 G4ThreeVector globalPosPost =
step->GetPostStepPoint()->GetPosition();
216 GlobalPoint globalPositionIn(globalPosPre.x() / cm, globalPosPre.y() / cm, globalPosPre.z() / cm);
217 GlobalPoint globalPositionOut(globalPosPost.x() / cm, globalPosPost.y() / cm, globalPosPost.z() / cm);
219 G4StepPoint* prePoint =
step->GetPreStepPoint();
220 G4StepPoint* postPoint =
step->GetPostStepPoint();
221 const CLHEP::Hep3Vector& postPos = postPoint->GetPosition();
227 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHGCalEta &&
234 << postPoint->GetMomentum().eta() <<
" "
235 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
239 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHFnoseEta &&
242 << postPoint->GetMomentum().eta() <<
" "
243 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
250 bool enter_sensitive =
false;
251 bool leave_sensitive =
false;
252 double cosThetaPre = 0.0;
253 double cosThetaPost = 0.0;
255 const G4VPhysicalVolume* sensitive =
nullptr;
259 const G4VSolid& solid = *touchable->GetSolid(
level);
261 G4ThreeVector
pos =
transform.Inverse().TransformPoint(G4ThreeVector(0., 0., 0.));
264 G4ThreeVector localPosPre =
transform.TransformPoint(globalPosPre);
265 EInside statusPre = solid.Inside(localPosPre);
266 if (statusPre == kSurface) {
267 enter_sensitive =
true;
268 G4ThreeVector globalDirPre =
step->GetPreStepPoint()->GetMomentumDirection();
269 G4ThreeVector localDirPre =
transform.TransformAxis(globalDirPre);
270 G4ThreeVector normalPre = solid.SurfaceNormal(localPosPre);
271 cosThetaPre = normalPre.cosTheta(-localDirPre);
274 G4ThreeVector localPosPost =
transform.TransformPoint(globalPosPost);
275 EInside statusPost = solid.Inside(localPosPost);
276 if (statusPost == kSurface) {
277 leave_sensitive =
true;
278 G4ThreeVector globalDirPost =
step->GetPostStepPoint()->GetMomentumDirection();
279 G4ThreeVector localDirPost =
transform.TransformAxis(globalDirPost);
280 G4ThreeVector normalPost = solid.SurfaceNormal(localPosPost);
281 cosThetaPost = normalPost.cosTheta(localDirPost);
286 if (enter_sensitive) {
288 edm::LogWarning(
"TrackingMaterialProducer") <<
"Entering volume " << sensitive <<
" while inside volume "
296 if (leave_sensitive) {
298 edm::LogWarning(
"TrackingMaterialProducer") <<
"Leaving volume " << sensitive <<
" while inside volume "
306 LogInfo(
"TrackingMaterialProducer") <<
"Track was near sensitive volume " << sensitive->GetName() << std::endl;
308 LogInfo(
"TrackingMaterialProducer") <<
"Track was near non-sensitive volume " << touchable->GetVolume()->GetName()
310 LogInfo(
"TrackingMaterialProducer") <<
"Step length: " << length <<
" cm\n"
311 <<
"globalPreStep(r,z): (" << globalPositionIn.perp() <<
", "
312 << globalPositionIn.z() <<
") cm\n"
313 <<
"globalPostStep(r,z): (" << globalPositionOut.perp() <<
", "
314 << globalPositionOut.z() <<
") cm\n"
315 <<
"position(r,z): (" <<
position.perp() <<
", " <<
position.z() <<
") cm\n"
316 <<
"Radiation lengths: " << radiationLengths <<
" \t\t(X0: " <<
X0
318 <<
"Energy loss: " <<
energyLoss <<
" MeV \t(Xi: " << Xi
320 <<
"Track was " << (enter_sensitive ?
"entering " :
"in none ")
321 <<
"sensitive volume\n"
322 <<
"Track was " << (leave_sensitive ?
"leaving " :
"in none ")
323 <<
"sensitive volume\n";