24 std::unique_ptr<const Logger> slogger)
26 m_propagator(std::move(propagator)),
27 m_logger(std::move(slogger)) {}
36 State mState(gctx, mctx);
37 resolveMaterialSurfaces(mState, *
world);
40 <<
" Surfaces with PROXIES collected ... ");
50 <<
"' for material surfaces.")
55 checkAndInsert(mState, bSurface->surfaceRepresentation());
65 checkAndInsert(mState, cLayer->surfaceRepresentation());
67 if (cLayer->approachDescriptor() !=
nullptr) {
69 cLayer->approachDescriptor()->containedSurfaces()) {
70 if (aSurface !=
nullptr) {
71 checkAndInsert(mState, *aSurface);
76 if (cLayer->surfaceArray() !=
nullptr) {
78 for (
auto& sSurface : cLayer->surfaceArray()->surfaces()) {
79 if (sSurface !=
nullptr) {
80 checkAndInsert(mState, *sSurface);
91 resolveMaterialSurfaces(mState, *sVolume);
100 if (surfaceMaterial !=
nullptr) {
101 auto geoID = surface.
geoID();
102 size_t volumeID = geoID.
volume();
103 ACTS_DEBUG(
"Material surface found with volumeID " << volumeID);
111 const BinUtility* bu = (psm !=
nullptr) ? (&psm->binUtility()) :
nullptr;
118 ACTS_DEBUG(
" - adjusted binning is " << buAdjusted);
126 bu = (bmp !=
nullptr) ? (&bmp->binUtility()) :
nullptr;
134 ACTS_DEBUG(
" - this is homogeneous material.");
143 ACTS_DEBUG(
"Finalizing map for Surface " << accMaterial.first);
145 accMaterial.second.totalAverage();
153 mTrack.first.second, 0.);
165 options.
debug = m_cfg.mapperDebugOutput;
168 const auto& result = m_propagator.propagate(start, options).value();
169 auto mcResult = result.get<MaterialSurfaceCollector::result_type>();
170 auto mvcResult = result.get<MaterialVolumeCollector::result_type>();
172 if (m_cfg.mapperDebugOutput) {
173 auto debugOutput = result.get<DebugOutput::result_type>();
178 auto mappingSurfaces = mcResult.collected;
179 auto mappingVolumes = mvcResult.collected;
182 auto& rMaterial = mTrack.second.materialInteractions;
183 std::map<GeometryID, unsigned int> assignedMaterial;
185 <<
" recorded material steps to map.")
189 <<
" mapping surfaces for this track.");
191 for (
auto&
mSurface : mappingSurfaces) {
193 <<
" at position = (" <<
mSurface.position.x()
194 <<
", " <<
mSurface.position.y() <<
", "
196 assignedMaterial[
mSurface.surface->geoID()] = 0;
204 auto rmIter = rMaterial.begin();
205 auto sfIter = mappingSurfaces.begin();
206 auto volIter = mappingVolumes.begin();
207 bool encounterVolume =
false;
213 double currentPathCorrection = 0.;
217 using MapBin = std::pair<AccumulatedSurfaceMaterial*, std::array<size_t, 3>>;
218 std::multimap<AccumulatedSurfaceMaterial*, std::array<size_t, 3>>
222 while (rmIter != rMaterial.end() && sfIter != mappingSurfaces.end()) {
223 if (volIter != mappingVolumes.end() && encounterVolume ==
true &&
224 !volIter->volume->inside(rmIter->position)) {
225 encounterVolume =
false;
230 if (volIter != mappingVolumes.end() &&
231 volIter->volume->inside(rmIter->position)) {
232 encounterVolume =
true;
236 if (sfIter != mappingSurfaces.end() - 1 &&
237 (rmIter->position - sfIter->position).
norm() >
238 (rmIter->position - (sfIter + 1)->
position).norm()) {
243 currentID = sfIter->surface->geoID();
245 if (not(currentID == lastID)) {
249 currentPathCorrection = sfIter->surface->pathCorrection(
250 mState.
geoContext, currentPos, sfIter->direction);
254 auto tBin = currentAccMaterial->second.accumulate(
255 currentPos, rmIter->materialProperties, currentPathCorrection);
256 touchedMapBins.insert(MapBin(&(currentAccMaterial->second), tBin));
257 ++assignedMaterial[currentID];
259 rmIter->direction = mTrack.first.second.normalized();
260 rmIter->surface = sfIter->surface;
265 ACTS_VERBOSE(
"Surfaces have following number of assigned hits :")
266 for (
auto& [key,
value] : assignedMaterial) {
271 for (
auto tmapBin : touchedMapBins) {
272 std::vector<std::array<size_t, 3>> trackBins = {tmapBin.second};
273 tmapBin.first->trackAverage(trackBins);
277 if (m_cfg.emptyBinCorrection) {
281 for (
auto&
mSurface : mappingSurfaces) {
282 auto mgID =
mSurface.surface->geoID();
285 if (assignedMaterial[mgID] == 0) {
287 missedMaterial->second.trackAverage(
mSurface.position,
true);