31 std::unique_ptr<const Logger> logger)
45 std::unique_ptr<const Logger> newLogger) {
46 m_logger = std::move(newLogger);
49 std::shared_ptr<Acts::TrackingVolume>
52 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
53 std::shared_ptr<const VolumeBounds> volumeBounds,
55 const std::string& volumeName,
BinningType bType)
const {
59 std::unique_ptr<const LayerArray> layerArray =
nullptr;
76 if (cylinderBounds ==
nullptr) {
78 "[!] Problem: given bounds are not cylindrical - return nullptr");
83 if (!layers.empty()) {
93 if (not estimateAndCheckDimension(gctx, layers, cylinderBounds, transform,
94 rMinRaw, rMaxRaw, zMinRaw, zMaxRaw,
97 "[!] Problem with given dimensions - return nullptr and "
98 "delete provided objects");
100 if (volumeBounds ==
nullptr) {
101 delete cylinderBounds;
107 (not idTrf ? transform.translation().z() : 0.) +
108 (cylinderBounds !=
nullptr
111 double zMax = (not idTrf ? transform.translation().z() : 0.) +
112 (cylinderBounds !=
nullptr
116 double rMin = cylinderBounds !=
nullptr
119 double rMax = cylinderBounds !=
nullptr
124 "Filling the layers into an appropriate layer array - with "
129 layerArray = (bValue ==
binR)
130 ? m_cfg.layerArrayCreator->layerArray(gctx, layers, rMin,
132 : m_cfg.layerArrayCreator->layerArray(gctx, layers, zMin,
133 zMax, bType, bValue);
137 std::shared_ptr<const VolumeBounds> volumeBoundsFinal =
138 volumeBounds.get() !=
nullptr
140 : std::shared_ptr<const VolumeBounds>(cylinderBounds);
143 std::move(layerArray),
nullptr, mtvVector,
147 "Created cylindrical volume at z-position :" << tVolume->center().z());
148 ACTS_VERBOSE(
" created bounds : " << tVolume->volumeBounds());
153 std::shared_ptr<Acts::TrackingVolume>
157 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
158 double rMax,
double zMin,
double zMax,
const std::string& volumeName,
164 ACTS_VERBOSE(
"Create cylindrical TrackingVolume '" << volumeName <<
"'.");
165 ACTS_VERBOSE(
" -> with given dimensions of (rMin/rMax/zMin/Max) = "
166 << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
169 if (zMin > zMax || rMin > rMax) {
171 << ((zMin > zMax) ?
" zMin > zMax (" :
" rMin > rMax (")
172 << ((zMin > zMax) ? zMin : rMin) <<
" > "
173 << ((zMin > zMax) ? zMax : rMax) <<
" ) - return 0");
178 double halflengthZ = 0.5 * (zMax - zMin);
179 double zPosition = 0.5 * (zMin + zMax);
180 zPosition =
std::abs(zPosition) < 0.1 ? 0. : zPosition;
188 return createTrackingVolume(gctx, layers, volumeMaterial,
193 std::shared_ptr<Acts::TrackingVolume>
196 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
197 double rMax,
double zMin,
double zMax,
unsigned int materialLayers,
198 bool cylinder,
const std::string& volumeName)
const {
201 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
202 ACTS_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
205 double min = cylinder ? rMin : zMin;
206 double max = cylinder ? rMax : zMax;
209 std::vector<double> layerPositions;
210 if (materialLayers > 1) {
211 double step = cylinder ? (max -
min) / (materialLayers - 1)
212 : (max -
min) / (materialLayers - 1);
213 for (
unsigned int il = 0; il < materialLayers; ++il) {
214 layerPositions.push_back(min + il * step);
217 layerPositions.push_back(0.5 * (min + max));
221 return createGapTrackingVolume(gctx, mtvVector, volumeMaterial, rMin, rMax,
222 zMin, zMax, layerPositions, cylinder,
226 std::shared_ptr<Acts::TrackingVolume>
229 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
230 double rMax,
double zMin,
double zMax,
231 const std::vector<double>& layerPositions,
bool cylinder,
232 const std::string& volumeName,
BinningType bType)
const {
235 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
236 ACTS_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
240 layers.reserve(layerPositions.size());
242 std::vector<double>::const_iterator layerPropIter = layerPositions.begin();
243 std::vector<double>::const_iterator layerPropEnd = layerPositions.end();
244 for (; layerPropIter != layerPropEnd; ++layerPropIter) {
248 double zMinLayer = zMin;
249 double zMaxLayer = zMax;
251 layers.push_back(createCylinderLayer(
252 0.5 * (zMinLayer + zMaxLayer), (*layerPropIter),
253 std::abs(0.5 * (zMaxLayer - zMinLayer)), m_cfg.passiveLayerThickness,
254 m_cfg.passiveLayerPhiBins, m_cfg.passiveLayerRzBins));
258 double rMinLayer = rMin;
259 double rMaxLayer = rMax;
261 layers.push_back(createDiscLayer(
262 (*layerPropIter), rMinLayer, rMaxLayer, m_cfg.passiveLayerThickness,
263 m_cfg.passiveLayerPhiBins, m_cfg.passiveLayerRzBins));
267 return createTrackingVolume(gctx, layers, mtvVector, volumeMaterial, rMin,
268 rMax, zMin, zMax, volumeName, bType);
271 std::shared_ptr<Acts::TrackingVolume>
275 if (volumes.size() <= (size_t)1) {
277 "None (only one) TrackingVolume given to create container "
278 "volume (min required: 2) - returning 0 ");
282 std::string volumeName =
"{ ";
283 ACTS_VERBOSE(
"[start] Creating a container volume with " << volumes.size()
287 auto firstVolume = volumes.begin();
288 auto lastVolume = volumes.end();
290 for (
size_t ivol = 0; firstVolume != lastVolume; ++firstVolume, ++ivol) {
292 <<
") is : " << (*firstVolume)->volumeName());
293 ACTS_VERBOSE(
" at position : " << (*firstVolume)->center().x() <<
", "
294 << (*firstVolume)->center().y() <<
", "
295 << (*firstVolume)->center().z());
297 ACTS_VERBOSE(
" with bounds : " << (*firstVolume)->volumeBounds());
299 volumeName += (*firstVolume)->volumeName();
300 if (ivol + 1 < volumes.size()) {
307 firstVolume = volumes.begin();
310 if (firstVolume == lastVolume) {
312 "Only one TrackingVolume given to create Top level volume "
313 "(min required: 2) - returning 0 ");
319 &((*firstVolume)->volumeBounds()));
322 &((*lastVolume)->volumeBounds()));
324 if ((firstVolumeBounds ==
nullptr) || (lastVolumeBounds ==
nullptr)) {
326 "VolumeBounds given are not of type: CylinderVolumeBounds "
327 "(required) - returning 0 ");
339 double rGlueMin = 0.;
344 zMin = (*firstVolume)->center().z() -
346 zMax = (*firstVolume)->center().z() +
354 zMin = (*firstVolume)->center().z() -
356 zMax = (*lastVolume)->center().z() +
358 zSep1 = (*firstVolume)->center().z() +
365 double zPos = 0.5 * (zMin + zMax);
374 ACTS_VERBOSE(
"Container volume bounds are " << (*topVolumeBounds));
377 std::shared_ptr<const TrackingVolumeArray> volumeArray =
378 (rCase) ? m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
380 : m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
381 gctx, volumes,
binZ);
382 if (volumeArray ==
nullptr) {
384 "Creation of TrackingVolume array did not succeed - returning 0 ");
385 delete topVolumeBounds;
394 if (not interGlueTrackingVolume(gctx, topVolume, rCase, rMin, rGlueMin, rMax,
397 "Problem with inter-glueing of TrackingVolumes (needed) - "
403 "[ end ] return newly created container : " << topVolume->volumeName());
413 const Transform3D& transform,
double& rMinClean,
double& rMaxClean,
414 double& zMinClean,
double& zMaxClean,
BinningValue& bValue,
419 <<
" layers to gather overall dimensions");
420 if (cylinderVolumeBounds !=
nullptr)
421 ACTS_DEBUG(
"Cylinder volume bounds are given: (rmin/rmax/dz) = "
429 double layerRmin = 10e10;
430 double layerRmax = 0.;
431 double layerZmin = 10e10;
432 double layerZmax = -10e10;
441 for (
auto& layerIter : layers) {
443 double currentRmin = 0.;
444 double currentRmax = 0.;
445 double currentZmin = 0.;
446 double currentZmax = 0.;
449 &(layerIter->surfaceRepresentation()).bounds());
451 if (cylBounds !=
nullptr) {
455 double centerZ = (layerIter->surfaceRepresentation()).center(gctx).z();
457 currentRmin = currentR - (0.5 * (layerIter)->
thickness());
458 currentRmax = currentR + (0.5 * (layerIter)->
thickness());
464 &(layerIter->surfaceRepresentation()).bounds());
465 if (discBounds !=
nullptr) {
467 double centerZ = (layerIter->surfaceRepresentation()).center(gctx).z();
468 currentRmin = discBounds->
rMin();
469 currentRmax = discBounds->
rMax();
470 currentZmin = centerZ - (0.5 * (layerIter)->
thickness());
471 currentZmax = centerZ + (0.5 * (layerIter)->
thickness());
474 rMinClean =
std::min(rMinClean, currentRmin);
475 rMaxClean =
std::max(rMaxClean, currentRmax);
476 zMinClean =
std::min(zMinClean, currentZmin);
477 zMaxClean =
std::max(zMaxClean, currentZmax);
479 layerRmin =
std::min(layerRmin, currentRmin);
480 layerRmax =
std::max(layerRmax, currentRmax);
481 layerZmin =
std::min(layerZmin, currentZmin);
482 layerZmax =
std::max(layerZmax, currentZmax);
489 "Estimate/check CylinderVolumeBounds from/w.r.t. enclosed "
490 "layers + envelope covers");
492 double zEstFromLayerEnv = 0.5 * ((layerZmax) + (layerZmin));
493 double halflengthFromLayer = 0.5 *
std::abs((layerZmax) - (layerZmin));
495 bool concentric = (zEstFromLayerEnv * zEstFromLayerEnv < 0.001);
501 if ((cylinderVolumeBounds ==
nullptr) && idTrf) {
503 cylinderVolumeBounds =
506 vtransform = concentric
509 }
else if ((cylinderVolumeBounds !=
nullptr) && idTrf && !concentric) {
511 }
else if (not idTrf && (cylinderVolumeBounds ==
nullptr)) {
513 cylinderVolumeBounds =
517 ACTS_VERBOSE(
" -> dimensions from layers (rMin/rMax/zMin/zMax) = "
518 << layerRmin <<
" / " << layerRmax <<
" / " << layerZmin <<
" / "
521 double zFromTransform = not idTrf ? transform.translation().z() : 0.;
523 " -> while created bounds are (rMin/rMax/zMin/zMax) = "
533 if (cylinderVolumeBounds !=
nullptr) {
546 "Provided layers are not contained by volume ! Bailing out. ");
549 << zFromTransform - cylinderVolumeBounds->
get(
551 <<
", layerZmin: " << layerZmin);
553 << zFromTransform + cylinderVolumeBounds->
get(
555 <<
", layerZmax: " << layerZmax);
558 <<
", layerRmin: " << layerRmin);
561 <<
", layerRmax: " << layerRmax);
566 ACTS_VERBOSE(
"Created/Checked " << *cylinderVolumeBounds);
571 const GeometryContext& gctx,
const std::shared_ptr<TrackingVolume>& tVolume,
572 bool rBinned,
double rMin,
double rGlueMin,
double rMax,
double zMin,
574 ACTS_VERBOSE(
"Glue contained TrackingVolumes of container '"
575 << tVolume->volumeName() <<
"'.");
578 if (tVolume->confinedVolumes()) {
584 auto& volumes = tVolume->confinedVolumes()->arrayObjects();
589 for (
auto& vol : volumes)
590 ACTS_VERBOSE(
"[" << ivol++ <<
"] - volume : " << vol->volumeName());
593 auto tVolIter = volumes.begin();
594 auto tVolFirst = volumes.begin();
595 auto tVolLast = volumes.end();
597 auto tVolEnd = volumes.end();
609 for (; tVolIter != tVolEnd;) {
611 ACTS_VERBOSE(
"r-binning: Processing volume [" << ivol++ <<
"]");
613 std::shared_ptr<TrackingVolume> tVol =
615 if (tVolIter == tVolFirst) {
621 if (tVolIter == tVolLast) {
625 std::shared_ptr<TrackingVolume> tVol1 =
627 std::shared_ptr<TrackingVolume> tVol2 =
636 for (; tVolIter != tVolEnd;) {
639 << (*tVolIter)->volumeName() <<
"'.");
640 std::shared_ptr<TrackingVolume> tVol =
642 if (tVolIter == tVolFirst) {
647 if (tVolIter == tVolLast) {
651 std::shared_ptr<TrackingVolume> tVol1 =
653 std::shared_ptr<TrackingVolume> tVol2 =
662 if (!glueVolumesNegativeFace.empty()) {
664 std::shared_ptr<const TrackingVolumeArray> glueVolumesNegativeFaceArray =
665 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
666 gctx, glueVolumesNegativeFace,
binR);
669 glueVolumesNegativeFaceArray);
671 if (!glueVolumesPositiveFace.empty()) {
673 std::shared_ptr<const TrackingVolumeArray> glueVolumesPositiveFaceArray =
674 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
675 gctx, glueVolumesPositiveFace,
binR);
678 glueVolumesPositiveFaceArray);
680 if (!glueVolumesInnerTube.empty()) {
682 std::shared_ptr<const TrackingVolumeArray> glueVolumesInnerTubeArray =
683 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
684 gctx, glueVolumesInnerTube,
binZ);
688 if (!glueVolumesOuterTube.empty()) {
690 std::shared_ptr<const TrackingVolumeArray> glueVolumesOuterTubeArray =
691 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
692 gctx, glueVolumesOuterTube,
binZ);
697 ACTS_VERBOSE(
"[GV] Register " << glueVolumesNegativeFace.size()
698 <<
" volumes at face negativeFaceXY:");
699 for (tVolIter = glueVolumesNegativeFace.begin();
700 tVolIter != glueVolumesNegativeFace.end(); ++tVolIter)
701 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
702 ACTS_VERBOSE(
"[GV] Register " << glueVolumesPositiveFace.size()
703 <<
" volumes at face positiveFaceXY: ");
704 for (tVolIter = glueVolumesPositiveFace.begin();
705 tVolIter != glueVolumesPositiveFace.end(); ++tVolIter)
706 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
707 ACTS_VERBOSE(
"[GV] Register " << glueVolumesInnerTube.size()
708 <<
" volumes at face tubeInnerCover: ");
709 for (tVolIter = glueVolumesInnerTube.begin();
710 tVolIter != glueVolumesInnerTube.end(); ++tVolIter)
711 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
712 ACTS_VERBOSE(
"[GV] Register " << glueVolumesOuterTube.size()
713 <<
" volumes at face tubeOuterCover:");
714 for (tVolIter = glueVolumesOuterTube.begin();
715 tVolIter != glueVolumesOuterTube.end(); ++tVolIter)
716 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName());
724 const GeometryContext& gctx,
const std::shared_ptr<TrackingVolume>& tvolOne,
727 double zMin,
double zMax)
const {
730 tvolOne->glueVolumesDescriptor();
732 tvolTwo->glueVolumesDescriptor();
734 size_t volOneGlueVols =
736 ? gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects().size()
739 << tvolOne->volumeName() <<
"' has " << volOneGlueVols <<
" @ "
741 size_t volTwoGlueVols =
743 ? gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects().size()
746 << tvolTwo->volumeName() <<
"' has " << volTwoGlueVols <<
" @ "
752 ? gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects()[0]
756 ? gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects()[0]
764 if (volOneGlueVols <= 1 && volTwoGlueVols <= 1) {
766 ACTS_VERBOSE(
" glue : one[ " << glueVolOne->volumeName() <<
" @ "
767 << faceOne <<
" ]-to-one[ "
768 << glueVolTwo->volumeName() <<
" @ "
771 mutableGlueVolOne->glueTrackingVolume(gctx, faceOne,
772 mutableGlueVolTwo.get(), faceTwo);
774 }
else if (volOneGlueVols <= 1) {
777 << glueVolOne->volumeName() <<
" @ " << faceOne
778 <<
" ]-to-many[ " << tvolTwo->volumeName() <<
" @ " << faceTwo
782 mutableGlueVolOne->glueTrackingVolumes(gctx, faceOne, mutableFaceTwoVolumes,
784 }
else if (volTwoGlueVols <= 1) {
787 << tvolOne->volumeName() <<
" @ " << faceOne <<
" ]-to-one[ "
788 << glueVolTwo->volumeName() <<
" @ " << faceTwo <<
" ]");
791 mutableGlueVolTwo->glueTrackingVolumes(gctx, faceTwo, mutableFaceOneVolumes,
796 << tvolOne->volumeName() <<
" @ " << faceOne <<
" ]-to-many[ "
797 << tvolTwo->volumeName() <<
" @ " << faceTwo <<
" ]");
800 std::shared_ptr<const BoundarySurfaceT<TrackingVolume>> boundarySurface =
814 std::make_shared<CylinderBounds>(rGlueMin, 0.5 * (zMax - zMin));
815 std::shared_ptr<const Surface>
cSurface =
816 Surface::makeShared<CylinderSurface>(
transform, cBounds);
818 " creating a new cylindrical boundary surface "
820 << cSurface->bounds());
821 ACTS_VERBOSE(
" at " << cSurface->center(gctx).transpose());
823 std::make_shared<const BoundarySurfaceT<TrackingVolume>>(
824 std::move(cSurface), gvDescriptorOne.
glueVolumes(faceOne),
831 &tvolOne->volumeBounds());
832 double zPos = tvolOne->center().z();
840 std::shared_ptr<const Surface> dSurface =
841 Surface::makeShared<DiscSurface>(
transform, rMin, rMax);
843 " creating a new disc-like boundary surface "
845 << dSurface->bounds());
846 ACTS_VERBOSE(
" at " << dSurface->center(gctx).transpose());
848 std::make_shared<const BoundarySurfaceT<TrackingVolume>>(
849 std::move(dSurface), gvDescriptorOne.
glueVolumes(faceOne),
854 std::shared_ptr<const ISurfaceMaterial> boundaryMaterial =
nullptr;
856 ACTS_VERBOSE(
"New Boundary surface setting for countainers");
857 ACTS_VERBOSE(
" - at first volume: " << tvolOne->volumeName());
860 for (
auto& oneVolume :
861 gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects()) {
862 auto mutableOneVolume =
865 if (boundaryMaterial ==
nullptr) {
868 oneBSurface->surfaceRepresentation().surfaceMaterialSharedPtr();
870 mutableOneVolume->updateBoundarySurface(faceOne, boundarySurface);
872 << mutableOneVolume->volumeName());
874 ACTS_VERBOSE(
" - at second volume: " << tvolTwo->volumeName());
875 for (
auto& twoVolume :
876 gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects()) {
877 auto mutableTwoVolume =
880 if (boundaryMaterial ==
nullptr) {
883 twoBSurface->surfaceRepresentation().surfaceMaterialSharedPtr();
885 mutableTwoVolume->updateBoundarySurface(faceTwo, boundarySurface);
887 << mutableTwoVolume->volumeName());
891 if (boundaryMaterial !=
nullptr) {
893 ACTS_VERBOSE(
"- the new boundary surface has boundary material: ");
896 const_cast<Surface*
>(&(boundarySurface->surfaceRepresentation()));
907 ACTS_VERBOSE(
"Adding face volumes of face " << glueFace <<
" for the volume '"
908 << tvol->volumeName() <<
"'.");
912 if (gvDescriptor.glueVolumes(glueFace)) {
914 auto volIter = gvDescriptor.
glueVolumes(glueFace)->arrayObjects().begin();
915 auto volEnd = gvDescriptor.glueVolumes(glueFace)->arrayObjects().end();
916 for (; volIter != volEnd; ++volIter) {
917 ACTS_VERBOSE(
" -> adding : " << (*volIter)->volumeName());
918 vols.push_back(*volIter);
922 <<
" navigation volumes registered as glue volumes.");
925 ACTS_VERBOSE(
" -> adding only volume itself (at navigation level).");
926 vols.push_back(tvol);
930 std::shared_ptr<const Acts::Layer>
935 ACTS_VERBOSE(
"Creating a CylinderLayer at position " << z <<
" and radius "
941 BinUtility layerBinUtility(binsZ, z - halflengthZ, z + halflengthZ,
open,
946 ACTS_VERBOSE(
" -> Preparing the binned material with " << binsZ
953 layerBinUtilityPhiZ += layerBinUtility;
956 << binsPhi <<
" / " << binsZ <<
" bins in phi / Z. ");
963 transform, std::shared_ptr<const CylinderBounds>(cylinderBounds),
nullptr,
968 double z,
double rMin,
double rMax,
double thickness,
int binsPhi,
970 ACTS_VERBOSE(
"Creating a DiscLayer at position " << z <<
" and rMin/rMax "
971 << rMin <<
" / " << rMax);
979 ACTS_VERBOSE(
" -> Preparing the binned material with " << binsR
985 << binsPhi <<
" / " << binsR <<
" bins in phi / R. ");
993 std::shared_ptr<const DiscBounds>(discBounds),