32 declareInterface<ILayerArrayCreator>(
this);
39 const std::vector<Trk::CylinderLayer*>& cylLayersInput,
42 ATH_MSG_VERBOSE(
" build LayerArray with " << cylLayersInput.size() <<
" cylindrical material layers." );
46 std::vector<Trk::CylinderLayer*> cylLayers(cylLayersInput);
49 std::sort(cylLayers.begin(), cylLayers.end(), rSorter);
53 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> cylinderLayerArray =
nullptr;
54 std::vector< std::pair<std::shared_ptr<Trk::Layer>,
Amg::Vector3D> > layerOrderVector;
62 unsigned int layers = cylLayers.size();
64 for (
auto& layIter : cylLayers ) {
67 double currentR = layerSurface.
bounds().
r();
68 ATH_MSG_VERBOSE(
"equidistant : registering cylindrical MaterialLayer at radius : " << currentR );
69 layerOrderVector.emplace_back(std::shared_ptr<Layer>(layIter),
74 ATH_MSG_VERBOSE(
"equidistant : created a BinUtility as " << binUtility );
77 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
85 unsigned int layers = cylLayers.size();
87 double layerThickness = cylLayers[0]->thickness();
89 double radialStep = (rmax-rmin)/(
layers-1);
91 double navigationR = 0.;
92 double navLayerHalflengthZ = 0.;
96 for (
auto& layIter : cylLayers ) {
99 layerTransform = layerSurface.
transform().isApprox(Amg::Transform3D::Identity()) ?
nullptr : &layerSurface.
transform();
101 double currentR = layerSurface.
bounds().
r();
102 navigationR = currentR - 0.5*radialStep;
105 ATH_MSG_VERBOSE(
"bi-equidistant : creating cylindrical NavigationLayer at radius : " << navigationR );
106 auto navLayerSurface =
107 layerTransform ? std::make_unique<Trk::CylinderSurface>(
109 : std::make_unique<Trk::CylinderSurface>(
110 navigationR, navLayerHalflengthZ);
112 auto navLayer = std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface));
114 layerOrderVector.emplace_back(std::move(navLayer),
116 ATH_MSG_VERBOSE(
"bi-equidistant : registering cylindrical MaterialLayer at radius : " << currentR );
118 layerOrderVector.emplace_back(std::shared_ptr<Trk::Layer>(layIter),
123 ATH_MSG_VERBOSE(
"bi-equidistant : creating cylindrical NavigationLayer at radius : " << navigationR+radialStep);
124 auto navLayerSurfacFinal = layerTransform ?
125 std::make_unique<Trk::CylinderSurface>(
126 Amg::Transform3D(*layerTransform), navigationR+radialStep, navLayerHalflengthZ) :
127 std::make_unique<Trk::CylinderSurface>(navigationR+radialStep, navLayerHalflengthZ);
129 auto navLayer = std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfacFinal));
131 layerOrderVector.emplace_back(std::move(navLayer),
134 ATH_MSG_VERBOSE( layerOrderVector.size() <<
" cylindrical Layers (material + navigation) built. " );
137 double rMinBoundary = rmin-radialStep+0.5*layerThickness;
138 double rMaxBoundary = rmax+radialStep+0.5*layerThickness;
140 ATH_MSG_VERBOSE(
"bi-equidistant : created a BinUtility as " << binUtility );
143 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
150 std::vector<float> boundaries;
152 double halfLengthZ = 0;
156 boundaries.push_back(rmin);
159 for (
auto& layIter : cylLayers) {
162 layerTransform = layerSurface.
transform().isApprox(Amg::Transform3D::Identity()) ?
nullptr : &layerSurface.
transform();
166 double layerRadius = layerSurface.
bounds().
r();
167 double layerThickness = layIter->thickness();
169 double navLayerRadius = 0.5*( (layerRadius-0.5*layerThickness) + boundaries[boundaries.size()-1] );
170 auto navLayerSurface = layerTransform ?
171 std::make_unique<Trk::CylinderSurface>(
173 std::make_unique<Trk::CylinderSurface>(navLayerRadius, halfLengthZ);
175 cylinderLayer = checkAndReplaceEmptyLayer(layIter);
177 ATH_MSG_VERBOSE(
"arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadius );
178 layerOrderVector.emplace_back(
179 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
181 ATH_MSG_VERBOSE(
"arbitrary : registering cylindrical MaterialLayer at radius :" << layerRadius );
182 layerOrderVector.emplace_back(
183 std::shared_ptr<Trk::Layer>(cylinderLayer),
185 boundaries.push_back(layerRadius-0.5*layerThickness);
186 boundaries.push_back(layerRadius+0.5*layerThickness);
188 ATH_MSG_VERBOSE(
"arbitrary : empty layer configuration cancelled this building of navigation layer.");
192 double navLayerRadiusFinal = 0.5*(rmax+boundaries[boundaries.size()-1]);
193 auto navLayerSurfaceFinal = layerTransform ?
194 std::make_unique<Trk::CylinderSurface>(
196 std::make_unique<Trk::CylinderSurface>(navLayerRadiusFinal, halfLengthZ);
197 boundaries.push_back(rmax);
198 ATH_MSG_VERBOSE(
"arbitrary : creating cylindrical NavigationLayer at radius : " << navLayerRadiusFinal );
199 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
202 ATH_MSG_VERBOSE( layerOrderVector.size() <<
" cylindrical Layers (material + navigation) built. " );
205 ATH_MSG_VERBOSE(
"arbitrary : created a BinUtility as " << binUtility );
208 cylinderLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
216 return cylinderLayerArray;
221 const std::vector<Trk::DiscLayer*>& discLayersInput,
227 ATH_MSG_VERBOSE(
" build LayerArray with " << discLayersInput.size() <<
" disc-like material layers." );
231 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> discLayerArray =
nullptr;
232 std::vector<std::pair<std::shared_ptr<Trk::Layer>,
Amg::Vector3D>> layerOrderVector;
235 std::vector<Trk::DiscLayer*> discLayers(discLayersInput);
238 std::sort(discLayers.begin(), discLayers.end(), zSorter);
248 size_t layers = discLayers.size();
251 discLayer = checkAndReplaceEmptyLayer(layIter);
254 ATH_MSG_VERBOSE(
"equidistant : registering disc-like MaterialLayer at z-Position : " << layerSurface.
center().z() );
255 layerOrderVector.emplace_back(std::shared_ptr<Layer>(discLayer),
260 ATH_MSG_VERBOSE(
"equidistant : created a BinUtility as " << binUtility );
263 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
271 unsigned int layers = discLayers.size();
273 double layerThickness = discLayers[0]->thickness();
281 double navigationZ = 0.;
283 for (
auto& layIter : discLayers) {
286 double currentZ = layerSurface.
center().z();
288 navigationZ = currentZ - 0.5*(zStep);
290 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
292 ATH_MSG_VERBOSE(
"bi-equidistant : creating disc-like NavigationLayer at z-Position : " << navigationZ );
294 layerOrderVector.emplace_back(
295 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
300 minR = dbounds->
rMin();
301 maxR = dbounds->
rMax();
307 ATH_MSG_VERBOSE(
"bi-equidistant : registering disc-like MaterialLayer at z-Position : " << currentZ );
308 layerOrderVector.emplace_back(std::shared_ptr<Trk::Layer>(layIter),
312 ATH_MSG_VERBOSE(
"bi-equidistant : creating disc-like NavigationLayer at z-Position : " << navigationZ + zStep );
314 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
316 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
319 ATH_MSG_VERBOSE( layerOrderVector.size() <<
" disc Layers (material + navigation) built. " );
322 double zminBoundary =
zmin-zStep+0.5*layerThickness;
323 double zmaxBoundary =
zmax+zStep+0.5*layerThickness;
325 ATH_MSG_VERBOSE(
"bi-equidistant : created a BinUtility as " << binUtility );
328 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
335 std::vector<float> boundaries;
342 boundaries.push_back(
zmin);
345 for (
auto& layIter : discLayers ) {
351 double layInnerR = dbounds->
rMin();
352 double layOuterR = dbounds->
rMax();
353 minR = (layInnerR < minR) ? layInnerR : minR;
354 maxR = (layOuterR > maxR) ? layOuterR : maxR;
360 double layerPositionZ = layerSurface.
center().z();
361 double layerThickness = layIter->thickness();
363 double navLayerPositionZ = 0.5*((layerPositionZ-0.5*layerThickness)+boundaries[boundaries.size()-1]);
367 auto navLayerSurface = std::make_unique<Trk::DiscSurface>(navLayerTransform, minR, maxR);
370 discLayer = checkAndReplaceEmptyLayer(layIter);
372 ATH_MSG_VERBOSE(
"arbitrary : creating disc-like NavigationLayer at z-Position : " << navLayerPositionZ );
373 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
375 ATH_MSG_VERBOSE(
"arbitrary : registering disc-like MaterialLayer at z-Position : " << layerPositionZ );
376 layerOrderVector.emplace_back(
377 std::shared_ptr<Trk::Layer>(discLayer),
379 boundaries.push_back(layerPositionZ-0.5*layerThickness);
380 boundaries.push_back(layerPositionZ+0.5*layerThickness);
382 ATH_MSG_VERBOSE(
"arbitrary : empty layer configuration cancelled this building of navigation layer.");
386 double navLayerPositionZFinal = 0.5*(
zmax+boundaries[boundaries.size()-1]);
389 auto navLayerSurfaceFinal = std::make_unique<Trk::DiscSurface>(navLayerTransformFinal, minR, maxR);
390 ATH_MSG_VERBOSE(
"arbitrary : creating disc-like NavigationLayer at z-Position : " << navLayerPositionZFinal );
391 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
393 ATH_MSG_VERBOSE( layerOrderVector.size() <<
" disc Layers (material + navigation) built. " );
395 boundaries.push_back(
zmax);
398 ATH_MSG_VERBOSE(
"arbitrary : created a BinUtility as " << binUtility );
402 discLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
410 return discLayerArray;
415 const std::vector<Trk::PlaneLayer*>& planeLayersInput,
421 ATH_MSG_VERBOSE(
" build LayerArray with " << planeLayersInput.size() <<
" plane-like material layers." );
424 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> planeLayerArray =
nullptr;
425 std::vector< std::pair< std::shared_ptr<Trk::Layer>,
Amg::Vector3D> > layerOrderVector;
429 std::vector<Trk::PlaneLayer*> planeLayers(planeLayersInput);
431 auto sortBegin = planeLayers.begin();
432 auto sortEnd = planeLayers.end();
438 ATH_MSG_WARNING(
"Plane Layers can only be sorted in x/y/z. Returning 0.");
444 auto layIter = planeLayers.begin();
452 unsigned int layers = planeLayers.size();
454 for ( ; layIter != planeLayers.end(); ++layIter) {
457 ATH_MSG_VERBOSE(
"equidistant : registering plane-like MaterialLayer at position : " << layerSurface.
center() );
459 layerOrderVector.emplace_back(
460 std::shared_ptr<Layer>(*layIter),
466 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
474 unsigned int layers = planeLayers.size();
476 double posStep = (posmax-posmin)/(
layers+1);
478 double currentPos = posmin + posStep;
479 double lastPos = posmin;
481 double minHalfX = 0.;
482 double maxHalfX = 0.;
485 double layerThickness = 0.;
488 for ( ; layIter != planeLayers.end() ; ++layIter) {
513 layerThickness = ((*layIter)->thickness() > layerThickness ) ? (*layIter)->thickness() : layerThickness;
516 double navigationPos = 0.5*(currentPos+lastPos);
517 double navigationX = (bv ==
Trk::binX) ? navigationPos : 0.;
518 double navigationY = (bv ==
Trk::binY) ? navigationPos : 0.;
519 double navigationZ = (bv ==
Trk::binZ) ? navigationPos : 0.;
522 std::unique_ptr<Trk::PlaneSurface> navLayerSurface =
nullptr;
525 if (std::abs(minHalfX)<10
e-5) {
526 navLayerSurface = std::make_unique<Trk::PlaneSurface>(navLayerTransform,
530 navLayerSurface = std::make_unique<Trk::PlaneSurface>(navLayerTransform,
536 ATH_MSG_VERBOSE(
"bi-equidistant : creating plane-like NavigationLayer at position : " << navigationX );
538 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
541 lastPos = currentPos;
544 ATH_MSG_VERBOSE(
"bi-equidistant : registering plane-like MaterialLayer at position : " << currentPos );
545 layerOrderVector.emplace_back(
546 std::shared_ptr<Trk::Layer>(*layIter),
550 currentPos += posStep;
554 double navigationPosFinal = 0.5*(currentPos+lastPos);
555 double navigationXFinal = (bv ==
Trk::binX) ? navigationPosFinal : 0.;
556 double navigationYFinal = (bv ==
Trk::binY) ? navigationPosFinal : 0.;
557 double navigationZFinal = (bv ==
Trk::binZ) ? navigationPosFinal : 0.;
561 auto navLayerSurface = (std::abs(minHalfX)<10
e-5) ?
562 std::make_unique<Trk::PlaneSurface>(navLayerTransform, maxHalfX,halfY) :
563 std::make_unique<Trk::PlaneSurface>(navLayerTransform, minHalfX, maxHalfX, halfY);
565 ATH_MSG_VERBOSE(
"bi-equidistant : creating plane-like NavigationLayer at position : " << navLayerSurface->center() );
567 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
574 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
582 std::vector<float> boundaries;
583 boundaries.push_back(posmin);
585 double minHalfX = 0.;
586 double maxHalfX = 0.;
590 for ( ; layIter != planeLayers.end(); ++layIter) {
616 layerCenter = layerSurface.
center();
617 double layerPosition = layerCenter[bv];
619 double layerThickness = (*layIter)->thickness();
621 boundaries.push_back(layerPosition-0.5*layerThickness);
622 double navLayerPositionX = (bv ==
Trk::binX) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.x();
623 double navLayerPositionY = (bv ==
Trk::binY) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.y();
624 double navLayerPositionZ = (bv ==
Trk::binZ) ? 0.5*(layerPosition+boundaries[boundaries.size()-1]) : layerCenter.z();
625 Amg::Translation3D navLayerPosition(navLayerPositionX,navLayerPositionY,navLayerPositionZ);
628 auto navLayerSurface = (std::abs(minHalfX)<10
e-5) ?
629 std::make_unique<Trk::PlaneSurface>( navLayerTransform, maxHalfX, halfY ) :
630 std::make_unique<Trk::PlaneSurface>( navLayerTransform, minHalfX, maxHalfX, halfY );
631 ATH_MSG_VERBOSE(
"arbitrary : creating plane-like NavigationLayer at position : " << navLayerPositionX );
632 layerOrderVector.emplace_back(
633 std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurface)),
634 Amg::Vector3D(navLayerPositionX, navLayerPositionY, navLayerPositionZ));
636 boundaries.push_back(layerPosition+0.5*layerThickness);
638 layerOrderVector.emplace_back(
639 std::shared_ptr<Trk::Layer>(*layIter),
644 double navLayerPositionXFinal = (bv ==
Trk::binX) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.x();
645 double navLayerPositionYFinal = (bv ==
Trk::binY) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.y();
646 double navLayerPositionZFinal = (bv ==
Trk::binZ) ? 0.5*(posmax+boundaries[boundaries.size()-1]) : layerCenter.z();
647 Amg::Translation3D navLayerPositionFinal(navLayerPositionXFinal,navLayerPositionYFinal,navLayerPositionZFinal);
650 auto navLayerSurfaceFinal = (std::abs(minHalfX)<10
e-5) ?
651 std::make_unique<Trk::PlaneSurface>( navLayerTransformFinal, maxHalfX, halfY ) :
652 std::make_unique<Trk::PlaneSurface>( navLayerTransformFinal, minHalfX, maxHalfX, halfY );
653 ATH_MSG_VERBOSE(
"arbitrary : creating plane-like NavigationLayer at position : " << 0.5*(posmax+boundaries[boundaries.size()-1]) );
654 layerOrderVector.emplace_back(std::make_shared<Trk::NavigationLayer>(std::move(navLayerSurfaceFinal)),
655 Amg::Vector3D(navLayerPositionXFinal, navLayerPositionYFinal, navLayerPositionZFinal));
657 ATH_MSG_VERBOSE( layerOrderVector.size() <<
" plane Layers (material + navigation) built. " );
662 planeLayerArray = std::make_unique<Trk::BinnedArray1D<Trk::Layer>>(layerOrderVector, binUtility);
669 return planeLayerArray;
675 if (m_emptyLayerMode){
678 " replacing dummyMaterial layer with "
679 << (m_emptyLayerMode > 1 ?
" nothing" :
" NavigationLayer."));