82 std::map<double, Trk::AssociatedMaterial> collectedMaterial;
95 for (
auto& lCandidate : layerIntersections ) {
98 double pathLength = lCandidate.intersection.pathLength;
100 if (layer->layerMaterialProperties()){
102 const Trk::MaterialProperties* mprop = layer->layerMaterialProperties()->fullMaterial(lCandidate.intersection.position);
104 double stepLength = mprop->
thickness()*fabs(layer->surfaceRepresentation().pathCorrection(lCandidate.intersection.position,
direction));
105 collectedMaterial[pathLength] =
Trk::AssociatedMaterial(lCandidate.intersection.position, mprop, stepLength, &tvol, layer);
114 if (!boundaryIntersections.empty()){
116 lastPosition = boundaryIntersections.begin()->intersection.position;
135 std::map<double, std::pair<const Trk::Layer*, Amg::Vector3D> > intersectedLayers;
141 std::span<Trk::Layer const * const> layers = layerArray->
arrayObjects();
142 auto layIter = layers.begin();
143 auto layIterE = layers.end();
144 for ( ; layIter != layIterE; ++layIter){
145 if ( (*layIter)->layerMaterialProperties() ){
147 if (lsIntersection.
valid){
148 intersectedLayers[lsIntersection.
pathLength] = std::pair<const Trk::Layer*, Amg::Vector3D>(*layIter,lsIntersection.
position);
151 Amg::Vector3D mposition = (*layIter)->surfaceRepresentation().transform().inverse()*lsIntersection.
position;
154 double stepLength = mprop->
thickness()*fabs((*layIter)->surfaceRepresentation().pathCorrection(lsIntersection.
position,
direction));
172 Amg::Vector3D lastPosition = !intersectedLayers.empty() ? (*(--(intersectedLayers.end()))).second.second :
position;
174 std::map<double, Trk::VolumeExit > volumeExits;
177 for (
size_t ib = 0; ib < bSurfaces.size(); ++ib){
179 if ( !bSurfaces[ib]->surfaceRepresentation().isOnSurface(lastPosition,
true, 0.1, 0.1) ){
180 Trk::Intersection evIntersection = bSurfaces[ib]->surfaceRepresentation().straightLineIntersection(lastPosition,
direction,
true,
true);
183 if (evIntersection.
valid){
195 if (!volumeExits.empty()){
197 VolumeExit closestVolumeExit = (*volumeExits.begin()).second;
201 ATH_MSG_VERBOSE(
"[>>>>] The boundary surface has an associated layer, collect material from there");
203 double pathToExit = (closestVolumeExit.
vExit-lastPosition).
mag();
211 if (closestVolumeExit.
nVolume != &tvol && closestVolumeExit.
nVolume) {
217 ATH_MSG_VERBOSE(
"[>>>>] No exit found from Volume '" << tvol.
volumeName() <<
"' - starting radius = " << lastPosition.perp() );
225 ATH_MSG_DEBUG(
"[>>>] Collecting materials from "<< collectedMaterial.size() <<
" layers");
227 auto cmIter = collectedMaterial.begin();
228 auto cmIterE = collectedMaterial.end();
229 for ( ; cmIter != cmIterE; ++cmIter ){
230 m_materialMapper->recordMaterialHit(cmIter->second, cmIter->second.materialPosition());
231 m_accTinX0 += cmIter->second.steplengthInX0();
232 int layerIndex = cmIter->second.associatedLayer() ? cmIter->second.associatedLayer()->layerIndex().value() : 0;
233 ATH_MSG_DEBUG(
"[>>>] Accumulate pathLength/X0 on layer with index " << layerIndex <<
" - t/X0 (total so far) = " << cmIter->second.steplengthInX0() <<
" (" <<
m_accTinX0 <<
")");
235 std::string surfaceType =
236 cmIter->second.associatedLayer()->surfaceRepresentation().type() ==
238 ?
"Cylinder at radius = "
239 :
"Disc at z-position = ";
240 std::string layerType =
241 cmIter->second.associatedLayer()->surfaceArray() ?
"Active "
244 cmIter->second.associatedLayer()->surfaceRepresentation().type() ==
246 ? cmIter->second.associatedLayer()
247 ->surfaceRepresentation()
250 : cmIter->second.associatedLayer()
251 ->surfaceRepresentation()
256 ATH_MSG_DEBUG(
" Distance to origin is " << cmIter->second.materialPosition().mag() );