34 std::unique_ptr<const Logger> slogger)
36 m_propagator(std::move(propagator)),
37 m_logger(std::move(slogger)) {}
46 State mState(gctx, mctx);
47 resolveMaterialVolume(mState, *
world);
54 <<
"' for material surfaces.")
57 checkAndInsert(mState, tVolume);
64 resolveMaterialVolume(mState, *sVolume);
70 resolveMaterialVolume(mState, *sVolume);
79 if (volumeMaterial !=
nullptr) {
80 auto geoID = volume.
geoID();
81 size_t volumeID = geoID.
volume();
82 ACTS_DEBUG(
"Material volume found with volumeID " << volumeID);
92 const BinUtility* bu = (psm !=
nullptr) ? (&psm->binUtility()) :
nullptr;
99 ACTS_DEBUG(
" - adjusted binning is " << buAdjusted);
104 auto bmp =
dynamic_cast<
107 if (bmp !=
nullptr) {
114 ACTS_DEBUG(
" - this is homogeneous material.");
125 ACTS_DEBUG(
"Create the material for volume " << recMaterial.first);
126 if (mState.
materialBin[recMaterial.first].dimensions() == 0) {
130 for (
const auto& rm : recMaterial.second) {
135 std::make_unique<HomogeneousVolumeMaterial>(std::move(mat));
137 }
else if (mState.
materialBin[recMaterial.first].dimensions() == 2) {
140 std::function<Acts::Vector2D(Acts::Vector3D)> transfoGlobalToLocal;
142 transfoGlobalToLocal);
148 std::move(matMap), mState.
materialBin[recMaterial.first]);
150 }
else if (mState.
materialBin[recMaterial.first].dimensions() == 3) {
153 std::function<Acts::Vector3D(Acts::Vector3D)> transfoGlobalToLocal;
155 transfoGlobalToLocal);
161 std::move(matMap), mState.
materialBin[recMaterial.first]);
164 throw std::invalid_argument(
165 "Incorrect bin dimension, only 0, 2 and 3 are accepted");
174 mTrack.first.second, 0.);
183 options.
debug = m_cfg.mapperDebugOutput;
186 const auto& result = m_propagator.propagate(start, options).value();
187 auto mcResult = result.get<MaterialVolumeCollector::result_type>();
189 if (m_cfg.mapperDebugOutput) {
195 auto mappingVolumes = mcResult.collected;
198 auto& rMaterial = mTrack.second.materialInteractions;
200 <<
" recorded material steps to map.")
204 <<
" mapping volumes for this track.");
206 for (
auto& mVolumes : mappingVolumes) {
208 <<
" at position = (" << mVolumes.position.x()
209 <<
", " << mVolumes.position.y() <<
", "
210 << mVolumes.position.z() <<
")");
212 mappingVolumes.push_back(mVolumes);
216 auto rmIter = rMaterial.begin();
217 auto volIter = mappingVolumes.begin();
218 bool encounterVolume =
false;
230 while (rmIter != rMaterial.end() && volIter != mappingVolumes.end()) {
231 if (volIter != mappingVolumes.end() && encounterVolume ==
true &&
232 !volIter->volume->inside(rmIter->position)) {
233 encounterVolume =
false;
237 if (volIter != mappingVolumes.end() &&
238 volIter->volume->inside(rmIter->position)) {
239 currentID = volIter->
volume->geoID();
240 if (not(currentID == lastID)) {
248 floor(rmIter->materialProperties.thickness() / m_cfg.mappingStep);
249 auto properties = rmIter->materialProperties;
250 float remainder = rmIter->materialProperties.thickness() -
251 m_cfg.mappingStep * volumeStep;
252 properties.scaleThickness(m_cfg.mappingStep / properties.thickness());
254 std::pair(properties, rmIter->position));
257 extraDirection = rmIter->direction;
259 extraDirection * (m_cfg.mappingStep / extraDirection.norm());
260 extraPosition = rmIter->position +
step * extraDirection;
261 if (
step == volumeStep) {
263 properties.scaleThickness(remainder / properties.thickness());
266 std::pair(properties, extraPosition));
269 encounterVolume =
true;