This routine will be called when the appropriate signal arrives.
204 const G4TouchableHistory* touchable =
static_cast<const G4TouchableHistory*
>(
step->GetTrack()->GetTouchable());
206 LogInfo(
"TrackingMaterialProducer") <<
"TrackingMaterialProducer:\t[...] skipping " 207 << touchable->GetVolume()->GetName() << std::endl;
212 const G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
213 double length =
step->GetStepLength() / cm;
214 double X0 = material->GetRadlen() / cm;
215 double Ne = material->GetElectronDensity() * cm3;
216 double Xi = Ne / 6.0221415e23 * 0.307075 / 2;
217 double radiationLengths = length /
X0;
221 G4ThreeVector globalPosPre =
step->GetPreStepPoint()->GetPosition();
222 G4ThreeVector globalPosPost =
step->GetPostStepPoint()->GetPosition();
223 GlobalPoint globalPositionIn(globalPosPre.x() / cm, globalPosPre.y() / cm, globalPosPre.z() / cm);
224 GlobalPoint globalPositionOut(globalPosPost.x() / cm, globalPosPost.y() / cm, globalPosPost.z() / cm);
226 G4StepPoint* prePoint =
step->GetPreStepPoint();
227 G4StepPoint* postPoint =
step->GetPostStepPoint();
228 const CLHEP::Hep3Vector& postPos = postPoint->GetPosition();
234 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHGCalEta &&
241 << postPoint->GetMomentum().eta() <<
" " 242 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
246 if (postPoint->GetStepStatus() == fGeomBoundary && fabs(postPoint->GetMomentum().eta()) >
outerHFnoseEta &&
249 << postPoint->GetMomentum().eta() <<
" " 250 <<
sqrt(postPos.x() * postPos.x() + postPos.y() * postPos.y()) <<
" " << 0 <<
" " << 0
257 bool enter_sensitive =
false;
258 bool leave_sensitive =
false;
259 double cosThetaPre = 0.0;
260 double cosThetaPost = 0.0;
262 const G4VPhysicalVolume* sensitive =
nullptr;
266 const G4VSolid& solid = *touchable->GetSolid(
level);
268 G4ThreeVector
pos =
transform.Inverse().TransformPoint(G4ThreeVector(0., 0., 0.));
271 G4ThreeVector localPosPre =
transform.TransformPoint(globalPosPre);
272 EInside statusPre = solid.Inside(localPosPre);
273 if (statusPre == kSurface) {
274 enter_sensitive =
true;
275 G4ThreeVector globalDirPre =
step->GetPreStepPoint()->GetMomentumDirection();
276 G4ThreeVector localDirPre =
transform.TransformAxis(globalDirPre);
277 G4ThreeVector normalPre = solid.SurfaceNormal(localPosPre);
278 cosThetaPre = normalPre.cosTheta(-localDirPre);
281 G4ThreeVector localPosPost =
transform.TransformPoint(globalPosPost);
282 EInside statusPost = solid.Inside(localPosPost);
283 if (statusPost == kSurface) {
284 leave_sensitive =
true;
285 G4ThreeVector globalDirPost =
step->GetPostStepPoint()->GetMomentumDirection();
286 G4ThreeVector localDirPost =
transform.TransformAxis(globalDirPost);
287 G4ThreeVector normalPost = solid.SurfaceNormal(localPosPost);
288 cosThetaPost = normalPost.cosTheta(localDirPost);
293 if (enter_sensitive) {
295 edm::LogWarning(
"TrackingMaterialProducer") <<
"Entering volume " << sensitive <<
" while inside volume " 303 if (leave_sensitive) {
305 edm::LogWarning(
"TrackingMaterialProducer") <<
"Leaving volume " << sensitive <<
" while inside volume " 313 LogInfo(
"TrackingMaterialProducer") <<
"Track was near sensitive volume " << sensitive->GetName() << std::endl;
315 LogInfo(
"TrackingMaterialProducer") <<
"Track was near non-sensitive volume " << touchable->GetVolume()->GetName()
317 LogInfo(
"TrackingMaterialProducer") <<
"Step length: " << length <<
" cm\n" 318 <<
"globalPreStep(r,z): (" << globalPositionIn.perp() <<
", " 319 << globalPositionIn.z() <<
") cm\n" 320 <<
"globalPostStep(r,z): (" << globalPositionOut.perp() <<
", " 321 << globalPositionOut.z() <<
") cm\n" 322 <<
"position(r,z): (" <<
position.perp() <<
", " <<
position.z() <<
") cm\n" 323 <<
"Radiation lengths: " << radiationLengths <<
" \t\t(X0: " <<
X0 325 <<
"Energy loss: " <<
energyLoss <<
" MeV \t(Xi: " << Xi
327 <<
"Track was " << (enter_sensitive ?
"entering " :
"in none ")
328 <<
"sensitive volume\n" 329 <<
"Track was " << (leave_sensitive ?
"leaving " :
"in none ")
330 <<
"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)