This routine will be called when the appropriate signal arrives.
201 const G4TouchableHistory* touchable =
static_cast<const G4TouchableHistory*
>(
step->GetTrack()->GetTouchable());
203 LogInfo(
"TrackingMaterialProducer") <<
"TrackingMaterialProducer:\t[...] skipping " 204 << touchable->GetVolume()->GetName() << std::endl;
209 const G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
210 double length =
step->GetStepLength() / cm;
211 double X0 = material->GetRadlen() / cm;
212 double Ne = material->GetElectronDensity() * cm3;
213 double Xi = Ne / 6.0221415e23 * 0.307075 / 2;
214 double radiationLengths = length /
X0;
218 G4ThreeVector globalPosPre =
step->GetPreStepPoint()->GetPosition();
219 G4ThreeVector globalPosPost =
step->GetPostStepPoint()->GetPosition();
220 GlobalPoint globalPositionIn(globalPosPre.x() / cm, globalPosPre.y() / cm, globalPosPre.z() / cm);
221 GlobalPoint globalPositionOut(globalPosPost.x() / cm, globalPosPost.y() / cm, globalPosPost.z() / cm);
223 G4StepPoint* prePoint =
step->GetPreStepPoint();
224 G4StepPoint* postPoint =
step->GetPostStepPoint();
225 const CLHEP::Hep3Vector& postPos = postPoint->GetPosition();
231 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHGCalEta &&
238 << postPoint->GetMomentum().eta() <<
" " 239 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
243 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHFnoseEta &&
246 << postPoint->GetMomentum().eta() <<
" " 247 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
254 bool enter_sensitive =
false;
255 bool leave_sensitive =
false;
256 double cosThetaPre = 0.0;
257 double cosThetaPost = 0.0;
259 const G4VPhysicalVolume* sensitive =
nullptr;
263 const G4VSolid& solid = *touchable->GetSolid(
level);
265 G4ThreeVector
pos =
transform.Inverse().TransformPoint(G4ThreeVector(0., 0., 0.));
268 G4ThreeVector localPosPre =
transform.TransformPoint(globalPosPre);
269 EInside statusPre = solid.Inside(localPosPre);
270 if (statusPre == kSurface) {
271 enter_sensitive =
true;
272 G4ThreeVector globalDirPre =
step->GetPreStepPoint()->GetMomentumDirection();
273 G4ThreeVector localDirPre =
transform.TransformAxis(globalDirPre);
274 G4ThreeVector normalPre = solid.SurfaceNormal(localPosPre);
275 cosThetaPre = normalPre.cosTheta(-localDirPre);
278 G4ThreeVector localPosPost =
transform.TransformPoint(globalPosPost);
279 EInside statusPost = solid.Inside(localPosPost);
280 if (statusPost == kSurface) {
281 leave_sensitive =
true;
282 G4ThreeVector globalDirPost =
step->GetPostStepPoint()->GetMomentumDirection();
283 G4ThreeVector localDirPost =
transform.TransformAxis(globalDirPost);
284 G4ThreeVector normalPost = solid.SurfaceNormal(localPosPost);
285 cosThetaPost = normalPost.cosTheta(localDirPost);
290 if (enter_sensitive) {
292 edm::LogWarning(
"TrackingMaterialProducer") <<
"Entering volume " << sensitive <<
" while inside volume " 300 if (leave_sensitive) {
302 edm::LogWarning(
"TrackingMaterialProducer") <<
"Leaving volume " << sensitive <<
" while inside volume " 310 LogInfo(
"TrackingMaterialProducer") <<
"Track was near sensitive volume " << sensitive->GetName() << std::endl;
312 LogInfo(
"TrackingMaterialProducer") <<
"Track was near non-sensitive volume " << touchable->GetVolume()->GetName()
314 LogInfo(
"TrackingMaterialProducer") <<
"Step length: " << length <<
" cm\n" 315 <<
"globalPreStep(r,z): (" << globalPositionIn.perp() <<
", " 316 << globalPositionIn.z() <<
") cm\n" 317 <<
"globalPostStep(r,z): (" << globalPositionOut.perp() <<
", " 318 << globalPositionOut.z() <<
") cm\n" 319 <<
"position(r,z): (" <<
position.perp() <<
", " <<
position.z() <<
") cm\n" 320 <<
"Radiation lengths: " << radiationLengths <<
" \t\t(X0: " <<
X0 322 <<
"Energy loss: " <<
energyLoss <<
" MeV \t(Xi: " << Xi
324 <<
"Track was " << (enter_sensitive ?
"entering " :
"in none ")
325 <<
"sensitive volume\n" 326 <<
"Track was " << (leave_sensitive ?
"leaving " :
"in none ")
327 <<
"sensitive volume\n";
void leaveDetector(double cosTheta)
static constexpr float innerHGCalEta
void enterDetector(const GlobalPoint &position, double cosTheta)
MaterialAccountingTrack m_track
Global3DPoint GlobalPoint
static constexpr float outerHFnoseEta
static constexpr float outerHGCalEta
void step(const MaterialAccountingStep &step)
const G4VPhysicalVolume * m_track_volume
static const G4AffineTransform & GetTransform(const G4TouchableHistory *touchable, int depth)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
static constexpr float innerHFnoseEta
Log< level::Info, false > LogInfo
std::ofstream outVolumeZpositionTxt
static int position[264][3]
Log< level::Warning, false > LogWarning
bool isSelectedFast(const G4TouchableHistory *touch)
std::tuple< const G4VPhysicalVolume *, int > GetSensitiveVolume(const G4VTouchable *touchable)