25 std::unique_ptr<const Logger> slogger)
27 m_propagator(std::move(propagator)),
28 m_logger(std::move(slogger)) {}
37 State mState(gctx, mctx);
38 resolveMaterialSurfaces(mState, *
world);
39 collectMaterialVolumes(mState, *
world);
42 <<
" Surfaces with PROXIES collected ... ");
52 <<
"' for material surfaces.")
57 checkAndInsert(mState, bSurface->surfaceRepresentation());
67 checkAndInsert(mState, cLayer->surfaceRepresentation());
69 if (cLayer->approachDescriptor() !=
nullptr) {
71 cLayer->approachDescriptor()->containedSurfaces()) {
72 if (aSurface !=
nullptr) {
73 checkAndInsert(mState, *aSurface);
78 if (cLayer->surfaceArray() !=
nullptr) {
80 for (
auto& sSurface : cLayer->surfaceArray()->surfaces()) {
81 if (sSurface !=
nullptr) {
82 checkAndInsert(mState, *sSurface);
93 resolveMaterialSurfaces(mState, *sVolume);
102 if (surfaceMaterial !=
nullptr) {
104 size_t volumeID = geoID.
volume();
105 ACTS_DEBUG(
"Material surface found with volumeID " << volumeID);
113 const BinUtility* bu = (psm !=
nullptr) ? (&psm->binUtility()) :
nullptr;
120 ACTS_DEBUG(
" - adjusted binning is " << buAdjusted);
128 bu = (bmp !=
nullptr) ? (&bmp->binUtility()) :
nullptr;
136 ACTS_DEBUG(
" - this is homogeneous material.");
145 <<
"' for material surfaces.")
157 collectMaterialVolumes(mState, *sVolume);
163 collectMaterialVolumes(mState, *sVolume);
171 ACTS_DEBUG(
"Finalizing map for Surface " << accMaterial.first);
173 accMaterial.second.totalAverage();
184 1 / mTrack.first.second.norm());
198 const auto& result = m_propagator.propagate(
start,
options).value();
199 auto mcResult = result.get<MaterialSurfaceCollector::result_type>();
200 auto mvcResult = result.get<MaterialVolumeCollector::result_type>();
202 auto mappingSurfaces = mcResult.collected;
203 auto mappingVolumes = mvcResult.collected;
206 auto& rMaterial = mTrack.second.materialInteractions;
207 std::map<GeometryIdentifier, unsigned int> assignedMaterial;
209 <<
" recorded material steps to map.")
213 <<
" mapping surfaces for this track.");
217 <<
" at position = (" <<
mSurface.position.x()
218 <<
", " <<
mSurface.position.y() <<
", "
220 assignedMaterial[
mSurface.surface->geometryId()] = 0;
228 auto rmIter = rMaterial.begin();
229 auto sfIter = mappingSurfaces.begin();
230 auto volIter = mappingVolumes.begin();
233 GeometryIdentifier lastID = GeometryIdentifier();
234 GeometryIdentifier currentID = GeometryIdentifier();
236 double currentPathCorrection = 0.;
237 auto currentAccMaterial = mState.accumulatedMaterial.end();
240 using MapBin = std::pair<AccumulatedSurfaceMaterial*, std::array<size_t, 3>>;
241 std::multimap<AccumulatedSurfaceMaterial*, std::array<size_t, 3>>
245 while (rmIter != rMaterial.end() && sfIter != mappingSurfaces.end()) {
247 if (volIter != mappingVolumes.end() &&
248 !volIter->volume->inside(rmIter->position)) {
249 double distVol = (volIter->position - mTrack.first.first).norm();
250 double distMat = (rmIter->position - mTrack.first.first).norm();
258 if (volIter != mappingVolumes.end() &&
259 volIter->volume->inside(rmIter->position)) {
263 if (sfIter != mappingSurfaces.end() - 1 &&
264 (rmIter->position - sfIter->position).norm() >
265 (rmIter->position - (sfIter + 1)->
position).norm()) {
270 currentID = sfIter->surface->geometryId();
272 if (not(currentID == lastID)) {
276 currentPathCorrection = sfIter->surface->pathCorrection(
277 mState.geoContext, currentPos, sfIter->direction);
278 currentAccMaterial = mState.accumulatedMaterial.find(currentID);
281 auto tBin = currentAccMaterial->second.accumulate(
282 currentPos, rmIter->materialSlab, currentPathCorrection);
283 touchedMapBins.insert(MapBin(&(currentAccMaterial->second), tBin));
284 ++assignedMaterial[currentID];
286 rmIter->surface = sfIter->surface;
291 ACTS_VERBOSE(
"Surfaces have following number of assigned hits :")
297 for (
auto tmapBin : touchedMapBins) {
298 std::vector<std::array<size_t, 3>> trackBins = {tmapBin.second};
299 tmapBin.first->trackAverage(trackBins);
303 if (m_cfg.emptyBinCorrection) {
307 for (
auto&
mSurface : mappingSurfaces) {
308 auto mgID =
mSurface.surface->geometryId();
311 if (assignedMaterial[mgID] == 0) {
312 auto missedMaterial = mState.accumulatedMaterial.find(mgID);
313 missedMaterial->second.trackAverage(
mSurface.position,
true);