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