33 std::unique_ptr<const Logger> logger)
47 std::unique_ptr<const Logger> newLogger) {
48 m_logger = std::move(newLogger);
51 std::shared_ptr<Acts::TrackingVolume>
54 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
55 std::shared_ptr<const VolumeBounds> volumeBounds,
57 std::shared_ptr<const Transform3D>
transform,
const std::string& volumeName,
62 std::unique_ptr<const LayerArray> layerArray =
nullptr;
74 if (cylinderBounds ==
nullptr) {
76 "[!] Problem: given bounds are not cylindrical - return nullptr");
81 if (!layers.empty()) {
91 if (not estimateAndCheckDimension(gctx, layers, cylinderBounds, transform,
92 rMinRaw, rMaxRaw, zMinRaw, zMaxRaw,
95 "[!] Problem with given dimensions - return nullptr and "
96 "delete provided objects");
98 if (volumeBounds ==
nullptr) {
99 delete cylinderBounds;
105 (transform ? transform->translation().z() : 0.) +
106 (cylinderBounds !=
nullptr
109 double zMax = (transform ? transform->translation().z() : 0.) +
110 (cylinderBounds !=
nullptr
114 double rMin = cylinderBounds !=
nullptr
117 double rMax = cylinderBounds !=
nullptr
122 "Filling the layers into an appropriate layer array - with "
127 layerArray = (bValue ==
binR)
128 ? m_cfg.layerArrayCreator->layerArray(gctx, layers, rMin,
130 : m_cfg.layerArrayCreator->layerArray(gctx, layers, zMin,
131 zMax, bType, bValue);
135 std::shared_ptr<const VolumeBounds> volumeBoundsFinal =
136 volumeBounds.get() !=
nullptr
138 : std::shared_ptr<const VolumeBounds>(cylinderBounds);
141 std::move(layerArray),
nullptr, mtvVector,
145 "Created cylindrical volume at z-position :" << tVolume->center().z());
146 ACTS_VERBOSE(
" created bounds : " << tVolume->volumeBounds());
151 std::shared_ptr<Acts::TrackingVolume>
155 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
156 double rMax,
double zMin,
double zMax,
const std::string& volumeName,
162 ACTS_VERBOSE(
"Create cylindrical TrackingVolume '" << volumeName <<
"'.");
163 ACTS_VERBOSE(
" -> with given dimensions of (rMin/rMax/zMin/Max) = "
164 << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
167 if (zMin > zMax || rMin > rMax) {
169 << ((zMin > zMax) ?
" zMin > zMax (" :
" rMin > rMax (")
170 << ((zMin > zMax) ? zMin : rMin) <<
" > "
171 << ((zMin > zMax) ? zMax : rMax) <<
" ) - return 0");
176 double halflengthZ = 0.5 * (zMax - zMin);
177 double zPosition = 0.5 * (zMin + zMax);
178 zPosition =
std::abs(zPosition) < 0.1 ? 0. : zPosition;
184 std::shared_ptr<const Transform3D> transform =
185 (zPosition != 0) ? std::make_shared<const Transform3D>(
189 return createTrackingVolume(gctx, layers, volumeMaterial,
194 std::shared_ptr<Acts::TrackingVolume>
197 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
198 double rMax,
double zMin,
double zMax,
unsigned int materialLayers,
199 bool cylinder,
const std::string& volumeName)
const {
202 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
203 ACTS_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
206 double min = cylinder ? rMin : zMin;
207 double max = cylinder ? rMax : zMax;
210 std::vector<double> layerPositions;
211 if (materialLayers > 1) {
212 double step = cylinder ? (max -
min) / (materialLayers - 1)
213 : (max -
min) / (materialLayers - 1);
214 for (
unsigned int il = 0; il < materialLayers; ++il) {
215 layerPositions.push_back(min + il * step);
218 layerPositions.push_back(0.5 * (min + max));
222 return createGapTrackingVolume(gctx, mtvVector, volumeMaterial, rMin, rMax,
223 zMin, zMax, layerPositions, cylinder,
227 std::shared_ptr<Acts::TrackingVolume>
230 std::shared_ptr<const IVolumeMaterial> volumeMaterial,
double rMin,
231 double rMax,
double zMin,
double zMax,
232 const std::vector<double>& layerPositions,
bool cylinder,
233 const std::string& volumeName,
BinningType bType)
const {
236 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
237 ACTS_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
241 layers.reserve(layerPositions.size());
243 std::vector<double>::const_iterator layerPropIter = layerPositions.begin();
244 std::vector<double>::const_iterator layerPropEnd = layerPositions.end();
245 for (; layerPropIter != layerPropEnd; ++layerPropIter) {
249 double zMinLayer = zMin;
250 double zMaxLayer = zMax;
252 layers.push_back(createCylinderLayer(
253 0.5 * (zMinLayer + zMaxLayer), (*layerPropIter),
254 std::abs(0.5 * (zMaxLayer - zMinLayer)), m_cfg.passiveLayerThickness,
255 m_cfg.passiveLayerPhiBins, m_cfg.passiveLayerRzBins));
259 double rMinLayer = rMin;
260 double rMaxLayer = rMax;
262 layers.push_back(createDiscLayer(
263 (*layerPropIter), rMinLayer, rMaxLayer, m_cfg.passiveLayerThickness,
264 m_cfg.passiveLayerPhiBins, m_cfg.passiveLayerRzBins));
268 return createTrackingVolume(gctx, layers, mtvVector, volumeMaterial, rMin,
269 rMax, zMin, zMax, volumeName, bType);
272 std::shared_ptr<Acts::TrackingVolume>
276 if (volumes.size() <= (size_t)1) {
278 "None (only one) TrackingVolume given to create container "
279 "volume (min required: 2) - returning 0 ");
283 std::string volumeName =
"{ ";
284 ACTS_VERBOSE(
"[start] Creating a container volume with " << volumes.size()
288 auto firstVolume = volumes.begin();
289 auto lastVolume = volumes.end();
291 for (
size_t ivol = 0; firstVolume != lastVolume; ++firstVolume, ++ivol) {
293 <<
") is : " << (*firstVolume)->volumeName());
294 ACTS_VERBOSE(
" at position : " << (*firstVolume)->center().x() <<
", "
295 << (*firstVolume)->center().y() <<
", "
296 << (*firstVolume)->center().z());
298 ACTS_VERBOSE(
" with bounds : " << (*firstVolume)->volumeBounds());
300 volumeName += (*firstVolume)->volumeName();
301 if (ivol + 1 < volumes.size()) {
308 firstVolume = volumes.begin();
311 if (firstVolume == lastVolume) {
313 "Only one TrackingVolume given to create Top level volume "
314 "(min required: 2) - returning 0 ");
320 &((*firstVolume)->volumeBounds()));
323 &((*lastVolume)->volumeBounds()));
325 if ((firstVolumeBounds ==
nullptr) || (lastVolumeBounds ==
nullptr)) {
327 "VolumeBounds given are not of type: CylinderVolumeBounds "
328 "(required) - returning 0 ");
340 double rGlueMin = 0.;
345 zMin = (*firstVolume)->center().z() -
347 zMax = (*firstVolume)->center().z() +
355 zMin = (*firstVolume)->center().z() -
357 zMax = (*lastVolume)->center().z() +
359 zSep1 = (*firstVolume)->center().z() +
366 double zPos = 0.5 * (zMin + zMax);
368 std::shared_ptr<const Transform3D> topVolumeTransform =
370 ? std::make_shared<const Transform3D>(
Translation3D(0., 0., zPos))
377 ACTS_VERBOSE(
"Container volume bounds are " << (*topVolumeBounds));
380 std::shared_ptr<const TrackingVolumeArray> volumeArray =
381 (rCase) ? m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
383 : m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
384 gctx, volumes,
binZ);
385 if (volumeArray ==
nullptr) {
387 "Creation of TrackingVolume array did not succeed - returning 0 ");
388 delete topVolumeBounds;
397 if (not interGlueTrackingVolume(gctx, topVolume, rCase, rMin, rGlueMin, rMax,
400 "Problem with inter-glueing of TrackingVolumes (needed) - "
406 "[ end ] return newly created container : " << topVolume->volumeName());
416 std::shared_ptr<const Transform3D>& transform,
double& rMinClean,
417 double& rMaxClean,
double& zMinClean,
double& zMaxClean,
422 <<
" layers to gather overall dimensions");
423 if (cylinderVolumeBounds !=
nullptr)
424 ACTS_DEBUG(
"Cylinder volume bounds are given: (rmin/rmax/dz) = "
432 double layerRmin = 10e10;
433 double layerRmax = 0.;
434 double layerZmin = 10e10;
435 double layerZmax = -10e10;
444 for (
auto& layerIter : layers) {
446 double currentRmin = 0.;
447 double currentRmax = 0.;
448 double currentZmin = 0.;
449 double currentZmax = 0.;
452 &(layerIter->surfaceRepresentation()).bounds());
454 if (cylBounds !=
nullptr) {
458 double centerZ = (layerIter->surfaceRepresentation()).center(gctx).z();
460 currentRmin = currentR - (0.5 * (layerIter)->
thickness());
461 currentRmax = currentR + (0.5 * (layerIter)->
thickness());
467 &(layerIter->surfaceRepresentation()).bounds());
468 if (discBounds !=
nullptr) {
470 double centerZ = (layerIter->surfaceRepresentation()).center(gctx).z();
471 currentRmin = discBounds->
rMin();
472 currentRmax = discBounds->
rMax();
473 currentZmin = centerZ - (0.5 * (layerIter)->
thickness());
474 currentZmax = centerZ + (0.5 * (layerIter)->
thickness());
492 "Estimate/check CylinderVolumeBounds from/w.r.t. enclosed "
493 "layers + envelope covers");
495 double zEstFromLayerEnv = 0.5 * ((layerZmax) + (layerZmin));
496 double halflengthFromLayer = 0.5 *
std::abs((layerZmax) - (layerZmin));
498 bool concentric = (zEstFromLayerEnv * zEstFromLayerEnv < 0.001);
501 if ((cylinderVolumeBounds ==
nullptr) && !
transform) {
503 cylinderVolumeBounds =
506 transform = concentric ? std::make_shared<const Transform3D>(
509 }
else if ((cylinderVolumeBounds !=
nullptr) && !transform && !concentric) {
510 transform = std::make_shared<const Transform3D>(
512 }
else if (transform && (cylinderVolumeBounds ==
nullptr)) {
514 cylinderVolumeBounds =
518 ACTS_VERBOSE(
" -> dimensions from layers (rMin/rMax/zMin/zMax) = "
519 << layerRmin <<
" / " << layerRmax <<
" / " << layerZmin <<
" / "
522 double zFromTransform = transform ? transform->translation().z() : 0.;
524 " -> while created bounds are (rMin/rMax/zMin/zMax) = "
534 if (cylinderVolumeBounds !=
nullptr) {
547 "Provided layers are not contained by volume ! Bailing out. ");
550 << zFromTransform - cylinderVolumeBounds->
get(
552 <<
", layerZmin: " << layerZmin);
554 << zFromTransform + cylinderVolumeBounds->
get(
556 <<
", layerZmax: " << layerZmax);
559 <<
", layerRmin: " << layerRmin);
562 <<
", layerRmax: " << layerRmax);
567 ACTS_VERBOSE(
"Created/Checked " << *cylinderVolumeBounds);
572 const GeometryContext& gctx,
const std::shared_ptr<TrackingVolume>& tVolume,
573 bool rBinned,
double rMin,
double rGlueMin,
double rMax,
double zMin,
575 ACTS_VERBOSE(
"Glue contained TrackingVolumes of container '"
576 << tVolume->volumeName() <<
"'.");
579 if (tVolume->confinedVolumes()) {
585 auto& volumes = tVolume->confinedVolumes()->arrayObjects();
590 for (
auto& vol : volumes)
591 ACTS_VERBOSE(
"[" << ivol++ <<
"] - volume : " << vol->volumeName());
594 auto tVolIter = volumes.begin();
595 auto tVolFirst = volumes.begin();
596 auto tVolLast = volumes.end();
598 auto tVolEnd = volumes.end();
610 for (; tVolIter != tVolEnd;) {
612 ACTS_VERBOSE(
"r-binning: Processing volume [" << ivol++ <<
"]");
614 std::shared_ptr<TrackingVolume> tVol =
616 if (tVolIter == tVolFirst) {
622 if (tVolIter == tVolLast) {
626 std::shared_ptr<TrackingVolume> tVol1 =
628 std::shared_ptr<TrackingVolume> tVol2 =
637 for (; tVolIter != tVolEnd;) {
640 << (*tVolIter)->volumeName() <<
"'.");
641 std::shared_ptr<TrackingVolume> tVol =
643 if (tVolIter == tVolFirst) {
648 if (tVolIter == tVolLast) {
652 std::shared_ptr<TrackingVolume> tVol1 =
654 std::shared_ptr<TrackingVolume> tVol2 =
663 if (!glueVolumesNegativeFace.empty()) {
665 std::shared_ptr<const TrackingVolumeArray> glueVolumesNegativeFaceArray =
666 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
667 gctx, glueVolumesNegativeFace,
binR);
670 glueVolumesNegativeFaceArray);
672 if (!glueVolumesPositiveFace.empty()) {
674 std::shared_ptr<const TrackingVolumeArray> glueVolumesPositiveFaceArray =
675 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
676 gctx, glueVolumesPositiveFace,
binR);
679 glueVolumesPositiveFaceArray);
681 if (!glueVolumesInnerTube.empty()) {
683 std::shared_ptr<const TrackingVolumeArray> glueVolumesInnerTubeArray =
684 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
685 gctx, glueVolumesInnerTube,
binZ);
689 if (!glueVolumesOuterTube.empty()) {
691 std::shared_ptr<const TrackingVolumeArray> glueVolumesOuterTubeArray =
692 m_cfg.trackingVolumeArrayCreator->trackingVolumeArray(
693 gctx, glueVolumesOuterTube,
binZ);
698 ACTS_VERBOSE(
"[GV] Register " << glueVolumesNegativeFace.size()
699 <<
" volumes at face negativeFaceXY:");
700 for (tVolIter = glueVolumesNegativeFace.begin();
701 tVolIter != glueVolumesNegativeFace.end(); ++tVolIter)
702 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
703 ACTS_VERBOSE(
"[GV] Register " << glueVolumesPositiveFace.size()
704 <<
" volumes at face positiveFaceXY: ");
705 for (tVolIter = glueVolumesPositiveFace.begin();
706 tVolIter != glueVolumesPositiveFace.end(); ++tVolIter)
707 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
708 ACTS_VERBOSE(
"[GV] Register " << glueVolumesInnerTube.size()
709 <<
" volumes at face tubeInnerCover: ");
710 for (tVolIter = glueVolumesInnerTube.begin();
711 tVolIter != glueVolumesInnerTube.end(); ++tVolIter)
712 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName() <<
"'");
713 ACTS_VERBOSE(
"[GV] Register " << glueVolumesOuterTube.size()
714 <<
" volumes at face tubeOuterCover:");
715 for (tVolIter = glueVolumesOuterTube.begin();
716 tVolIter != glueVolumesOuterTube.end(); ++tVolIter)
717 ACTS_VERBOSE(
" -> volume '" << (*tVolIter)->volumeName());
725 const GeometryContext& gctx,
const std::shared_ptr<TrackingVolume>& tvolOne,
728 double zMin,
double zMax)
const {
731 tvolOne->glueVolumesDescriptor();
733 tvolTwo->glueVolumesDescriptor();
735 size_t volOneGlueVols =
737 ? gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects().size()
740 << tvolOne->volumeName() <<
"' has " << volOneGlueVols <<
" @ "
742 size_t volTwoGlueVols =
744 ? gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects().size()
747 << tvolTwo->volumeName() <<
"' has " << volTwoGlueVols <<
" @ "
753 ? gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects()[0]
757 ? gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects()[0]
765 if (volOneGlueVols <= 1 && volTwoGlueVols <= 1) {
767 ACTS_VERBOSE(
" glue : one[ " << glueVolOne->volumeName() <<
" @ "
768 << faceOne <<
" ]-to-one[ "
769 << glueVolTwo->volumeName() <<
" @ "
772 mutableGlueVolOne->glueTrackingVolume(gctx, faceOne,
773 mutableGlueVolTwo.get(), faceTwo);
775 }
else if (volOneGlueVols <= 1) {
778 << glueVolOne->volumeName() <<
" @ " << faceOne
779 <<
" ]-to-many[ " << tvolTwo->volumeName() <<
" @ " << faceTwo
783 mutableGlueVolOne->glueTrackingVolumes(gctx, faceOne, mutableFaceTwoVolumes,
785 }
else if (volTwoGlueVols <= 1) {
788 << tvolOne->volumeName() <<
" @ " << faceOne <<
" ]-to-one[ "
789 << glueVolTwo->volumeName() <<
" @ " << faceTwo <<
" ]");
792 mutableGlueVolTwo->glueTrackingVolumes(gctx, faceTwo, mutableFaceOneVolumes,
797 << tvolOne->volumeName() <<
" @ " << faceOne <<
" ]-to-many[ "
798 << tvolTwo->volumeName() <<
" @ " << faceTwo <<
" ]");
801 std::shared_ptr<const BoundarySurfaceT<TrackingVolume>> boundarySurface =
805 std::shared_ptr<const Transform3D> transform =
nullptr;
808 auto pTransform = std::make_shared<const Transform3D>(
810 transform = pTransform;
816 std::make_shared<CylinderBounds>(rGlueMin, 0.5 * (zMax - zMin));
817 std::shared_ptr<const Surface>
cSurface =
818 Surface::makeShared<CylinderSurface>(
transform, cBounds);
820 " creating a new cylindrical boundary surface "
822 << cSurface->bounds());
823 ACTS_VERBOSE(
" at " << cSurface->center(gctx).transpose());
825 std::make_shared<const BoundarySurfaceT<TrackingVolume>>(
826 std::move(cSurface), gvDescriptorOne.
glueVolumes(faceOne),
833 &tvolOne->volumeBounds());
834 double zPos = tvolOne->center().z();
837 std::make_shared<const Transform3D>(
Translation3D(0, 0, zPos + zHL));
843 std::shared_ptr<const Surface> dSurface =
844 Surface::makeShared<DiscSurface>(
transform, rMin, rMax);
846 " creating a new disc-like boundary surface "
848 << dSurface->bounds());
849 ACTS_VERBOSE(
" at " << dSurface->center(gctx).transpose());
851 std::make_shared<const BoundarySurfaceT<TrackingVolume>>(
852 std::move(dSurface), gvDescriptorOne.
glueVolumes(faceOne),
857 std::shared_ptr<const ISurfaceMaterial> boundaryMaterial =
nullptr;
859 ACTS_VERBOSE(
"New Boundary surface setting for countainers");
860 ACTS_VERBOSE(
" - at first volume: " << tvolOne->volumeName());
863 for (
auto& oneVolume :
864 gvDescriptorOne.
glueVolumes(faceOne)->arrayObjects()) {
865 auto mutableOneVolume =
868 if (boundaryMaterial ==
nullptr) {
871 oneBSurface->surfaceRepresentation().surfaceMaterialSharedPtr();
873 mutableOneVolume->updateBoundarySurface(faceOne, boundarySurface);
875 << mutableOneVolume->volumeName());
877 ACTS_VERBOSE(
" - at second volume: " << tvolTwo->volumeName());
878 for (
auto& twoVolume :
879 gvDescriptorTwo.
glueVolumes(faceTwo)->arrayObjects()) {
880 auto mutableTwoVolume =
883 if (boundaryMaterial ==
nullptr) {
886 twoBSurface->surfaceRepresentation().surfaceMaterialSharedPtr();
888 mutableTwoVolume->updateBoundarySurface(faceTwo, boundarySurface);
890 << mutableTwoVolume->volumeName());
894 if (boundaryMaterial !=
nullptr) {
896 ACTS_VERBOSE(
"- the new boundary surface has boundary material: ");
899 const_cast<Surface*
>(&(boundarySurface->surfaceRepresentation()));
910 ACTS_VERBOSE(
"Adding face volumes of face " << glueFace <<
" for the volume '"
911 << tvol->volumeName() <<
"'.");
915 if (gvDescriptor.glueVolumes(glueFace)) {
917 auto volIter = gvDescriptor.
glueVolumes(glueFace)->arrayObjects().begin();
918 auto volEnd = gvDescriptor.glueVolumes(glueFace)->arrayObjects().end();
919 for (; volIter != volEnd; ++volIter) {
920 ACTS_VERBOSE(
" -> adding : " << (*volIter)->volumeName());
921 vols.push_back(*volIter);
925 <<
" navigation volumes registered as glue volumes.");
928 ACTS_VERBOSE(
" -> adding only volume itself (at navigation level).");
929 vols.push_back(tvol);
933 std::shared_ptr<const Acts::Layer>
938 ACTS_VERBOSE(
"Creating a CylinderLayer at position " << z <<
" and radius "
941 std::shared_ptr<const Transform3D> transform =
943 ? std::make_shared<const Transform3D>(
Translation3D(0., 0., z))
947 BinUtility layerBinUtility(binsZ, z - halflengthZ, z + halflengthZ,
open,
952 ACTS_VERBOSE(
" -> Preparing the binned material with " << binsZ
959 layerBinUtilityPhiZ += layerBinUtility;
962 << binsPhi <<
" / " << binsZ <<
" bins in phi / Z. ");
969 transform, std::shared_ptr<const CylinderBounds>(cylinderBounds),
nullptr,
974 double z,
double rMin,
double rMax,
double thickness,
int binsPhi,
976 ACTS_VERBOSE(
"Creating a DiscLayer at position " << z <<
" and rMin/rMax "
977 << rMin <<
" / " << rMax);
980 std::shared_ptr<const Transform3D> transform =
982 ? std::make_shared<const Transform3D>(
Translation3D(0., 0., z))
988 ACTS_VERBOSE(
" -> Preparing the binned material with " << binsR
994 << binsPhi <<
" / " << binsR <<
" bins in phi / R. ");
1002 std::shared_ptr<const DiscBounds>(discBounds),
1003 nullptr, thickness);