37 std::vector<Obj*> toRawVec(
const std::vector<std::shared_ptr<Obj>>& in) {
39 std::vector<Obj*>
out{};
40 out.reserve(in.size());
41 for (
const std::shared_ptr<Obj>& obj : in) {
42 out.emplace_back(
obj.get());
53 declareInterface<ITrackingVolumeHelper>(
this);
63 return StatusCode::SUCCESS;
72 bool buildBoundaryLayer)
const
78 if (buildBoundaryLayer){
82 Surface& firstFaceSurface = bSurfacesFirst[firstFace]->surfaceRepresentation();
83 Surface& secondFaceSurface = bSurfacesSecond[secondFace]->surfaceRepresentation();
90 auto mLayer = std::make_shared<MaterialLayerNoOwnSurf>(&firstFaceSurface, std::move(lmps));
91 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of first volume." );
93 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of second volume.");
102 const std::vector<TrackingVolume*>& secondVolumes,
104 bool buildBoundaryLayer,
105 bool boundaryFaceExchange)
const
108 if (
msgLvl(MSG::VERBOSE)) {
110 for (
const auto & volIter : secondVolumes)
114 std::shared_ptr<MaterialLayer> mLayer{};
117 if (buildBoundaryLayer){
124 mLayer = std::make_shared<MaterialLayerNoOwnSurf>(&firstFaceSurface, std::move(lmps));
125 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of first volume (may be shared with second volume)." );
130 if (secondVolumes.size() == 1) {
135 std::unique_ptr<BinnedArray<TrackingVolume>> navArray =
nullptr;
151 if (boundaryFaceExchange){
153 ATH_MSG_VERBOSE(
"Creating a joint boundary surface for 1-to-n glueing case.");
155 std::shared_ptr<BoundarySurface<TrackingVolume> > bSurface = firstVol.
boundarySurfaces()[firstFace];
157 for (
const auto & volIter: secondVolumes )
162 for (
const auto & volIter: secondVolumes ) {
169 if (currentVolBounds && currentVolBounds->
innerRadius() < 10e-3)
179 Surface& secondFaceSurface = volIter->boundarySurfaces()[secondFace]->surfaceRepresentation();
190 const std::vector<TrackingVolume*>& secondVolumes,
192 bool buildBoundaryLayer,
193 bool boundaryFaceExchange)
const
197 std::unique_ptr<BinnedArray<TrackingVolume>> navArrayOne =
nullptr;
198 std::unique_ptr<BinnedArray<TrackingVolume>> navArrayTwo =
nullptr;
200 std::unique_ptr<Surface> mLayerSurface;
201 std::shared_ptr<MaterialLayer> mLayer;
203 ATH_MSG_VERBOSE(
"Glue configuration firstFace | secondFace = " << firstFace <<
" | " << secondFace );
206 if (firstFace < 2 && secondFace < 2 ) {
211 if (buildBoundaryLayer || boundaryFaceExchange){
212 double rmin = 10e10;
double rmax = 0;
double boundaryz = 0.;
double centerzOne = 0.;
213 for (
const auto & volIter : firstVolumes ){
219 boundaryz = volIter->boundarySurfaces()[firstFace]->surfaceRepresentation().center().z();
221 centerzOne = volIter->center().z();
223 if (buildBoundaryLayer){
227 mLayerSurface = std::make_unique<DiscSurface>(mLayerTransform, rmin, rmax);
233 mLayer = std::make_shared<MaterialLayerOwnSurf>(std::move(mLayerSurface), std::move(lmps));
236 if (boundaryFaceExchange){
238 ATH_MSG_VERBOSE(
"Creating a joint boundary surface for n-to-n glueing case.");
240 double centerzTwo = secondVolumes[secondVolumes.size()-1]->center().z();
244 DiscSurface dSurface(boundaryTransform, rmin, rmax);
246 if (centerzTwo < centerzOne){
250 std::shared_ptr< BinnedArray<TrackingVolume> > navArrayInside(std::move(navArrayOne));
251 std::shared_ptr< BinnedArray<TrackingVolume> > navArrayOutside(std::move(navArrayTwo));
253 std::shared_ptr<BoundarySurface<TrackingVolume> > sharedBoundarySurface(boundarySurface);
256 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of volume from second array." );
260 for (
const auto & volIter : firstVolumes){
261 ATH_MSG_VERBOSE(
" -> first array : setting a newly created boundary surface to " << volIter->volumeName());
264 for (
const auto & volIter : secondVolumes){
265 ATH_MSG_VERBOSE(
" -> second array : setting a newly created boundary surface to " << volIter->volumeName());
277 if (buildBoundaryLayer || boundaryFaceExchange){
279 double zmin = 10e10;
double zmax = -10e10;
double boundaryr = 0.;
double volumerOne = 0.;
double volumerTwo = 10e10;
280 for (
const auto & volIter : firstVolumes ){
286 boundaryr = volIter->boundarySurfaces()[firstFace]->surfaceRepresentation().bounds().r();
292 if (buildBoundaryLayer){
293 std::unique_ptr<Amg::Transform3D> mLayerTransform =
294 ((zmin + zmax) * (zmin + zmax) < 10e-4)
296 : std::make_unique < Amg::Transform3D>();
299 mLayerSurface.reset( mLayerTransform ?
new CylinderSurface(*mLayerTransform,boundaryr,0.5*(zmax-zmin)) :
304 if (lmps) mLayer = std::make_shared<MaterialLayerOwnSurf>(
305 std::move(mLayerSurface),
309 if (boundaryFaceExchange) {
311 ATH_MSG_VERBOSE(
"Creating a joint boundary surface for n-to-n glueing case.");
313 std::unique_ptr<Amg::Transform3D> boundaryTransform =
314 ((zmin + zmax) * (zmin + zmax) < 10e-4)
316 : std::make_unique<Amg::Transform3D>();
328 if (volumerTwo < volumerOne){
332 std::shared_ptr< BinnedArray<TrackingVolume> > navArrayInside(std::move(navArrayOne));
333 std::shared_ptr< BinnedArray<TrackingVolume> > navArrayOutside(std::move(navArrayTwo));
335 std::shared_ptr<BoundarySurface<TrackingVolume> > sharedBoundarySurface(boundarySurface);
338 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of volume from second array.");
343 for (
const auto & volIter : firstVolumes){
344 ATH_MSG_VERBOSE(
" -> first array : setting a newly created boundary surface to " << volIter->volumeName());
347 for (
const auto & volIter : secondVolumes){
348 ATH_MSG_VERBOSE(
" -> second array : setting a newly created boundary surface to " << volIter->volumeName());
359 ATH_MSG_VERBOSE(
"Leaving individual boundary surfaces for n-to-n glueing case.");
362 std::shared_ptr< BinnedArray< TrackingVolume> > navArrayOneShared(std::move(navArrayOne));
363 std::shared_ptr< BinnedArray< TrackingVolume> > navArrayTwoShared(std::move(navArrayTwo));
366 for (
const auto & tVolIter: firstVolumes) {
370 ATH_MSG_VERBOSE(
"Set outsideTrackingVolumeArray at face " << firstFace <<
" to " << (*tVolIter).volumeName() );
373 ATH_MSG_VERBOSE(
"Set insideTrackingVolumeArray at face " << firstFace <<
" to " << (*tVolIter).volumeName() );
377 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of volume from first array." );
378 Surface& firstFaceSurface = tVolIter->boundarySurfaces()[firstFace]->surfaceRepresentation();
386 for (
const auto & tVolIter : secondVolumes) {
389 ATH_MSG_VERBOSE(
"Set outsideTrackingVolumeArray at face " << secondFace <<
" to " << (*tVolIter).volumeName() );
392 ATH_MSG_VERBOSE(
"Set insideTrackingVolumeArray at face " << secondFace <<
" to " << (*tVolIter).volumeName() );
396 ATH_MSG_VERBOSE(
"Set MaterialLayer to the BoundarySurface of volume from second array." );
397 Surface& secondFaceSurface = tVolIter->boundarySurfaces()[secondFace]->surfaceRepresentation();
408 std::shared_ptr<TrackingVolume> secondVol,
410 const std::string& name)
const {
411 std::unique_ptr<TrackingVolume> enclosingVolume{};
416 if (!cyl1 || !cyl2) {
417 ATH_MSG_ERROR(
"TrackingVolumeHelper::glueTrackingVolumeArrays: input volumes not cylinders, return 0" );
418 return enclosingVolume;
420 if (cyl1->halfPhiSector()!=
M_PI || cyl2->halfPhiSector()!=
M_PI ) {
421 ATH_MSG_ERROR(
"TrackingVolumeHelper::glueTrackingVolumeArrays: not coded for cylinder Phi sectors yet, return 0" );
422 return enclosingVolume;
431 std::vector<std::shared_ptr<TrackingVolume>> vols;
432 std::shared_ptr<CylinderVolumeBounds> envBounds{};
433 std::unique_ptr<Amg::Transform3D> envTransf{};
434 std::unique_ptr<BinnedArray<TrackingVolume>> subVols{};
435 vols.push_back(firstVol);
436 vols.push_back(secondVol);
437 std::vector<std::shared_ptr<TrackingVolume>> envGlueNegXY{};
438 std::vector<std::shared_ptr<TrackingVolume>> envGluePosXY{};
439 std::vector<std::shared_ptr<TrackingVolume>> envGlueOuter;
440 std::vector<std::shared_ptr<TrackingVolume>> envGlueInner{};
443 envBounds = std::make_shared<CylinderVolumeBounds>(cyl1->innerRadius(),
445 cyl1->halflengthZ() + cyl2->halflengthZ());
450 center.z() + cyl2->halflengthZ()));
453 envGlueNegXY.push_back(firstVol);
454 envGluePosXY.push_back(secondVol);
458 envBounds = std::make_shared<CylinderVolumeBounds>(cyl1->innerRadius(),
460 cyl1->halflengthZ()+cyl2->halflengthZ());
464 center.z() - cyl2->halflengthZ()));
465 envGlueNegXY.push_back(secondVol);
466 envGluePosXY.push_back(firstVol);
469 vols.push_back(secondVol);
470 vols.push_back(firstVol);
472 firstFaceCorr = secondFace;
473 secondFaceCorr = firstFace;
480 envBounds = std::make_shared<CylinderVolumeBounds>(cyl2->innerRadius(),
482 cyl1->halflengthZ());
484 envBounds = std::make_shared<CylinderVolumeBounds>(cyl1->outerRadius(),
485 cyl1->halflengthZ());
487 if (!firstVol->transform().isApprox(Amg::Transform3D::Identity())) {
492 vols.push_back(secondVol);
493 vols.push_back(firstVol);
495 firstFaceCorr = secondFace;
496 secondFaceCorr = firstFace;
501 envGlueOuter.push_back(firstVol);
502 envGlueInner.push_back(secondVol);
504 envBounds = std::make_shared<CylinderVolumeBounds>(cyl1->innerRadius(),
506 cyl1->halflengthZ());
507 if(!firstVol->transform().isApprox(Amg::Transform3D::Identity())){
513 envGlueOuter.push_back(secondVol);
514 envGlueInner.push_back(firstVol);
516 firstFaceCorr = secondFace;
517 secondFaceCorr = firstFace;
521 enclosingVolume = std::make_unique<TrackingVolume>(std::move(envTransf),
524 nullptr, std::move(subVols), name);
531 std::vector<TrackingVolume*> glueNegXY{};
532 std::vector<TrackingVolume*> gluePosXY{};
533 std::vector<TrackingVolume*> glueInner{};
534 std::vector<TrackingVolume*> glueOuter{};
549 return enclosingVolume;
555 const std::vector<std::shared_ptr<TrackingVolume>>& envelopeFaceVolumes,
557 std::vector<TrackingVolume*>& glueVols){
558 std::vector<std::shared_ptr<TrackingVolume>> sharedTops{};
559 std::vector<std::shared_ptr<TrackingVolume>> sharedFaces{};
561 ::toRawVec(envelopeFaceVolumes),
566 const std::vector<TrackingVolume*>& envelopeFaceVolumes,
568 std::vector<TrackingVolume*>& glueVols) {
570 auto refVolIter = topLevelVolumes.begin();
571 for ( ; refVolIter != topLevelVolumes.end(); ++refVolIter ) {
573 for (
auto *envelopeFaceVolume : envelopeFaceVolumes){
575 if (envelopeFaceVolume==(*refVolIter)) {
579 if ( (glueVolDescriptor.
glueVolumes(glueFace)).empty()) {
580 glueVols.push_back(*refVolIter);
583 for (
auto *isubNavVol : glueVolDescriptor.
glueVolumes(glueFace))
584 glueVols.push_back( isubNavVol );
603 if (glueVols.size()<2) {
609 ATH_MSG_VERBOSE(
" glueTrackingVolumes() called with boundary faces " <<
static_cast<int>(firstFace)
610 <<
" and " <<
static_cast<int>(secondFace) <<
"." );
613 std::vector<TrackingVolume*>::const_iterator firstVol = glueVols.begin();
614 std::vector<TrackingVolume*>::const_iterator secondVol = firstVol + 1;
615 for ( ; secondVol != glueVols.end(); ++firstVol, ++secondVol) {
618 ATH_MSG_VERBOSE(
"Processing '" << (*firstVol)->volumeName() <<
"' and '" << (*secondVol)->volumeName() <<
"'." );
625 std::vector<TrackingVolume*> glueVols1{};
626 std::vector<TrackingVolume*> glueVols2{};
632 if (glueVols1.empty() && glueVols2.empty()) {
636 }
else if (glueVols1.empty() && !glueVols2.empty()) {
637 glueVols1.push_back(*firstVol);
639 }
else if (!glueVols1.empty() && glueVols2.empty()) {
640 glueVols2.push_back(*secondVol);
651 if (glueVols2.size()>1)
656 if (glueVols1.size()>1)
670 for (
auto & vol : glueVols1) {
673 if (glueVols2.size()>1)
678 if (glueVols2.size()>1){
688 for (
auto & vol : glueVols2) {
701std::unique_ptr<LayerMaterialProperties>
704 std::unique_ptr<LayerMaterialProperties> layerMaterial{};
708 if (!cb)
throw std::logic_error(
"Not CylinderBounds");
715 layerMaterial = std::make_unique<BinnedLayerMaterial>(layerBinUtilityZ);
718 layerBinUtilityRPhiZ += layerBinUtilityZ;
719 layerMaterial = std::make_unique<BinnedLayerMaterial>(layerBinUtilityRPhiZ);
726 if (!db)
throw std::logic_error(
"Not DiscBounds");
727 double rMin = db->rMin();
728 double rMax = db->rMax();
732 layerMaterial = std::make_unique<BinnedLayerMaterial>(layerBinUtilityR);
735 layerBinUtilityR += layerBinUtilityPhi;
736 layerMaterial = std::make_unique<BinnedLayerMaterial>(layerBinUtilityR);
741 return layerMaterial;
775 unsigned int numVols = outsidevolarray.get()->arrayObjects().size() ;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define takeSmaller(current, test)
#define takeBigger(current, test)
bool msgLvl(const MSG::Level lvl) const
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Binned Array for avoiding map searches/.
BoundaryCylinderSurface description inside the tracking realm, Extends the Surface description to mak...
virtual const Surface & surfaceRepresentation() const override final
The Surface Representation of this.
BoundaryDiscSurface description inside the tracking realm, it extends the DiscSurface description to ...
virtual const Surface & surfaceRepresentation() const override final
The Surface Representation of this.
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 for a CylinderSurface in the ATLAS detector.
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.
Class to describe the bounds for a planar DiscSurface.
Class for a DiscSurface in the ATLAS detector.
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
Abstract Base Class for tracking surfaces.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
void setMaterialLayer(std::shared_ptr< Trk::MaterialLayer > mlay)
set material layer
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
void setOutsideTrackingVolume(TrackingVolume &tvol, BoundarySurfaceFace face, TrackingVolume *outsidevol) const override
protected method to set outside Volume of a BoundarySurface: input:
void setOutsideTrackingVolumeArray(TrackingVolume &tvol, BoundarySurfaceFace face, std::shared_ptr< BinnedArray< TrackingVolume > > outsidevolarray) const override
protected method to set outside VolumeArray of a BoundarySurface: input:
void glueTrackingVolumes(TrackingVolume &firstVol, BoundarySurfaceFace firstFace, TrackingVolume &secondVol, BoundarySurfaceFace secondFace, bool buildBoundaryLayer=false) const override
Method to glue two Volumes together input:
ToolHandle< ITrackingVolumeArrayCreator > m_trackingVolumeArrayCreator
Helper Tool to create TrackingVolume.
std::unique_ptr< Trk::TrackingVolume > glueTrackingVolumeArrays(std::shared_ptr< TrackingVolume > firstVol, BoundarySurfaceFace firstFace, std::shared_ptr< TrackingVolume > secondVol, BoundarySurfaceFace secondFace, const std::string &name) const override
Method to glue two VolumeArrays together (at navigation level).
Gaudi::Property< int > m_endcapLayerBinsR
material bins in R
void setInsideTrackingVolumeArray(TrackingVolume &tvol, BoundarySurfaceFace face, std::shared_ptr< BinnedArray< TrackingVolume > > insidevolarray) const override
protected method to set inside VolumeArray of a BoundarySurface: input:
std::unique_ptr< Trk::LayerMaterialProperties > layerMaterialProperties(const Trk::Surface &sf) const
< helper method to construct barrel material
TrackingVolumeHelper(const std::string &, const std::string &, const IInterface *)
Constructor.
Gaudi::Property< int > m_barrelLayerBinsPhi
material bins in Phi
Gaudi::Property< int > m_endcapLayerBinsPhi
material bins in Phi
StatusCode initialize() override
AlgTool initialize method.
Gaudi::Property< int > m_barrelLayerBinsZ
material bins in Z
void setInsideTrackingVolume(TrackingVolume &tvol, BoundarySurfaceFace face, TrackingVolume *insidevol) const override
protected method to set inside Volume of a BoundarySurface: input:
PublicToolHandle< ILayerArrayCreator > m_layerArrayCreator
A Tool for coherent LayerArray creation.
static void fillGlueVolumes(const std::vector< TrackingVolume * > &topLevelVolumes, const std::vector< TrackingVolume * > &envelopeFaceVolumes, BoundarySurfaceFace glueFace, std::vector< Trk::TrackingVolume * > &glueVols)
Private method - it takes the full vector of given volumes to create the supervolume,...
static void setBoundarySurface(TrackingVolume &tvol, std::shared_ptr< BoundarySurface< TrackingVolume > > bsurf, BoundarySurfaceFace face)
protected method to set the boundary surface of a tracking volume
static void setOutsideVolumeArray(TrackingVolume &tvol, BoundarySurfaceFace face, const std::shared_ptr< BinnedArray< TrackingVolume > > &outsidevolarray)
protected method to set outside VolumeArray of a BoundarySurface: input:
static void setInsideVolumeArray(TrackingVolume &tvol, BoundarySurfaceFace face, const std::shared_ptr< BinnedArray< TrackingVolume > > &insidevolarray)
protected method to set inside VolumeArray of a BoundarySurface: input:
void glueVolumes(TrackingVolume &firstVol, BoundarySurfaceFace firstFace, TrackingVolume &secondVol, BoundarySurfaceFace secondFace) const
protected method to glue two Volumes together input:
TrackingVolumeManipulator()
constructor
static void setOutsideVolume(TrackingVolume &tvol, BoundarySurfaceFace face, TrackingVolume *outsidevol)
protected method to set outside Volume of a BoundarySurface: input:
static void setInsideVolume(TrackingVolume &tvol, BoundarySurfaceFace face, TrackingVolume *insidevol)
protected method to set inside Volume of a BoundarySurface: input:
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Amg::Transform3D getTranslateZ3D(const double Z)
: Returns a shift transformation along the z-axis
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
Ensure that the ATLAS eigen extensions are properly loaded.
BoundarySurfaceFace
Enum to describe the position of the BoundarySurface respectively to the frame orientatin of the volu...
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)