30 const EventContext& ctx = Gaudi::Hive::currentContext();
36 auto coll = std::make_unique<RecordedMaterialTrackCollection>();
37 if (materialTracks.
record(std::move(coll)).isFailure()) {
38 ATH_MSG_ERROR(
"Failed to record RecordedMaterialTrackCollection with key "
39 <<
m_cfg.materialTrackCollectionName);
51 ATH_MSG_ERROR(
"Recorded collection pointer is null right after record/present for key "
52 <<
m_cfg.materialTrackCollectionName);
56 <<
" slot=" << ctx.slot() <<
" key=" <<
m_cfg.materialTrackCollectionName);
76 ATH_MSG_ERROR(
"No per-event collection pointer cached (m_coll is null).");
81 G4Material* material = step->GetPreStepPoint()->GetMaterial();
82 if (material ==
nullptr) {
87 std::string materialName = material->GetName();
88 for (
const auto& emat :
m_cfg.excludeMaterials) {
89 if (emat == materialName) {
90 ATH_MSG_DEBUG(
"Exclude step in material '" << materialName <<
"'.");
105 const G4ElementVector* elements = material->GetElementVector();
106 const G4double* fraction = material->GetFractionVector();
107 std::size_t nElements = material->GetNumberOfElements();
111 if (nElements == 1) {
112 Ar = material->GetA() / (CLHEP::gram / CLHEP::mole);
113 Z = material->GetZ();
115 for (std::size_t i = 0; i < nElements; i++) {
116 Ar += elements->at(i)->GetA() * fraction[i] / (CLHEP::gram / CLHEP::mole);
117 Z += elements->at(i)->GetZ() * fraction[i];
122 const auto slab = Acts::MaterialSlab(Acts::Material::fromMassDensity(X0, L0, Ar, Z, rho),
s_convertLength * step->GetStepLength());
125 Acts::MaterialInteraction mInteraction;
126 mInteraction.position =
convertPosition(step->GetPreStepPoint()->GetPosition());
127 mInteraction.direction =
convertDirection(step->GetPreStepPoint()->GetMomentum()).normalized();
128 mInteraction.materialSlab = slab;
129 mInteraction.pathCorrection = (step->GetStepLength() / CLHEP::mm);
131 G4Track* g4Track = step->GetTrack();
135 Acts::Vector3 direction =
convertDirection(g4Track->GetMomentumDirection());
136 rmTrack.first = {vertex, direction};
137 rmTrack.second.materialInteractions.push_back(mInteraction);