105 std::map<double, Trk::AssociatedMaterial> collectedMaterial;
118 for (
auto& lCandidate : layerIntersections ) {
121 double pathLength = lCandidate.intersection.pathLength;
123 if (layer->layerMaterialProperties()){
125 const Trk::MaterialProperties* mprop = layer->layerMaterialProperties()->fullMaterial(lCandidate.intersection.position);
127 double stepLength = mprop->
thickness()*fabs(layer->surfaceRepresentation().pathCorrection(lCandidate.intersection.position,direction));
128 collectedMaterial[pathLength] =
Trk::AssociatedMaterial(lCandidate.intersection.position, mprop, stepLength, &tvol, layer);
133 Amg::Vector3D lastPosition = !collectedMaterial.empty() ? collectedMaterial.rbegin()->second.materialPosition() : (position + direction.unit());
137 if (!boundaryIntersections.empty()){
139 lastPosition = boundaryIntersections.begin()->intersection.position;
145 double pathLength = (lastPosition-position).
mag();
158 std::map<double, std::pair<const Trk::Layer*, Amg::Vector3D> > intersectedLayers;
164 std::span<Trk::Layer const * const> layers = layerArray->
arrayObjects();
165 auto layIter = layers.begin();
166 auto layIterE = layers.end();
167 for ( ; layIter != layIterE; ++layIter){
168 if ( (*layIter)->layerMaterialProperties() ){
169 Trk::Intersection lsIntersection = (*layIter)->surfaceRepresentation().straightLineIntersection(position, direction,
true,
true);
170 if (lsIntersection.
valid){
171 intersectedLayers[lsIntersection.
pathLength] = std::pair<const Trk::Layer*, Amg::Vector3D>(*layIter,lsIntersection.
position);
174 Amg::Vector3D mposition = (*layIter)->surfaceRepresentation().transform().inverse()*lsIntersection.
position;
177 double stepLength = mprop->
thickness()*fabs((*layIter)->surfaceRepresentation().pathCorrection(lsIntersection.
position,direction));
195 Amg::Vector3D lastPosition = !intersectedLayers.empty() ? (*(--(intersectedLayers.end()))).second.second : position;
197 std::map<double, Trk::VolumeExit > volumeExits;
200 for (
size_t ib = 0; ib < bSurfaces.size(); ++ib){
202 if ( !bSurfaces[ib]->surfaceRepresentation().isOnSurface(lastPosition,
true, 0.1, 0.1) ){
203 Trk::Intersection evIntersection = bSurfaces[ib]->surfaceRepresentation().straightLineIntersection(lastPosition, direction,
true,
true);
206 if (evIntersection.
valid){
218 if (!volumeExits.empty()){
220 VolumeExit closestVolumeExit = (*volumeExits.begin()).second;
224 ATH_MSG_VERBOSE(
"[>>>>] The boundary surface has an associated layer, collect material from there");
226 double pathToExit = (closestVolumeExit.
vExit-lastPosition).
mag();
234 if (closestVolumeExit.
nVolume != &tvol && closestVolumeExit.
nVolume) {
240 ATH_MSG_VERBOSE(
"[>>>>] No exit found from Volume '" << tvol.
volumeName() <<
"' - starting radius = " << lastPosition.perp() );
248 ATH_MSG_DEBUG(
"[>>>] Collecting materials from "<< collectedMaterial.size() <<
" layers");
250 auto cmIter = collectedMaterial.begin();
251 auto cmIterE = collectedMaterial.end();
252 for ( ; cmIter != cmIterE; ++cmIter ){
253 m_materialMapper->recordMaterialHit(cmIter->second, cmIter->second.materialPosition());
254 m_accTinX0 += cmIter->second.steplengthInX0();
255 int layerIndex = cmIter->second.associatedLayer() ? cmIter->second.associatedLayer()->layerIndex().value() : 0;
256 ATH_MSG_DEBUG(
"[>>>] Accumulate pathLength/X0 on layer with index " << layerIndex <<
" - t/X0 (total so far) = " << cmIter->second.steplengthInX0() <<
" (" <<
m_accTinX0 <<
")");
258 std::string surfaceType =
259 cmIter->second.associatedLayer()->surfaceRepresentation().type() ==
261 ?
"Cylinder at radius = "
262 :
"Disc at z-position = ";
263 std::string layerType =
264 cmIter->second.associatedLayer()->surfaceArray() ?
"Active "
267 cmIter->second.associatedLayer()->surfaceRepresentation().type() ==
269 ? cmIter->second.associatedLayer()
270 ->surfaceRepresentation()
273 : cmIter->second.associatedLayer()
274 ->surfaceRepresentation()
279 ATH_MSG_DEBUG(
" Distance to origin is " << cmIter->second.materialPosition().mag() );