35 std::unique_ptr<const Logger> slogger)
37 m_propagator(std::move(propagator)),
38 m_logger(std::move(slogger)) {}
47 State mState(gctx, mctx);
48 resolveMaterialVolume(mState, *
world);
49 collectMaterialSurfaces(mState, *
world);
56 <<
"' for material surfaces.")
59 checkAndInsert(mState, tVolume);
66 resolveMaterialVolume(mState, *sVolume);
72 resolveMaterialVolume(mState, *sVolume);
81 if (volumeMaterial !=
nullptr) {
83 size_t volumeID = geoID.
volume();
84 ACTS_DEBUG(
"Material volume found with volumeID " << volumeID);
94 const BinUtility* bu = (psm !=
nullptr) ? (&psm->binUtility()) :
nullptr;
101 ACTS_DEBUG(
" - adjusted binning is " << buAdjusted);
106 auto bmp =
dynamic_cast<
109 if (bmp !=
nullptr) {
116 ACTS_DEBUG(
" - this is homogeneous material.");
127 <<
"' for material surfaces.")
132 if (bSurface->surfaceRepresentation().surfaceMaterial() !=
nullptr) {
133 mState.
surfaceMaterial[bSurface->surfaceRepresentation().geometryId()] =
134 bSurface->surfaceRepresentation().surfaceMaterialSharedPtr();
145 if (cLayer->surfaceRepresentation().surfaceMaterial() !=
nullptr) {
147 cLayer->surfaceRepresentation().surfaceMaterialSharedPtr();
150 if (cLayer->approachDescriptor() !=
nullptr) {
151 for (
auto& aSurface :
152 cLayer->approachDescriptor()->containedSurfaces()) {
153 if (aSurface !=
nullptr) {
154 if (aSurface->surfaceMaterial() !=
nullptr) {
156 aSurface->surfaceMaterialSharedPtr();
162 if (cLayer->surfaceArray() !=
nullptr) {
164 for (
auto& sSurface : cLayer->surfaceArray()->surfaces()) {
165 if (sSurface !=
nullptr) {
166 if (sSurface->surfaceMaterial() !=
nullptr) {
168 sSurface->surfaceMaterialSharedPtr();
180 collectMaterialSurfaces(mState, *sVolume);
188 std::vector<Acts::Vector3D> extraPosition;
189 std::vector<Acts::Vector3D> extraRemainderPositions;
191 int volumeStep = floor(properties.
thickness() / m_cfg.mappingStep);
192 float remainder = properties.
thickness() - m_cfg.mappingStep * volumeStep;
194 direction = direction * (m_cfg.mappingStep / direction.norm());
196 for (
int extraStep = 0; extraStep < volumeStep; extraStep++) {
198 extraPosition.push_back(position + extraStep * direction);
200 matPoint.push_back(std::pair(properties, extraPosition));
205 extraRemainderPositions.push_back(position + volumeStep * direction);
206 matPoint.push_back(std::pair(properties, extraRemainderPositions));
213 ACTS_DEBUG(
"Create the material for volume " << recMaterial.first);
214 if (mState.
materialBin[recMaterial.first].dimensions() == 0) {
218 for (
const auto& rm : recMaterial.second) {
223 std::make_unique<HomogeneousVolumeMaterial>(std::move(mat));
224 }
else if (mState.
materialBin[recMaterial.first].dimensions() == 2) {
227 std::function<Acts::Vector2D(Acts::Vector3D)> transfoGlobalToLocal;
229 transfoGlobalToLocal);
235 std::move(matMap), mState.
materialBin[recMaterial.first]);
236 }
else if (mState.
materialBin[recMaterial.first].dimensions() == 3) {
239 std::function<Acts::Vector3D(Acts::Vector3D)> transfoGlobalToLocal;
241 transfoGlobalToLocal);
247 std::move(matMap), mState.
materialBin[recMaterial.first]);
249 throw std::invalid_argument(
250 "Incorrect bin dimension, only 0, 2 and 3 are accepted");
262 1 / mTrack.first.second.norm());
275 const auto& result = m_propagator.propagate(
start,
options).value();
276 auto mcResult = result.get<BoundSurfaceCollector::result_type>();
277 auto mvcResult = result.get<MaterialVolumeCollector::result_type>();
279 auto mappingSurfaces = mcResult.collected;
280 auto mappingVolumes = mvcResult.collected;
283 auto& rMaterial = mTrack.second.materialInteractions;
285 <<
" recorded material steps to map.")
289 <<
" mapping volumes for this track.");
291 for (
auto& mVolumes : mappingVolumes) {
292 ACTS_VERBOSE(
" - Volume : " << mVolumes.volume->geometryId()
293 <<
" at position = (" << mVolumes.position.x()
294 <<
", " << mVolumes.position.y() <<
", "
295 << mVolumes.position.z() <<
")");
297 mappingVolumes.push_back(mVolumes);
301 auto rmIter = rMaterial.begin();
302 auto sfIter = mappingSurfaces.begin();
303 auto volIter = mappingVolumes.begin();
306 GeometryIdentifier lastID = GeometryIdentifier();
307 GeometryIdentifier currentID = GeometryIdentifier();
308 auto currentRecMaterial = mState.recordedMaterial.end();
314 if (volIter != mappingVolumes.end()) {
315 lastPositionEnd = volIter->position;
320 while (rmIter != rMaterial.end() && volIter != mappingVolumes.end()) {
321 if (volIter != mappingVolumes.end() &&
322 !volIter->volume->inside(rmIter->position)) {
325 double distVol = (volIter->position - mTrack.first.first).norm();
326 double distMat = (rmIter->position - mTrack.first.first).norm();
332 if (volIter != mappingVolumes.end() &&
333 volIter->volume->inside(rmIter->position)) {
334 currentID = volIter->volume->geometryId();
335 if (not(currentID == lastID)) {
338 lastPositionEnd = volIter->position;
339 currentRecMaterial = mState.recordedMaterial.find(currentID);
343 if (currentRecMaterial != mState.recordedMaterial.end() &&
344 rmIter->materialSlab.thickness() > 0) {
346 float vacuumThickness = (rmIter->position - lastPositionEnd).norm();
350 createExtraHits(currentRecMaterial->second, properties,
351 lastPositionEnd, direction);
355 direction = rmIter->direction;
357 direction * (rmIter->materialSlab.thickness() / direction.norm());
358 lastPositionEnd = rmIter->position + direction;
360 createExtraHits(currentRecMaterial->second, rmIter->materialSlab,
361 rmIter->position, direction);
366 if ((rmIter + 1) == rMaterial.end() ||
367 !volIter->volume->inside((rmIter + 1)->
position)) {
369 while (sfIter != mappingSurfaces.end()) {
370 if (sfIter->surface->geometryId().volume() == lastID.volume() ||
371 ((volIter + 1) != mappingVolumes.end() &&
372 sfIter->surface->geometryId().volume() ==
373 (volIter + 1)->
volume->geometryId().volume())) {
374 double distVol = (volIter->position - mTrack.first.first).norm();
375 double distSur = (sfIter->position - mTrack.first.first).norm();
377 float vacuumThickness =
378 (sfIter->position - lastPositionEnd).norm();
383 createExtraHits(currentRecMaterial->second, properties,
384 lastPositionEnd, direction);
385 lastPositionEnd = sfIter->position;
393 rmIter->volume = volIter->volume;