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" );
120 if (volBounds != cylinderBounds) {
121 delete cylinderBounds;
127 double zMin = ( transform ? transform->translation().
z() : 0. ) +
128 ( cylinderBounds ? -cylinderBounds->
halflengthZ() : 0. );
129 double zMax = ( transform ? transform->translation().
z() : 0. ) +
130 ( cylinderBounds ? cylinderBounds->
halflengthZ() : 0. );
143 if (!cylinderBounds) {
153 std::unique_ptr<Trk::BinnedArray1D<Trk::Layer>> layerArray =
155 cylLayers, rMin, rMax, btype)
157 discLayers, zMin, zMax, btype);
161 std::shared_ptr<Trk::CylinderVolumeBounds>(cylinderBounds),
163 std::move(layerArray),
176 const std::vector<Trk::Layer*>& layers,
182 const std::string& volumeName,
190 ATH_MSG_VERBOSE(
"Create cylindrical TrackingVolume '" << volumeName <<
"'.");
192 << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax);
195 if (zMin > zMax || rMin > rMax) {
197 << ((zMin > zMax) ?
" zMin > zMax (" :
" rMin > rMax (")
198 << ((zMin > zMax) ? zMin : rMin) <<
" > "
199 << ((zMin > zMax) ? zMax : rMax) <<
" ) - return 0");
204 double halflengthZ = 0.5 * (zMax - zMin);
205 double zPosition = 0.5 * (zMin + zMax);
206 zPosition = fabs(zPosition) < 0.1 ? 0. : zPosition;
219 layers, matprop, cBounds, transform, volumeName, btype);
228 unsigned int materialLayers,
230 const std::string& volumeName)
const
234 ATH_MSG_VERBOSE(
"Create cylindrical gap TrackingVolume '" << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
235 ATH_MSG_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / " << zMax );
238 double min = cylinder ? rMin : zMin;
239 double max = cylinder ? rMax : zMax;
242 std::vector<double> layerPositions;
243 layerPositions.reserve(materialLayers);
244 if (materialLayers > 1){
246 const double step=(
max-
min)/(materialLayers-1);
247 for (
unsigned int il = 0; il < materialLayers; ++il)
248 layerPositions.push_back(
min+il*step);
250 layerPositions.push_back(0.5*(
min+
max));
272 const std::vector<double>& layerPositions,
274 const std::string& volumeName,
280 << volumeName <<
"' with (rMin/rMax/zMin/Max) = ");
281 ATH_MSG_VERBOSE(
'\t' << rMin <<
" / " << rMax <<
" / " << zMin <<
" / "
285 std::vector<Trk::Layer*> layers;
286 layers.reserve(layerPositions.size());
288 std::vector<double>::const_iterator layerPropIter = layerPositions.begin();
289 std::vector<double>::const_iterator layerPropEnd = layerPositions.end();
290 for (; layerPropIter != layerPropEnd; ++layerPropIter) {
294 double zMinLayer = zMin;
295 double zMaxLayer = zMax;
299 fabs(0.5 * (zMaxLayer - zMinLayer)),
306 double rMinLayer = rMin;
307 double rMaxLayer = rMax;
319 layers, matprop, rMin, rMax, zMin, zMax, volumeName, btype);
324 const std::vector<Trk::TrackingVolume*>& volumes,
326 const std::string& volumeName,
327 bool buildBoundaryLayers,
328 bool replaceBoundaryFace)
const
331 if (volumes.size() <= (
unsigned int)1) {
332 ATH_MSG_WARNING(
"None (only one) TrackingVolume given to create container "
333 "volume (min required: 2) - returning 0 ");
339 << volumeName <<
"' with " << volumes.size()
343 auto firstVolume = volumes.begin();
344 auto lastVolume = volumes.end();
346 for (
unsigned int ivol = 0; firstVolume != lastVolume;
347 ++firstVolume, ++ivol) {
349 << ivol <<
") is : " << (*firstVolume)->volumeName());
351 " at position : " <<
Amg::toString((*firstVolume)->center()));
356 firstVolume = volumes.begin();
359 if (firstVolume == lastVolume) {
360 ATH_MSG_WARNING(
"Only one TrackingVolume given to create Top level volume "
361 "(min required: 2) - returning 0 ");
368 &((*firstVolume)->volumeBounds()));
371 &((*lastVolume)->volumeBounds()));
373 if (!firstVolumeBounds || !lastVolumeBounds) {
375 "Trk::CylinderVolumeBounds (required) - returning 0 ");
380 bool rCase = fabs(firstVolumeBounds->
innerRadius() -
389 zMin = (*firstVolume)->center().z() - firstVolumeBounds->
halflengthZ();
390 zMax = (*firstVolume)->center().z() + firstVolumeBounds->
halflengthZ();
394 zMin = (*firstVolume)->center().z() - firstVolumeBounds->
halflengthZ();
395 zMax = (*lastVolume)->center().z() + lastVolumeBounds->
halflengthZ();
401 double zPos = 0.5 * (zMin + zMax);
403 std::unique_ptr<Amg::Transform3D> topVolumeTransform =
404 fabs(zPos) > 0.1 ? std::make_unique<Amg::Transform3D>(
Amg::Translation3D(0., 0., zPos)) :
nullptr;
406 auto topVolumeBounds =
408 ? std::make_shared<Trk::CylinderVolumeBounds>(rMin, rMax, 0.5 * fabs(zMax - zMin))
409 : std::make_shared<Trk::CylinderVolumeBounds>(rMax, 0.5 * fabs(zMax - zMin));
411 std::unique_ptr<Trk::BinnedArray<Trk::TrackingVolume>> volumeArray =
416 "Creation of TrackingVolume array did not succeed - returning 0 ");
422 std::move(topVolumeTransform),
423 std::move(topVolumeBounds),
426 std::move(volumeArray),
432 *topVolume, rCase, buildBoundaryLayers, replaceBoundaryFace)
435 "Problem with inter-glueing of TrackingVolumes (needed) - returning 0 ");
441 "[ end ] return newly created container : " << topVolume->
volumeName());
449 const std::vector<Trk::Layer*>& layers,
452 std::vector<Trk::CylinderLayer*>& cylinderLayers,
453 std::vector<Trk::DiscLayer*>& discLayers,
462 if (layers.empty()) {
464 return StatusCode::FAILURE;
468 ATH_MSG_VERBOSE(
"Parsing the " << layers.size() <<
" layers to gather overall dimensions" );
469 if (cylinderVolumeBounds)
ATH_MSG_VERBOSE(
"Cylinder volume bounds are given." );
472 double layerRmin = 10e10;
473 double layerRmax = 0.;
474 double layerZmin = 10e10;
475 double layerZmax = -10e10;
484 for (
auto *
const layerIter : layers) {
487 double currentRmin = 0.;
488 double currentRmax = 0.;
489 double currentZmin = 0.;
490 double currentZmax = 0.;
500 double currentR = cylBounds->
r();
501 double centerZ = (layerIter->surfaceRepresentation()).center().z();
504 currentRmin = currentR; currentRmax = currentR;
506 currentRmin = currentR-(0.5*(layerIter)->thickness());
507 currentRmax = currentR+(0.5*(layerIter)->thickness());
514 dynamic_cast<const Trk::DiscBounds*
>(&(layerIter->surfaceRepresentation()).bounds());
519 double centerZ = (layerIter->surfaceRepresentation()).center().z();
520 currentRmin = discBounds->
rMin();
521 currentRmax = discBounds->
rMax();
523 currentZmin = centerZ; currentZmax = centerZ;
525 currentZmin = centerZ - (0.5*(layerIter)->thickness());
526 currentZmax = centerZ + (0.5*(layerIter)->thickness());
530 rMinClean = std::min(rMinClean, currentRmin);
531 rMaxClean = std::max(rMaxClean, currentRmax);
532 zMinClean = std::min(zMinClean, currentZmin);
533 zMaxClean = std::max(zMaxClean, currentZmax);
536 layerRmin = std::min(layerRmin,currentRmin);
537 layerRmax = std::max(layerRmax, currentRmax);
538 layerZmin = std::min(layerZmin,currentZmin);
539 layerZmax = std::max(layerZmax, currentZmax);
545 double rStepHalf = 0.5*(layerRmax-layerRmin)/(layers.size()-1);
546 layerRmin -= rStepHalf;
547 layerRmax += rStepHalf;
549 double zStepHalf = 0.5*(layerZmax-layerZmin)/(layers.size()-1);
550 layerZmin -= zStepHalf;
551 layerZmax += zStepHalf;
555 ATH_MSG_VERBOSE(
"Estimate/check CylinderVolumeBounds from/w.r.t. enclosed layers + envelope covers" );
557 double zEstFromLayerEnv = 0.5*((layerZmax)+(layerZmin));
558 double halflengthFromLayer = 0.5*fabs((layerZmax)-(layerZmin));
560 bool concentric = (zEstFromLayerEnv*zEstFromLayerEnv < 0.001);
563 if (!cylinderVolumeBounds && !transform) {
570 }
else if (cylinderVolumeBounds && !transform &&!concentric){
574 else if (transform && !cylinderVolumeBounds) {
576 double halflengthFromLayer = 0.5*fabs((layerZmax)-(layerZmin));
579 halflengthFromLayer);
583 << layerRmin <<
" / " << layerRmax <<
" / " << layerZmin <<
" / " << layerZmax );
584 double zFromTransform = transform ? transform->translation().z() : 0.;
585 ATH_MSG_VERBOSE(
" -> while created bounds are (rMin/rMax/zMin/zMax) = "
587 << zFromTransform-cylinderVolumeBounds->
halflengthZ() <<
" / " << zFromTransform+cylinderVolumeBounds->
halflengthZ() );
591 if (cylinderVolumeBounds) {
593 if (zFromTransform-cylinderVolumeBounds->
halflengthZ() <= layerZmin &&
594 zFromTransform+cylinderVolumeBounds->
halflengthZ() >= layerZmax &&
595 cylinderVolumeBounds->
innerRadius() <= layerRmin &&
597 return StatusCode::SUCCESS;
599 ATH_MSG_WARNING(
"Provided layers are not contained by volume ! Bailing out. " );
600 return StatusCode::FAILURE;
606 return StatusCode::SUCCESS;
612 bool createBoundaryLayers,
613 bool replaceBoundaryFace)
const
625 auto tVolIter = volumes.begin();
626 auto tVolFirst = volumes.begin();
627 auto tVolLast = volumes.end(); --tVolLast;
628 auto tVolEnd = volumes.end();
631 std::vector<Trk::TrackingVolume*> glueVolumesInnerTube;
632 std::vector<Trk::TrackingVolume*> glueVolumesOuterTube;
633 std::vector<Trk::TrackingVolume*> glueVolumesNegativeFace;
634 std::vector<Trk::TrackingVolume*> glueVolumesPositiveFace;
639 for ( ; tVolIter != tVolEnd; ) {
641 ATH_MSG_VERBOSE(
"r-binning: Processing volume '" << (*tVolIter)->volumeName() <<
"'.");
643 if (tVolIter == tVolFirst)
648 if (tVolIter == tVolLast) {
660 for ( ; tVolIter != tVolEnd; ) {
662 ATH_MSG_VERBOSE(
"z-binning: Processing volume '" << (*tVolIter)->volumeName() <<
"'.");
663 if (tVolIter == tVolFirst)
667 if (tVolIter == tVolLast) {
685 return StatusCode::SUCCESS;
692 std::vector<Trk::TrackingVolume*>& vols)
const
701 std::vector<Trk::TrackingVolume*>::const_iterator volIter = gvDescriptor.
glueVolumes(glueFace).begin();
702 std::vector<Trk::TrackingVolume*>::const_iterator volEnd = gvDescriptor.
glueVolumes(glueFace).end();
703 for ( ; volIter != volEnd; ++volIter){
704 ATH_MSG_VERBOSE(
" -> adding volumes : " << (*volIter)->volumeName() );
705 vols.push_back(*volIter);
708 ATH_MSG_VERBOSE( vols.size() <<
" navigation volumes registered as glue volumes." );
712 vols.push_back(&tvol);
722 bool createBoundaryLayers,
723 bool replaceBoundaryFace)
const
730 ATH_MSG_VERBOSE(
"Glue method called with " << (replaceBoundaryFace ?
"joint boundaries." :
"individual boundaries." ) );
732 size_t volOneGlueVols = gvDescriptorOne.
glueVolumes(faceOne).size();
734 << volOneGlueVols <<
" @ " << faceOne );
735 size_t volTwoGlueVols = gvDescriptorTwo.
glueVolumes(faceTwo).size();
737 << volTwoGlueVols <<
" @ " << faceTwo );
741 gvDescriptorOne.
glueVolumes(faceOne)[0] : &tvolOne;
744 gvDescriptorTwo.
glueVolumes(faceTwo)[0] : &tvolTwo;
748 if ( volOneGlueVols <= 1 && volTwoGlueVols <= 1) {
751 <<
" ]-to-one[ "<< glueVolTwo->
volumeName() <<
" @ " << faceTwo <<
" ]" );
756 createBoundaryLayers);
757 }
else if (volOneGlueVols <= 1) {
759 <<
" ]-to-many[ "<< tvolTwo.
volumeName() <<
" @ " << faceTwo <<
" ]" );
764 createBoundaryLayers,
765 replaceBoundaryFace);
766 }
else if (volTwoGlueVols <= 1 ) {
768 <<
" ]-to-one[ "<< glueVolTwo->
volumeName() <<
" @ " << faceTwo <<
" ]" );
773 createBoundaryLayers,
774 replaceBoundaryFace);
778 <<
" ]-to-many[ "<< tvolTwo.
volumeName() <<
" @ " << faceTwo <<
" ]" );
783 createBoundaryLayers,
784 replaceBoundaryFace);
795 ATH_MSG_VERBOSE(
"Creating a CylinderLayer at position " <<
z <<
" and radius " <<
r );
799 std::unique_ptr<Amg::Transform3D> transform =
809 << binsZ <<
" bins in Z. ");
814 layerBinUtilityRPhiZ += layerBinUtility;
819 << binsPhi <<
" / " << binsZ <<
" bins in R*phi / Z. ");
822 auto cylinderBounds = std::make_shared<Trk::CylinderBounds>(
r,halflengthZ);
827 cylinderMaterial, thickness,
nullptr,
832 return cylinderLayer;
844 ATH_MSG_VERBOSE(
"Creating a DiscLayer at position " <<
z <<
" and rMin/rMax " << rMin <<
" / " << rMax);
854 << binsR <<
" bins in R. ");
859 << binsPhi <<
" / " << binsR <<
" bins in phi / R. ");
864 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