30 declareInterface<ITrackingVolumeCreator>(
this);
42 return StatusCode::FAILURE;
51 return StatusCode::FAILURE;
60 return StatusCode::FAILURE;
66 return StatusCode::SUCCESS;
71 const std::vector<Trk::Layer*>& layers,
75 const std::string& volumeName,
93 ATH_MSG_WARNING(
"[!] Problem: given bounds were not cylindrical - return 0" );
97 std::vector<Trk::CylinderLayer*> cylLayers;
98 cylLayers.reserve(layers.size());
99 std::vector<Trk::DiscLayer*> discLayers;
100 discLayers.reserve(layers.size());
116 btype).isFailure()) {
117 ATH_MSG_WARNING(
"[!] Problem with given dimensions - return 0 and delete provided objects" );
118 delete volBounds;
delete transform;
119 delete cylinderBounds;
124 double zMin = ( transform ? transform->translation().
z() : 0. ) +
125 ( cylinderBounds ? -cylinderBounds->
halflengthZ() : 0. );
126 double zMax = ( transform ? transform->translation().
z() : 0. ) +
127 ( cylinderBounds ? cylinderBounds->
halflengthZ() : 0. );
140 if (!cylinderBounds) {
150 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> layerArray =
152 cylLayers, rMin, rMax, btype)
154 discLayers, zMin, zMax, btype);
158 std::shared_ptr<Trk::CylinderVolumeBounds>(cylinderBounds),
160 std::move(layerArray),
173 const std::vector<Trk::Layer*>& layers,
179 const std::string& volumeName,
187 ATH_MSG_VERBOSE(
"Create cylindrical TrackingVolume '" << volumeName <<
"'.");
189 << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
192 if (zMin > zMax || rMin > rMax) {
194 << ((zMin > zMax) ?
" zMin > zMax (" :
" rMin > rMax (")
195 << ((zMin > zMax) ? zMin : rMin) <<
" > "
196 << ((zMin > zMax) ? zMax : rMax) <<
" ) - return 0");
201 double halflengthZ = 0.5 * (zMax - zMin);
202 double zPosition = 0.5 * (zMin + zMax);
203 zPosition = fabs(zPosition) < 0.1 ? 0. : zPosition;
216 layers, matprop, cBounds, transform, volumeName, btype);
225 unsigned int materialLayers,
227 const std::string& volumeName)
const
231 ATH_MSG_VERBOSE(
"Create cylindrical gap TrackingVolume '" << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
232 ATH_MSG_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax );
235 double min = cylinder ? rMin : zMin;
236 double max = cylinder ? rMax : zMax;
239 std::vector<double> layerPositions;
240 layerPositions.reserve(materialLayers);
241 if (materialLayers > 1){
243 const double step=(
max-
min)/(materialLayers-1);
244 for (
unsigned int il = 0; il < materialLayers; ++il)
245 layerPositions.push_back(
min+il*step);
247 layerPositions.push_back(0.5*(
min+
max));
269 const std::vector<double>& layerPositions,
271 const std::string& volumeName,
277 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
278 ATH_MSG_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / "
282 std::vector<Trk::Layer*> layers;
283 layers.reserve(layerPositions.size());
285 std::vector<double>::const_iterator layerPropIter = layerPositions.begin();
286 std::vector<double>::const_iterator layerPropEnd = layerPositions.end();
287 for (; layerPropIter != layerPropEnd; ++layerPropIter) {
291 double zMinLayer = zMin;
292 double zMaxLayer = zMax;
296 fabs(0.5 * (zMaxLayer - zMinLayer)),
303 double rMinLayer = rMin;
304 double rMaxLayer = rMax;
316 layers, matprop, rMin, rMax, zMin, zMax, volumeName, btype);
321 const std::vector<Trk::TrackingVolume*>& volumes,
323 const std::string& volumeName,
324 bool buildBoundaryLayers,
325 bool replaceBoundaryFace)
const
328 if (volumes.size() <= (
unsigned int)1) {
329 ATH_MSG_WARNING(
"None (only one) TrackingVolume given to create container "
330 "volume (min required: 2) - returning 0 ");
336 << volumeName <<
"' with " << volumes.size()
340 auto firstVolume = volumes.begin();
341 auto lastVolume = volumes.end();
343 for (
unsigned int ivol = 0; firstVolume != lastVolume;
344 ++firstVolume, ++ivol) {
346 << ivol <<
") is : " << (*firstVolume)->volumeName());
348 " at position : " <<
Amg::toString((*firstVolume)->center()));
353 firstVolume = volumes.begin();
356 if (firstVolume == lastVolume) {
357 ATH_MSG_WARNING(
"Only one TrackingVolume given to create Top level volume "
358 "(min required: 2) - returning 0 ");
365 &((*firstVolume)->volumeBounds()));
368 &((*lastVolume)->volumeBounds()));
370 if (!firstVolumeBounds || !lastVolumeBounds) {
372 "Trk::CylinderVolumeBounds (required) - returning 0 ");
377 bool rCase = fabs(firstVolumeBounds->
innerRadius() -
386 zMin = (*firstVolume)->center().z() - firstVolumeBounds->
halflengthZ();
387 zMax = (*firstVolume)->center().z() + firstVolumeBounds->
halflengthZ();
391 zMin = (*firstVolume)->center().z() - firstVolumeBounds->
halflengthZ();
392 zMax = (*lastVolume)->center().z() + lastVolumeBounds->
halflengthZ();
398 double zPos = 0.5 * (zMin + zMax);
400 std::unique_ptr<Amg::Transform3D> topVolumeTransform =
401 fabs(zPos) > 0.1 ? std::make_unique<Amg::Transform3D>(
Amg::Translation3D(0., 0., zPos)) :
nullptr;
403 auto topVolumeBounds =
405 ? std::make_shared<Trk::CylinderVolumeBounds>(rMin, rMax, 0.5 * fabs(zMax - zMin))
406 : std::make_shared<Trk::CylinderVolumeBounds>(rMax, 0.5 * fabs(zMax - zMin));
408 std::unique_ptr<Trk::BinnedArray<Trk::TrackingVolume>> volumeArray =
413 "Creation of TrackingVolume array did not succeed - returning 0 ");
419 std::move(topVolumeTransform),
420 std::move(topVolumeBounds),
423 std::move(volumeArray),
429 *topVolume, rCase, buildBoundaryLayers, replaceBoundaryFace)
432 "Problem with inter-glueing of TrackingVolumes (needed) - returning 0 ");
438 "[ end ] return newly created container : " << topVolume->
volumeName());
446 const std::vector<Trk::Layer*>& layers,
449 std::vector<Trk::CylinderLayer*>& cylinderLayers,
450 std::vector<Trk::DiscLayer*>& discLayers,
459 if (layers.empty()) {
461 return StatusCode::FAILURE;
465 ATH_MSG_VERBOSE(
"Parsing the " << layers.size() <<
" layers to gather overall dimensions" );
466 if (cylinderVolumeBounds)
ATH_MSG_VERBOSE(
"Cylinder volume bounds are given." );
469 double layerRmin = 10e10;
470 double layerRmax = 0.;
471 double layerZmin = 10e10;
472 double layerZmax = -10e10;
481 for (
auto *
const layerIter : layers) {
484 double currentRmin = 0.;
485 double currentRmax = 0.;
486 double currentZmin = 0.;
487 double currentZmax = 0.;
497 double currentR = cylBounds->
r();
498 double centerZ = (layerIter->surfaceRepresentation()).center().z();
501 currentRmin = currentR; currentRmax = currentR;
503 currentRmin = currentR-(0.5*(layerIter)->thickness());
504 currentRmax = currentR+(0.5*(layerIter)->thickness());
511 dynamic_cast<const Trk::DiscBounds*
>(&(layerIter->surfaceRepresentation()).bounds());
516 double centerZ = (layerIter->surfaceRepresentation()).center().z();
517 currentRmin = discBounds->
rMin();
518 currentRmax = discBounds->
rMax();
520 currentZmin = centerZ; currentZmax = centerZ;
522 currentZmin = centerZ - (0.5*(layerIter)->thickness());
523 currentZmax = centerZ + (0.5*(layerIter)->thickness());
527 rMinClean = std::min(rMinClean, currentRmin);
528 rMaxClean = std::max(rMaxClean, currentRmax);
529 zMinClean = std::min(zMinClean, currentZmin);
530 zMaxClean = std::max(zMaxClean, currentZmax);
533 layerRmin = std::min(layerRmin,currentRmin);
534 layerRmax = std::max(layerRmax, currentRmax);
535 layerZmin = std::min(layerZmin,currentZmin);
536 layerZmax = std::max(layerZmax, currentZmax);
542 double rStepHalf = 0.5*(layerRmax-layerRmin)/(layers.size()-1);
543 layerRmin -= rStepHalf;
544 layerRmax += rStepHalf;
546 double zStepHalf = 0.5*(layerZmax-layerZmin)/(layers.size()-1);
547 layerZmin -= zStepHalf;
548 layerZmax += zStepHalf;
552 ATH_MSG_VERBOSE(
"Estimate/check CylinderVolumeBounds from/w.r.t. enclosed layers + envelope covers" );
554 double zEstFromLayerEnv = 0.5*((layerZmax)+(layerZmin));
555 double halflengthFromLayer = 0.5*fabs((layerZmax)-(layerZmin));
557 bool concentric = (zEstFromLayerEnv*zEstFromLayerEnv < 0.001);
560 if (!cylinderVolumeBounds && !transform) {
567 }
else if (cylinderVolumeBounds && !transform &&!concentric){
571 else if (transform && !cylinderVolumeBounds) {
573 double halflengthFromLayer = 0.5*fabs((layerZmax)-(layerZmin));
576 halflengthFromLayer);
580 << layerRmin <<
" / " << layerRmax <<
" / " << layerZmin <<
" / " << layerZmax );
581 double zFromTransform = transform ? transform->translation().z() : 0.;
582 ATH_MSG_VERBOSE(
" -> while created bounds are (rMin/rMax/zMin/zMax) = "
584 << zFromTransform-cylinderVolumeBounds->
halflengthZ() <<
" / " << zFromTransform+cylinderVolumeBounds->
halflengthZ() );
588 if (cylinderVolumeBounds) {
590 if (zFromTransform-cylinderVolumeBounds->
halflengthZ() <= layerZmin &&
591 zFromTransform+cylinderVolumeBounds->
halflengthZ() >= layerZmax &&
592 cylinderVolumeBounds->
innerRadius() <= layerRmin &&
594 return StatusCode::SUCCESS;
596 ATH_MSG_WARNING(
"Provided layers are not contained by volume ! Bailing out. " );
597 return StatusCode::FAILURE;
603 return StatusCode::SUCCESS;
609 bool createBoundaryLayers,
610 bool replaceBoundaryFace)
const
622 auto tVolIter = volumes.begin();
623 auto tVolFirst = volumes.begin();
624 auto tVolLast = volumes.end(); --tVolLast;
625 auto tVolEnd = volumes.end();
628 std::vector<Trk::TrackingVolume*> glueVolumesInnerTube;
629 std::vector<Trk::TrackingVolume*> glueVolumesOuterTube;
630 std::vector<Trk::TrackingVolume*> glueVolumesNegativeFace;
631 std::vector<Trk::TrackingVolume*> glueVolumesPositiveFace;
636 for ( ; tVolIter != tVolEnd; ) {
638 ATH_MSG_VERBOSE(
"r-binning: Processing volume '" << (*tVolIter)->volumeName() <<
"'.");
640 if (tVolIter == tVolFirst)
645 if (tVolIter == tVolLast) {
657 for ( ; tVolIter != tVolEnd; ) {
659 ATH_MSG_VERBOSE(
"z-binning: Processing volume '" << (*tVolIter)->volumeName() <<
"'.");
660 if (tVolIter == tVolFirst)
664 if (tVolIter == tVolLast) {
682 return StatusCode::SUCCESS;
689 std::vector<Trk::TrackingVolume*>& vols)
const
698 std::vector<Trk::TrackingVolume*>::const_iterator volIter = gvDescriptor.
glueVolumes(glueFace).begin();
699 std::vector<Trk::TrackingVolume*>::const_iterator volEnd = gvDescriptor.
glueVolumes(glueFace).end();
700 for ( ; volIter != volEnd; ++volIter){
701 ATH_MSG_VERBOSE(
" -> adding volumes : " << (*volIter)->volumeName() );
702 vols.push_back(*volIter);
705 ATH_MSG_VERBOSE( vols.size() <<
" navigation volumes registered as glue volumes." );
709 vols.push_back(&tvol);
719 bool createBoundaryLayers,
720 bool replaceBoundaryFace)
const
727 ATH_MSG_VERBOSE(
"Glue method called with " << (replaceBoundaryFace ?
"joint boundaries." :
"individual boundaries." ) );
729 size_t volOneGlueVols = gvDescriptorOne.
glueVolumes(faceOne).size();
731 << volOneGlueVols <<
" @ " << faceOne );
732 size_t volTwoGlueVols = gvDescriptorTwo.
glueVolumes(faceTwo).size();
734 << volTwoGlueVols <<
" @ " << faceTwo );
738 gvDescriptorOne.
glueVolumes(faceOne)[0] : &tvolOne;
741 gvDescriptorTwo.
glueVolumes(faceTwo)[0] : &tvolTwo;
745 if ( volOneGlueVols <= 1 && volTwoGlueVols <= 1) {
748 <<
" ]-to-one[ "<< glueVolTwo->
volumeName() <<
" @ " << faceTwo <<
" ]" );
753 createBoundaryLayers);
754 }
else if (volOneGlueVols <= 1) {
756 <<
" ]-to-many[ "<< tvolTwo.
volumeName() <<
" @ " << faceTwo <<
" ]" );
761 createBoundaryLayers,
762 replaceBoundaryFace);
763 }
else if (volTwoGlueVols <= 1 ) {
765 <<
" ]-to-one[ "<< glueVolTwo->
volumeName() <<
" @ " << faceTwo <<
" ]" );
770 createBoundaryLayers,
771 replaceBoundaryFace);
775 <<
" ]-to-many[ "<< tvolTwo.
volumeName() <<
" @ " << faceTwo <<
" ]" );
780 createBoundaryLayers,
781 replaceBoundaryFace);
792 ATH_MSG_VERBOSE(
"Creating a CylinderLayer at position " <<
z <<
" and radius " <<
r );
796 std::unique_ptr<Amg::Transform3D> transform =
806 << binsZ <<
" bins in Z. ");
811 layerBinUtilityRPhiZ += layerBinUtility;
816 << binsPhi <<
" / " << binsZ <<
" bins in R*phi / Z. ");
819 auto cylinderBounds = std::make_shared<Trk::CylinderBounds>(
r,halflengthZ);
824 cylinderMaterial, thickness,
nullptr,
829 return cylinderLayer;
841 ATH_MSG_VERBOSE(
"Creating a DiscLayer at position " <<
z <<
" and rMin/rMax " << rMin <<
" / " << rMax);
851 << binsR <<
" bins in R. ");
856 << binsPhi <<
" / " << binsR <<
" bins in phi / R. ");
861 auto discBounds = std::make_shared<Trk::DiscBounds>(rMin,rMax);
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
It extends the LayerMaterialProperties base class.
Bounds for a cylindrical Surface.
virtual double r() const override final
This method returns the radius.
double halflengthZ() const
This method returns the halflengthZ.
Class to describe a cylindrical detector layer for tracking, it inhertis from both,...
Bounds for a cylindrical Volume, the decomposeToSurfaces method creates a vector of up to 6 surfaces:
double innerRadius() const
This method returns the inner radius.
double halflengthZ() const
This method returns the halflengthZ.
double outerRadius() const
This method returns the outer radius.
ToolHandle< ITrackingVolumeHelper > m_trackingVolumeHelper
CylinderLayer * createCylinderLayer(double z, double r, double halflength, double thickness, int binsPhi, int binsZ) const
Private method - helper method to save some code.
void glueTrackingVolumes(TrackingVolume &volumeOne, BoundarySurfaceFace faceOne, TrackingVolume &volumeTwo, BoundarySurfaceFace faceTwo, bool buildBoundaryLayers, bool replaceBoundaryFace=false) const
Private method - glue volume to the other – use trackingVolume helper.
void addFaceVolumes(TrackingVolume &tvol, Trk::BoundarySurfaceFace bsf, std::vector< Trk::TrackingVolume * > &vols) const
Private method - helper method not to duplicate code.
ToolHandle< ILayerArrayCreator > m_layerArrayCreator
< A Tool for coherent LayerArray creation
virtual TrackingVolume * createGapTrackingVolume(Material &matprop, double rMin, double rMax, double zMin, double zMax, unsigned int materialLayers, bool cylinder=true, const std::string &volumeName="UndefinedVolume") const override final
DiscLayer * createDiscLayer(double z, double rMin, double rMax, double thickness, int binsPhi, int binsR) const
Private method - helper method to save some code.
virtual TrackingVolume * createContainerTrackingVolume(const std::vector< TrackingVolume * > &volumes, const Material &matprop, const std::string &volumeName="UndefinedVolume", bool buildBoundaryLayers=false, bool replaceBoundaryFace=false) const override final
;
Gaudi::Property< int > m_passiveLayerRzBins
ToolHandle< ITrackingVolumeArrayCreator > m_trackingVolumeArrayCreator
TrackingVolume helper.
StatusCode interGlueTrackingVolume(TrackingVolume &tVolume, bool rBinned, bool buildBoundaryLayers, bool replaceBoundaryFace=false) const
Private method - interglue all volumes contained by a TrackingVolume and set the outside glue volumes...
CylinderVolumeCreator(const std::string &, const std::string &, const IInterface *)
Constructor.
Gaudi::Property< double > m_passiveLayerThickness
virtual StatusCode initialize() override
AlgTool initialize method.
Gaudi::Property< int > m_passiveLayerPhiBins
virtual TrackingVolume * createTrackingVolume(const std::vector< Layer * > &layers, Material &matprop, VolumeBounds *volBounds=0, Amg::Transform3D *transform=0, const std::string &volumeName="UndefinedVolume", BinningType btype=arbitrary) const override final
;
StatusCode estimateAndCheckDimension(const std::vector< Layer * > &layers, Trk::CylinderVolumeBounds *&cylBounds, Amg::Transform3D *&translation, std::vector< CylinderLayer * > &cylLayers, std::vector< DiscLayer * > &discLayers, double &rMinClean, double &rMaxClean, double &zMinClean, double &zMaxClean, BinningType bType=arbitrary) const
Private method - it estimates the CylinderBounds and Translation of layers, if given,...
Class to describe the bounds for a planar DiscSurface.
double rMax() const
This method returns outer radius.
double rMin() const
This method returns inner radius.
Class to describe a disc-like detector layer for tracking, it inhertis from both, Layer base class an...
Descriptor class to hold GlueVolumes of a TrackingGeometry object.
const std::vector< TrackingVolume * > & glueVolumes(BoundarySurfaceFace)
retrieve them again
void registerGlueVolumes(BoundarySurfaceFace, std::vector< TrackingVolume * > &)
register the volumes
A common object to be contained by.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
GlueVolumesDescriptor & glueVolumesDescriptor()
Pure Absract Base Class for Volume bounds.
const Amg::Vector3D & center() const
returns the center of the volume
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Translation< double, 3 > Translation3D
BoundarySurfaceFace
Enum to describe the position of the BoundarySurface respectively to the frame orientatin of the volu...
@ z
global position (cartesian)
BinningType
, BinningOption & BinningAccess