diff --git a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilder.cxx b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilder.cxx index cfb6e0996e14f261f3599e426da373d4f8c7d181..d61f5bf3e4825a8114eaf0e17fc599c8ab07c133 100755 --- a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilder.cxx +++ b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilder.cxx @@ -426,10 +426,10 @@ const std::vector< const Trk::CylinderLayer* >* InDet::TRT_LayerBuilder::cylindr // build a BinUtility for the ApproachDescritptor Trk::BinUtility* aDescriptorBinUtility = new Trk::BinUtility(nBarrelPhiSectors,layerPhiMinCorrected,layerPhiMaxCorrected,Trk::closed,Trk::binPhi); (*aDescriptorBinUtility) += Trk::BinUtility(2,-layerHalflength,layerHalflength,Trk::open, Trk::binZ); - Trk::BinnedArray2D<Trk::ApproachSurfaces>* aDescriptorBinnedArray = new Trk::BinnedArray2D<Trk::ApproachSurfaces> (layerApproachSurfaces, aDescriptorBinUtility); + auto aDescriptorBinnedArray = std::make_unique<Trk::BinnedArray2D<Trk::ApproachSurfaces>> (layerApproachSurfaces, aDescriptorBinUtility); // build an approach surface Trk::CylinderSurface* approachSurface = new Trk::CylinderSurface(barrelLayerBounds->clone()); - Trk::ApproachDescriptor* aDescritpor = new Trk::ApproachDescriptor(aDescriptorBinnedArray, approachSurface); + Trk::ApproachDescriptor* aDescritpor = new Trk::ApproachDescriptor(std::move(aDescriptorBinnedArray), approachSurface); // do not give every layer material properties if (assignMaterial) { @@ -669,7 +669,7 @@ const std::vector< const Trk::DiscLayer* >* InDet::TRT_LayerBuilder::discLayers( ATH_MSG_VERBOSE("TRT Disc being build at z Position " << discZ << " ( from " << zMin << " / " << zMax << " )"); // create the approach offset - Trk::ApproachSurfaces* aSurfaces = new Trk::ApproachSurfaces; + auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>(); // get the position of the approach surfaces const Amg::Vector3D aspPosition(0.,0.,zMin-m_layerStrawRadius); const Amg::Vector3D asnPosition(0.,0.,zMax+m_layerStrawRadius); @@ -686,7 +686,7 @@ const std::vector< const Trk::DiscLayer* >* InDet::TRT_LayerBuilder::discLayers( aSurfaces->push_back( new Trk::DiscSurface(asnTransform, fullDiscBounds->clone()) ); } // approach descriptor - Trk::ApproachDescriptor* aDescriptor = new Trk::ApproachDescriptor(aSurfaces,false); + Trk::ApproachDescriptor* aDescriptor = new Trk::ApproachDescriptor(std::move(aSurfaces),false); // do not give every layer material properties if (assignMaterial) diff --git a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilderCond.cxx b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilderCond.cxx index 90ac1dc3137d848986ae89d920a7a0742230d346..ee73ca31db73a3c72ff99408516d4f1faee16c15 100755 --- a/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilderCond.cxx +++ b/InnerDetector/InDetDetDescr/InDetTrackingGeometry/src/TRT_LayerBuilderCond.cxx @@ -433,11 +433,15 @@ std::pair<EventIDRange, const std::vector< const Trk::CylinderLayer* >* > InDet: // build a BinUtility for the ApproachDescritptor Trk::BinUtility* aDescriptorBinUtility = new Trk::BinUtility(nBarrelPhiSectors,layerPhiMinCorrected,layerPhiMaxCorrected,Trk::closed,Trk::binPhi); (*aDescriptorBinUtility) += Trk::BinUtility(2,-layerHalflength,layerHalflength,Trk::open, Trk::binZ); - Trk::BinnedArray2D<Trk::ApproachSurfaces>* aDescriptorBinnedArray = new Trk::BinnedArray2D<Trk::ApproachSurfaces> (layerApproachSurfaces, aDescriptorBinUtility); + + auto aDescriptorBinnedArray = std::make_unique<Trk::BinnedArray2D<Trk::ApproachSurfaces>> (layerApproachSurfaces, aDescriptorBinUtility); + // build an approach surface - Trk::CylinderSurface* approachSurface = new Trk::CylinderSurface(barrelLayerBounds->clone()); - Trk::ApproachDescriptor* aDescritpor = new Trk::ApproachDescriptor(aDescriptorBinnedArray, approachSurface); - + Trk::CylinderSurface* approachSurface = new Trk::CylinderSurface(barrelLayerBounds->clone()); + Trk::ApproachDescriptor* aDescritpor = + new Trk::ApproachDescriptor(std::move(aDescriptorBinnedArray), + approachSurface); + // do not give every layer material properties if (assignMaterial) { // ----- prepare the BinnedLayerMaterial ----------------------------------------------------- @@ -678,7 +682,7 @@ std::pair<EventIDRange, const std::vector< const Trk::DiscLayer* >* > InDet::TRT ATH_MSG_VERBOSE("TRT Disc being build at z Position " << discZ << " ( from " << zMin << " / " << zMax << " )"); // create the approach offset - Trk::ApproachSurfaces* aSurfaces = new Trk::ApproachSurfaces; + auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>(); // get the position of the approach surfaces const Amg::Vector3D aspPosition(0.,0.,zMin-m_layerStrawRadius); const Amg::Vector3D asnPosition(0.,0.,zMax+m_layerStrawRadius); @@ -695,7 +699,7 @@ std::pair<EventIDRange, const std::vector< const Trk::DiscLayer* >* > InDet::TRT aSurfaces->push_back( new Trk::DiscSurface(asnTransform, fullDiscBounds->clone()) ); } // approach descriptor - Trk::ApproachDescriptor* aDescriptor = new Trk::ApproachDescriptor(aSurfaces,false); + Trk::ApproachDescriptor* aDescriptor = new Trk::ApproachDescriptor(std::move(aSurfaces),false); // do not give every layer material properties if (assignMaterial) diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/ApproachDescriptor.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/ApproachDescriptor.h index 9e2b4aed57713e1c250e4b775962b2a55cd9aa51..788a9c1c41ca286e918b2ab7b187d59785c8eae6 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/ApproachDescriptor.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/ApproachDescriptor.h @@ -25,13 +25,18 @@ namespace Trk { class ApproachDescriptor : public IApproachDescriptor { public: // Default constructor - ApproachDescriptor(ApproachSurfaces* aSurfaces, bool rebuild=true) : - IApproachDescriptor(aSurfaces,rebuild) {} - + ApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces, + bool rebuild = true) + : IApproachDescriptor(std::move(aSurfaces), rebuild) + {} + // Default constructor - ApproachDescriptor(BinnedArray<ApproachSurfaces>* aSurfaceArray, Surface* aSurfaceArraySurface = nullptr) : - IApproachDescriptor(aSurfaceArray,aSurfaceArraySurface) {} - + ApproachDescriptor( + std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray, + Surface* aSurfaceArraySurface = nullptr) + : IApproachDescriptor(std::move(aSurfaceArray), aSurfaceArraySurface) + {} + /** get the compatible surfaces - return : a boolean indicating if an actual intersection had been tried - fill vector of intersections diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/CylinderLayer.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/CylinderLayer.h index e235f53daa9b27743559159d83cbdf693bf532f8..e755a68cd7d8942603888ed9fba9529af5329259 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/CylinderLayer.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/CylinderLayer.h @@ -18,6 +18,7 @@ class MsgStream; #include "TrkSurfaces/CylinderSurface.h" #include "TrkDetDescrUtils/BinnedArray.h" #include "TrkEventPrimitives/PropDirection.h" +#include "TrkGeometry/ApproachDescriptor.h" // STL sorting #include <algorithm> @@ -26,7 +27,6 @@ namespace Trk { class CylinderBounds; class LayerMaterialProperties; class OverlapDescriptor; -class IApproachDescriptor; /** @class CylinderLayer @@ -115,7 +115,7 @@ class IApproachDescriptor; CylinderLayer& operator=(const CylinderLayer&); /**Destructor*/ - virtual ~CylinderLayer() override; + virtual ~CylinderLayer() = default; /** Transforms the layer into a Surface representation for extrapolation */ virtual const CylinderSurface& surfaceRepresentation() const override; @@ -179,7 +179,7 @@ class IApproachDescriptor; protected: /** surfaces on approach to the layer */ - IApproachDescriptor* m_approachDescriptor; + std::unique_ptr<IApproachDescriptor> m_approachDescriptor; }; diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/DiscLayer.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/DiscLayer.h index b9863d0a85cb069c44b57ba556bfcb88a364bb5d..8bb2b812e1db5720357635ef86ec80e4fb5e1f50 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/DiscLayer.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/DiscLayer.h @@ -17,16 +17,16 @@ class MsgStream; #include "TrkGeometry/Layer.h" #include "TrkSurfaces/DiscSurface.h" #include "TrkEventPrimitives/PropDirection.h" +#include "TrkGeometry/ApproachDescriptor.h" // STL sorting #include <algorithm> - +#include <memory> namespace Trk { class DiscBounds; class VolumeBounds; class LayerMaterialProperties; class OverlapDescriptor; - class IApproachDescriptor; /** @class DiscLayer @@ -44,8 +44,8 @@ namespace Trk { public: /**Default Constructor*/ - DiscLayer(){} - + DiscLayer() = default; + /**Constructor with DiscSurface components and MaterialProperties */ DiscLayer(Amg::Transform3D* transform, DiscBounds* dbounds, @@ -91,8 +91,8 @@ namespace Trk { DiscLayer& operator=(const DiscLayer&); /**Destructor*/ - virtual ~DiscLayer() override; - + virtual ~DiscLayer() = default; + /** Transforms the layer into a Surface representation for extrapolation */ virtual const DiscSurface& surfaceRepresentation() const override; @@ -112,30 +112,31 @@ namespace Trk { virtual double postUpdateMaterialFactor(const Trk::TrackParameters& par, Trk::PropDirection dir) const override; - /** move the Layer */ + /** move the Layer non-const*/ virtual void moveLayer( Amg::Transform3D& shift ) override; - /** move the Layer */ + /** move the Layer const , performas const_cast */ virtual void moveLayer ATLAS_NOT_THREAD_SAFE ( Amg::Transform3D& shift ) const override{ const_cast<DiscLayer*> (this)->moveLayer(shift); } private: /** Resize the layer to the tracking volume - only works for CylinderVolumeBouns */ - virtual void resizeLayer(const VolumeBounds& vBounds, double envelope) override; - /** Resize the layer to the tracking volume - only works for CylinderVolumeBouns */ + virtual void resizeLayer(const VolumeBounds& vBounds, double envelope) override; + /** Resize the layer to the tracking volume - only works for + * CylinderVolumeBouns . performs const cast */ virtual void resizeLayer ATLAS_NOT_THREAD_SAFE(const VolumeBounds& vBounds, double envelope) const override { const_cast<DiscLayer*> (this)->resizeLayer(vBounds,envelope); } - /** Resize the layer to the tracking volume - not implemented */ + /** Resize the layer to the tracking volume - not implemented.*/ virtual void resizeAndRepositionLayer(const VolumeBounds& vBounds, const Amg::Vector3D& cCenter, double envelop) override; - /** Resize the layer to the tracking volume - not implemented */ + /** Resize the layer to the tracking volume - not implemented . Performs const cast*/ virtual void resizeAndRepositionLayer ATLAS_NOT_THREAD_SAFE (const VolumeBounds& vBounds, const Amg::Vector3D& cCenter, double envelop) const override{ @@ -151,22 +152,20 @@ namespace Trk { const Amg::Vector3D& dir, const BoundaryCheck& bcheck) const; protected: - IApproachDescriptor* m_approachDescriptor; //!< surface for approaching - + //!< surface for approaching + std::unique_ptr<IApproachDescriptor> m_approachDescriptor; }; /** @class DiscLayerSorterZ simple helper function to allow sorting of DiscLayers in z */ class DiscLayerSorterZ { - public: - /** Default Constructor */ - DiscLayerSorterZ() - {} - - bool operator() (const DiscLayer* one, const DiscLayer* two) const - {return ( one->center().z() < two->center().z() ); } - }; + public: + bool operator()(const DiscLayer* one, const DiscLayer* two) const + { + return (one->center().z() < two->center().z()); + } + }; } // end of namespace diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/IApproachDescriptor.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/IApproachDescriptor.h index 9f6046201eecc73e5a0c3853c40fb4fd6bae0e4e..0ed49a870336dc0482aabbe4e2312f5b33a09dff 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/IApproachDescriptor.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/IApproachDescriptor.h @@ -13,7 +13,7 @@ #include "GeoPrimitives/GeoPrimitives.h" #include "TrkSurfaces/Surface.h" #include "TrkDetDescrUtils/BinnedArray.h" - +#include <memory> namespace Trk { /** @@ -31,10 +31,14 @@ namespace Trk { // Desctructur with cleanup ~ApproachSurfaces() { - for (auto& sf : (*this)) + for (auto& sf : (*this)){ + //delete when not owned by + //Tracking Geometry + if (sf && sf->isFree()) { delete sf; + } + } } - }; /** @@ -49,23 +53,31 @@ namespace Trk { class IApproachDescriptor { public: // Default constructor - IApproachDescriptor(ApproachSurfaces* aSurfaces, bool rebuild=true) : - m_approachSurfaces(aSurfaces), - m_approachSurfaceArraySurface(nullptr), - m_approachSurfaceArray(nullptr), - m_rebuild(rebuild) + IApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces, + bool rebuild = true) + : m_approachSurfaces(std::move(aSurfaces)) + , m_approachSurfaceArraySurface(nullptr) + , m_approachSurfaceArray(nullptr) + , m_rebuild(rebuild) {} // Default constructor - IApproachDescriptor(BinnedArray<ApproachSurfaces>* aSurfaceArray, Surface* aSurfaceArraySurface = nullptr): - m_approachSurfaces(nullptr), - m_approachSurfaceArraySurface(aSurfaceArraySurface), - m_approachSurfaceArray(aSurfaceArray), - m_rebuild(false) + IApproachDescriptor( + std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray, + Surface* aSurfaceArraySurface = nullptr) + : m_approachSurfaces(nullptr) + , m_approachSurfaceArraySurface(aSurfaceArraySurface) + , m_approachSurfaceArray(std::move(aSurfaceArray)) + , m_rebuild(false) {} - // Virtual destructor - virtual ~IApproachDescriptor() {} + virtual ~IApproachDescriptor() { + //Delet if not free + if (m_approachSurfaceArraySurface && + m_approachSurfaceArraySurface->isFree()) { + delete m_approachSurfaceArraySurface; + } + } // register Layer void registerLayer(const Layer& lay); @@ -93,13 +105,12 @@ namespace Trk { {} protected: - ApproachSurfaces* m_approachSurfaces; - Surface* m_approachSurfaceArraySurface; - BinnedArray<ApproachSurfaces>* m_approachSurfaceArray; - bool m_rebuild; + std::unique_ptr<ApproachSurfaces> m_approachSurfaces; + Surface* m_approachSurfaceArraySurface; + std::unique_ptr<BinnedArray<ApproachSurfaces>> m_approachSurfaceArray; + bool m_rebuild; }; - inline bool IApproachDescriptor::rebuild() const { return m_rebuild; } inline void IApproachDescriptor::registerLayer(const Layer& lay) { diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/AlignableTrackingVolume.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/AlignableTrackingVolume.cxx index 566daba63bc00eb568d9c21aa639cc60b606c0bf..17f495f2139184879716e890de19c39473093366 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/AlignableTrackingVolume.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/AlignableTrackingVolume.cxx @@ -45,5 +45,5 @@ Trk::AlignableTrackingVolume::~AlignableTrackingVolume() const Trk::TrackingVolume* Trk::AlignableTrackingVolume::alignedTrackingVolume() const { if ( m_alignedTV ) return m_alignedTV; - else return this; + return this; } diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/ApproachDescriptor.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/ApproachDescriptor.cxx index aa7fe711e011c69bd2eaa2a12808f319ba2ffc28..ff3ee7d498a19122356eb2a0b2e56a981f921511 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/src/ApproachDescriptor.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/ApproachDescriptor.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -13,7 +13,7 @@ const Trk::ApproachSurfaces* Trk::ApproachDescriptor::approachSurfaces(const Amg { // return the single approach surfaces if (m_approachSurfaces) - return (m_approachSurfaces); + return (m_approachSurfaces.get()); // there's new surface given if (m_approachSurfaceArraySurface){ Trk::Intersection asInter = m_approachSurfaceArraySurface->straightLineIntersection(pos,dir); diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/ConeLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/ConeLayer.cxx index 6d3786aad2c98cbcd466a8122605917f98d6f7a9..40857a44af5de45f0ec0813cb4d5ce7337a808bd 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/src/ConeLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/ConeLayer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -56,10 +56,9 @@ Trk::ConeLayer::ConeLayer(Amg::Transform3D* transform, Layer(surfaceArray, laymatprop, thickness, olap, laytyp) {} -Trk::ConeLayer::ConeLayer(const Trk::ConeLayer& clay): - ConeSurface(clay), - Layer(clay) -{} +Trk::ConeLayer::ConeLayer(const Trk::ConeLayer& clay) + += default; Trk::ConeLayer::ConeLayer(const Trk::ConeLayer& clay, const Amg::Transform3D& transf): ConeSurface(clay,transf), diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/CylinderLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/CylinderLayer.cxx index 49f3c982c8bbc5027303bbd50820fe3bcc8b64a7..8a46f927731b3b66faf74626c460712c32fb3dca 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/CylinderLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/CylinderLayer.cxx @@ -2,294 +2,288 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// CylinderLayer.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// Trk -#include "TrkGeometry/CylinderLayer.h" -#include "TrkGeometry/LayerMaterialProperties.h" -#include "TrkGeometry/MaterialProperties.h" -#include "TrkGeometry/ApproachDescriptor.h" -#include "TrkVolumes/CylinderVolumeBounds.h" -#include "TrkSurfaces/CylinderBounds.h" -#include "TrkParameters/TrackParameters.h" -#include "TrkDetDescrUtils/BinUtility.h" -// Amg -#include "GeoPrimitives/GeoPrimitives.h" - -Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, - Trk::CylinderBounds* cbounds, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - CylinderSurface(transform, cbounds), - Layer(laymatprop, thickness, olap, laytyp), - m_approachDescriptor(nullptr) -{ - CylinderSurface::associateLayer(*this); -} - -Trk::CylinderLayer::CylinderLayer(Trk::CylinderSurface* cyl, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - CylinderSurface(*cyl), - Layer(laymatprop, thickness, olap, laytyp), - m_approachDescriptor(nullptr) -{ - CylinderSurface::associateLayer(*this); -} - -Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, - Trk::CylinderBounds* cbounds, - Trk::SurfaceArray* surfaceArray, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - CylinderSurface(transform, cbounds), - Layer(surfaceArray, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - CylinderSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); - -} - -Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, - Trk::CylinderBounds* cbounds, - Trk::SurfaceArray* surfaceArray, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - CylinderSurface(transform, cbounds), - Layer(surfaceArray, laymatprop, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - CylinderSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); - -} - -Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - CylinderSurface(cbounds), - Layer(laymatprop, thickness, olap, laytyp), - m_approachDescriptor(nullptr) -{ - CylinderSurface::associateLayer(*this); -} - -Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, - Trk::SurfaceArray* surfaceArray, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - CylinderSurface(cbounds), - Layer(surfaceArray, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - CylinderSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); -} - -Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, - Trk::SurfaceArray* surfaceArray, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - CylinderSurface(cbounds), - Layer(surfaceArray, laymatprop, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - CylinderSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); -} - -Trk::CylinderLayer::CylinderLayer(const Trk::CylinderLayer& clay): - CylinderSurface(clay), - Layer(clay), - m_approachDescriptor(nullptr) -{ - CylinderSurface::associateLayer(*this); - delete m_approachDescriptor; - if (m_surfaceArray) buildApproachDescriptor(); //!< TODO use clone when exists -} - -Trk::CylinderLayer::CylinderLayer(const Trk::CylinderLayer& clay, const Amg::Transform3D& transf): - CylinderSurface(clay,transf), - Layer(clay), - m_approachDescriptor(nullptr) -{ - if (m_surfaceArray) buildApproachDescriptor(); -} - -Trk::CylinderLayer& Trk::CylinderLayer::operator=(const CylinderLayer& clay) -{ - if (this!=&clay){ - // call the assignments of the base classes - Trk::CylinderSurface::operator=(clay); - Trk::Layer::operator=(clay); - if (m_surfaceArray) buildApproachDescriptor(); - CylinderSurface::associateLayer(*this); - } - return(*this); -} - -Trk::CylinderLayer::~CylinderLayer() -{ - delete m_approachDescriptor; -} - - -const Trk::CylinderSurface& Trk::CylinderLayer::surfaceRepresentation() const -{ - return (*this); -} - -double Trk::CylinderLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0.; - // calculate the direction to the normal - const Amg::Vector3D& parmPos = parm.position(); - Amg::Vector3D pastStep(parmPos + dir*parm.momentum().normalized()); - if (pastStep.perp() > parm.position().perp()) - return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); -} - -double Trk::CylinderLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0; - const Amg::Vector3D& parmPos = parm.position(); - Amg::Vector3D pastStep(parmPos + dir*parm.momentum().normalized()); - if (pastStep.perp() > parm.position().perp()) - return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); -} - - -void Trk::CylinderLayer::moveLayer(Amg::Transform3D& shift) { +/////////////////////////////////////////////////////////////////// +// CylinderLayer.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// Trk +#include "TrkGeometry/CylinderLayer.h" +#include "TrkGeometry/LayerMaterialProperties.h" +#include "TrkGeometry/MaterialProperties.h" +#include "TrkGeometry/ApproachDescriptor.h" +#include "TrkVolumes/CylinderVolumeBounds.h" +#include "TrkSurfaces/CylinderBounds.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkDetDescrUtils/BinUtility.h" +// Amg +#include "GeoPrimitives/GeoPrimitives.h" + +Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, + Trk::CylinderBounds* cbounds, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + CylinderSurface(transform, cbounds), + Layer(laymatprop, thickness, olap, laytyp), + m_approachDescriptor(nullptr) +{ + CylinderSurface::associateLayer(*this); +} + +Trk::CylinderLayer::CylinderLayer(Trk::CylinderSurface* cyl, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + CylinderSurface(*cyl), + Layer(laymatprop, thickness, olap, laytyp), + m_approachDescriptor(nullptr) +{ + CylinderSurface::associateLayer(*this); +} + +Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, + Trk::CylinderBounds* cbounds, + Trk::SurfaceArray* surfaceArray, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + CylinderSurface(transform, cbounds), + Layer(surfaceArray, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + CylinderSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); + +} + +Trk::CylinderLayer::CylinderLayer(Amg::Transform3D* transform, + Trk::CylinderBounds* cbounds, + Trk::SurfaceArray* surfaceArray, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + CylinderSurface(transform, cbounds), + Layer(surfaceArray, laymatprop, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + CylinderSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); + +} + +Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + CylinderSurface(cbounds), + Layer(laymatprop, thickness, olap, laytyp), + m_approachDescriptor(nullptr) +{ + CylinderSurface::associateLayer(*this); +} + +Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, + Trk::SurfaceArray* surfaceArray, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + CylinderSurface(cbounds), + Layer(surfaceArray, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + CylinderSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); +} + +Trk::CylinderLayer::CylinderLayer(Trk::CylinderBounds* cbounds, + Trk::SurfaceArray* surfaceArray, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + CylinderSurface(cbounds), + Layer(surfaceArray, laymatprop, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + CylinderSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); +} + +Trk::CylinderLayer::CylinderLayer(const Trk::CylinderLayer& clay): + CylinderSurface(clay), + Layer(clay), + m_approachDescriptor(nullptr) +{ + CylinderSurface::associateLayer(*this); + m_approachDescriptor.reset(); + if (m_surfaceArray) buildApproachDescriptor(); //!< TODO use clone when exists +} + +Trk::CylinderLayer::CylinderLayer(const Trk::CylinderLayer& clay, const Amg::Transform3D& transf): + CylinderSurface(clay,transf), + Layer(clay), + m_approachDescriptor(nullptr) +{ + if (m_surfaceArray) buildApproachDescriptor(); +} + +Trk::CylinderLayer& Trk::CylinderLayer::operator=(const CylinderLayer& clay) +{ + if (this!=&clay){ + // call the assignments of the base classes + Trk::CylinderSurface::operator=(clay); + Trk::Layer::operator=(clay); + if (m_surfaceArray) buildApproachDescriptor(); + CylinderSurface::associateLayer(*this); + } + return(*this); +} + + +const Trk::CylinderSurface& Trk::CylinderLayer::surfaceRepresentation() const +{ + return (*this); +} + +double Trk::CylinderLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0.; + // calculate the direction to the normal + const Amg::Vector3D& parmPos = parm.position(); + Amg::Vector3D pastStep(parmPos + dir*parm.momentum().normalized()); + if (pastStep.perp() > parm.position().perp()) + return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); +} + +double Trk::CylinderLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0; + const Amg::Vector3D& parmPos = parm.position(); + Amg::Vector3D pastStep(parmPos + dir*parm.momentum().normalized()); + if (pastStep.perp() > parm.position().perp()) + return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); +} + + +void Trk::CylinderLayer::moveLayer(Amg::Transform3D& shift) { Amg::Transform3D transf = shift * (*m_transform); - Trk::CylinderSurface::m_transform= std::make_unique<Amg::Transform3D>(transf); - m_center.store(std::make_unique<Amg::Vector3D>(m_transform->translation())); - m_normal.store(std::make_unique<Amg::Vector3D>(m_transform->rotation().col(2))); - - if (m_approachDescriptor && m_approachDescriptor->rebuild()){ - // build the new approach descriptor - deletes the current one - buildApproachDescriptor(); - } -} - -void Trk::CylinderLayer::resizeLayer(const VolumeBounds& bounds, double envelope) { - // only do this if the volume bounds a CylinderVolumeBounds - const Trk::CylinderVolumeBounds* cvb = dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds); - if (cvb){ - // get the dimensions - double hLengthZ = cvb->halflengthZ(); - double r = surfaceRepresentation().bounds().r(); - // (0) first, resize the layer itself - Trk::CylinderBounds* rCylinderBounds = new Trk::CylinderBounds(r,hLengthZ-envelope); - Trk::CylinderSurface::m_bounds = Trk::SharedObject<const Trk::CylinderBounds>(rCylinderBounds); - // (1) resize the material properties by updating the BinUtility, assuming rphi/z binning - if (Trk::Layer::m_layerMaterialProperties.get() ){ - const BinUtility* layerMaterialBU = Trk::Layer::m_layerMaterialProperties->binUtility(); - if (layerMaterialBU && layerMaterialBU->dimensions() > 1 ){ - size_t binsRPhi = layerMaterialBU->max(0)+1; - size_t binsZ = layerMaterialBU->max(1)+1; - // create a new binning with the new dimensions - Trk::BinUtility* rBinUtility = - new Trk::BinUtility(binsRPhi,-r*M_PI,r*M_PI, Trk::closed, Trk::binRPhi); - (*rBinUtility) += Trk::BinUtility(binsZ, -hLengthZ+envelope, hLengthZ-envelope, Trk::open, Trk::binZ); - Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility); - } - } - } - - if (m_approachDescriptor && m_approachDescriptor->rebuild()){ - // build the approach descriptor - delete the current approach descriptor - buildApproachDescriptor(); - } - - -} - -/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ -const Trk::Surface& Trk::CylinderLayer::approachSurface(const Amg::Vector3D& pos, - const Amg::Vector3D& dir, - const Trk::BoundaryCheck& bcheck) const -{ - if (m_approachDescriptor){ - // get the test surfaces from the approach Descriptor - const Trk::ApproachSurfaces* surfacesOnApproach = m_approachDescriptor->approachSurfaces(pos,dir); - if (surfacesOnApproach){ - // test the intersections and go - std::vector<Trk::Intersection> sfIntersections; - const Trk::Surface* aSurface = nullptr; - double aPathLength = 10e10; - // get the surfaces - for (auto& sfIter : (*surfacesOnApproach)){ - // get the intersection with the surface - Trk::Intersection sIntersection = sfIter->straightLineIntersection(pos, dir, true, bcheck); - // validation - if (sIntersection.valid && sIntersection.pathLength < aPathLength){ - aPathLength = sIntersection.pathLength; - aSurface = sfIter; - } - } - if (aSurface) return (*aSurface); - } - } - return surfaceRepresentation(); -} - -/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ -const Trk::Surface& Trk::CylinderLayer::surfaceOnApproach(const Amg::Vector3D& pos, - const Amg::Vector3D& mom, - Trk::PropDirection pDir, - const Trk::BoundaryCheck& bcheck, - bool resolveSubSurfaces, - const Trk::ICompatibilityEstimator*) const -{ - // resolve the surfaces - if (m_approachDescriptor && resolveSubSurfaces){ - // resolve based on straight line intersection - return approachSurface(pos,double(pDir)*mom.unit(),bcheck); - } - return surfaceRepresentation(); -} - - - + Trk::CylinderSurface::m_transform= std::make_unique<Amg::Transform3D>(transf); + m_center.store(std::make_unique<Amg::Vector3D>(m_transform->translation())); + m_normal.store(std::make_unique<Amg::Vector3D>(m_transform->rotation().col(2))); + + if (m_approachDescriptor && m_approachDescriptor->rebuild()){ + // build the new approach descriptor - deletes the current one + buildApproachDescriptor(); + } +} + +void Trk::CylinderLayer::resizeLayer(const VolumeBounds& bounds, double envelope) { + // only do this if the volume bounds a CylinderVolumeBounds + const Trk::CylinderVolumeBounds* cvb = dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds); + if (cvb){ + // get the dimensions + double hLengthZ = cvb->halflengthZ(); + double r = surfaceRepresentation().bounds().r(); + // (0) first, resize the layer itself + Trk::CylinderBounds* rCylinderBounds = new Trk::CylinderBounds(r,hLengthZ-envelope); + Trk::CylinderSurface::m_bounds = Trk::SharedObject<const Trk::CylinderBounds>(rCylinderBounds); + // (1) resize the material properties by updating the BinUtility, assuming rphi/z binning + if (Trk::Layer::m_layerMaterialProperties.get() ){ + const BinUtility* layerMaterialBU = Trk::Layer::m_layerMaterialProperties->binUtility(); + if (layerMaterialBU && layerMaterialBU->dimensions() > 1 ){ + size_t binsRPhi = layerMaterialBU->max(0)+1; + size_t binsZ = layerMaterialBU->max(1)+1; + // create a new binning with the new dimensions + Trk::BinUtility* rBinUtility = + new Trk::BinUtility(binsRPhi,-r*M_PI,r*M_PI, Trk::closed, Trk::binRPhi); + (*rBinUtility) += Trk::BinUtility(binsZ, -hLengthZ+envelope, hLengthZ-envelope, Trk::open, Trk::binZ); + Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility); + } + } + } + + if (m_approachDescriptor && m_approachDescriptor->rebuild()){ + // build the approach descriptor - delete the current approach descriptor + buildApproachDescriptor(); + } + + +} + +/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ +const Trk::Surface& Trk::CylinderLayer::approachSurface(const Amg::Vector3D& pos, + const Amg::Vector3D& dir, + const Trk::BoundaryCheck& bcheck) const +{ + if (m_approachDescriptor){ + // get the test surfaces from the approach Descriptor + const Trk::ApproachSurfaces* surfacesOnApproach = m_approachDescriptor->approachSurfaces(pos,dir); + if (surfacesOnApproach){ + // test the intersections and go + std::vector<Trk::Intersection> sfIntersections; + const Trk::Surface* aSurface = nullptr; + double aPathLength = 10e10; + // get the surfaces + for (auto& sfIter : (*surfacesOnApproach)){ + // get the intersection with the surface + Trk::Intersection sIntersection = sfIter->straightLineIntersection(pos, dir, true, bcheck); + // validation + if (sIntersection.valid && sIntersection.pathLength < aPathLength){ + aPathLength = sIntersection.pathLength; + aSurface = sfIter; + } + } + if (aSurface) return (*aSurface); + } + } + return surfaceRepresentation(); +} + +/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ +const Trk::Surface& Trk::CylinderLayer::surfaceOnApproach(const Amg::Vector3D& pos, + const Amg::Vector3D& mom, + Trk::PropDirection pDir, + const Trk::BoundaryCheck& bcheck, + bool resolveSubSurfaces, + const Trk::ICompatibilityEstimator*) const +{ + // resolve the surfaces + if (m_approachDescriptor && resolveSubSurfaces){ + // resolve based on straight line intersection + return approachSurface(pos,double(pDir)*mom.unit(),bcheck); + } + return surfaceRepresentation(); +} + + + /** build approach surfaces */ -void Trk::CylinderLayer::buildApproachDescriptor(){ - // delete it - delete m_approachDescriptor; +void Trk::CylinderLayer::buildApproachDescriptor(){ + // delete it // delete the surfaces - Trk::ApproachSurfaces* aSurfaces = new Trk::ApproachSurfaces; + auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>(); // create new surfaces Amg::Transform3D* asTransform = m_transform ? new Amg::Transform3D(*m_transform) : nullptr; // create the new surfaces @@ -300,7 +294,7 @@ void Trk::CylinderLayer::buildApproachDescriptor(){ sIter->associateLayer(*this); sIter->setOwner(Trk::TGOwn); } - m_approachDescriptor = new Trk::ApproachDescriptor(aSurfaces); + m_approachDescriptor = std::make_unique<Trk::ApproachDescriptor>(std::move(aSurfaces)); } diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/DiscLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/DiscLayer.cxx index 3ee5bd8619238f854a0c921858dd431da0285552..5350136ed628000e84805b12c1aaf4f37dba5b92 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/DiscLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/DiscLayer.cxx @@ -2,241 +2,238 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// DiscLayer.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// Trk -#include "TrkGeometry/DiscLayer.h" -#include "TrkGeometry/LayerMaterialProperties.h" -#include "TrkGeometry/MaterialProperties.h" -#include "TrkGeometry/ApproachDescriptor.h" -#include "TrkVolumes/CylinderVolumeBounds.h" -#include "TrkSurfaces/DiscBounds.h" -#include "TrkParameters/TrackParameters.h" -#include "TrkDetDescrUtils/BinUtility.h" -// CLHEP -#include "GeoPrimitives/GeoPrimitives.h" - -Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, - Trk::DiscBounds* dbounds, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - DiscSurface(transform, dbounds), - Layer(laymatprop, thickness, olap, laytyp), - m_approachDescriptor(nullptr) -{ - DiscSurface::associateLayer(*this); -} - -Trk::DiscLayer::DiscLayer(Trk::DiscSurface* disc, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - DiscSurface(*disc), - Layer(laymatprop, thickness, olap, laytyp), - m_approachDescriptor(nullptr) -{ - DiscSurface::associateLayer(*this); -} - -Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, - Trk::DiscBounds* dbounds, - Trk::SurfaceArray* surfaceArray, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - DiscSurface(transform, dbounds), - Layer(surfaceArray, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - DiscSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); - -} - -Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, - Trk::DiscBounds* dbounds, - Trk::SurfaceArray* surfaceArray, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - Trk::IApproachDescriptor* ades, - int laytyp) : - DiscSurface(transform, dbounds), - Layer(surfaceArray, laymatprop, thickness, olap, laytyp), - m_approachDescriptor(ades) -{ - DiscSurface::associateLayer(*this); - if (!ades && surfaceArray) buildApproachDescriptor(); - // register the layer - if (ades) m_approachDescriptor->registerLayer(*this); -} - -Trk::DiscLayer::DiscLayer(const Trk::DiscLayer& dlay): - DiscSurface(dlay), - Layer(dlay), - m_approachDescriptor(nullptr) -{ - DiscSurface::associateLayer(*this); - if (m_surfaceArray) buildApproachDescriptor(); -} - -Trk::DiscLayer::DiscLayer(const Trk::DiscLayer& dlay, const Amg::Transform3D& transf): - DiscSurface(dlay,transf), - Layer(dlay), - m_approachDescriptor(nullptr) -{ - DiscSurface::associateLayer(*this); - if (m_surfaceArray) buildApproachDescriptor(); -} - -Trk::DiscLayer::~DiscLayer() { - delete m_approachDescriptor; -} - -Trk::DiscLayer& Trk::DiscLayer::operator=(const DiscLayer& dlay) -{ - if (this!=&dlay){ - // call the assignments of the base classes - Trk::DiscSurface::operator=(dlay); - Trk::Layer::operator=(dlay); - delete m_approachDescriptor; - if (m_surfaceArray) buildApproachDescriptor(); - DiscSurface::associateLayer(*this); - } - return(*this); -} - -const Trk::DiscSurface& Trk::DiscLayer::surfaceRepresentation() const -{ - return (*this); -} - -double Trk::DiscLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0.; - //const Amg::Vector3D& parmPos = parm.position(); - if (Trk::DiscSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) - return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); -} - -double Trk::DiscLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0.; - //const Amg::Vector3D& parmPos = parm.position(); - if (Trk::DiscSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) - return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); -} - -void Trk::DiscLayer::moveLayer(Amg::Transform3D& shift) { +/////////////////////////////////////////////////////////////////// +// DiscLayer.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// Trk +#include "TrkGeometry/DiscLayer.h" +#include "TrkGeometry/LayerMaterialProperties.h" +#include "TrkGeometry/MaterialProperties.h" +#include "TrkVolumes/CylinderVolumeBounds.h" +#include "TrkSurfaces/DiscBounds.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkDetDescrUtils/BinUtility.h" +// CLHEP +#include "GeoPrimitives/GeoPrimitives.h" + +Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, + Trk::DiscBounds* dbounds, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + DiscSurface(transform, dbounds), + Layer(laymatprop, thickness, olap, laytyp), + m_approachDescriptor(nullptr) +{ + DiscSurface::associateLayer(*this); +} + +Trk::DiscLayer::DiscLayer(Trk::DiscSurface* disc, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + DiscSurface(*disc), + Layer(laymatprop, thickness, olap, laytyp), + m_approachDescriptor(nullptr) +{ + DiscSurface::associateLayer(*this); +} + +Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, + Trk::DiscBounds* dbounds, + Trk::SurfaceArray* surfaceArray, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + DiscSurface(transform, dbounds), + Layer(surfaceArray, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + DiscSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); + +} + +Trk::DiscLayer::DiscLayer(Amg::Transform3D* transform, + Trk::DiscBounds* dbounds, + Trk::SurfaceArray* surfaceArray, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + Trk::IApproachDescriptor* ades, + int laytyp) : + DiscSurface(transform, dbounds), + Layer(surfaceArray, laymatprop, thickness, olap, laytyp), + m_approachDescriptor(ades) +{ + DiscSurface::associateLayer(*this); + if (!ades && surfaceArray) buildApproachDescriptor(); + // register the layer + if (ades) m_approachDescriptor->registerLayer(*this); +} + +Trk::DiscLayer::DiscLayer(const Trk::DiscLayer& dlay): + DiscSurface(dlay), + Layer(dlay), + m_approachDescriptor(nullptr) +{ + DiscSurface::associateLayer(*this); + if (m_surfaceArray) buildApproachDescriptor(); +} + +Trk::DiscLayer::DiscLayer(const Trk::DiscLayer& dlay, const Amg::Transform3D& transf): + DiscSurface(dlay,transf), + Layer(dlay), + m_approachDescriptor(nullptr) +{ + DiscSurface::associateLayer(*this); + if (m_surfaceArray) buildApproachDescriptor(); +} + +Trk::DiscLayer& Trk::DiscLayer::operator=(const DiscLayer& dlay) +{ + if (this!=&dlay){ + // call the assignments of the base classes + Trk::DiscSurface::operator=(dlay); + Trk::Layer::operator=(dlay); + m_approachDescriptor.reset(); + if (m_surfaceArray) { + buildApproachDescriptor(); + } + DiscSurface::associateLayer(*this); + } + return(*this); +} + +const Trk::DiscSurface& Trk::DiscLayer::surfaceRepresentation() const +{ + return (*this); +} + +double Trk::DiscLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0.; + //const Amg::Vector3D& parmPos = parm.position(); + if (Trk::DiscSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) + return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); +} + +double Trk::DiscLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0.; + //const Amg::Vector3D& parmPos = parm.position(); + if (Trk::DiscSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) + return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); +} + +void Trk::DiscLayer::moveLayer(Amg::Transform3D& shift) { - Amg::Transform3D transf = shift * (*m_transform); - m_transform=std::make_unique<Amg::Transform3D>(transf); - m_center.store(std::make_unique<Amg::Vector3D>(m_transform->translation())); - m_normal.store(std::make_unique<Amg::Vector3D>(m_transform->rotation().col(2))); - // rebuild that - deletes the current one - if (m_approachDescriptor && m_approachDescriptor->rebuild()) - buildApproachDescriptor(); -} - -void Trk::DiscLayer::resizeLayer(const VolumeBounds& bounds, double envelope) { - // only do this if the volume bounds a CylinderVolumeBounds - const Trk::CylinderVolumeBounds* cvb = dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds); - if (cvb){ - // get the dimensions - double rInner = cvb->innerRadius(); - double rOuter = cvb->outerRadius(); - // (0) first, resize the layer itself - Trk::DiscBounds* rDiscBounds = new Trk::DiscBounds(rInner+envelope,rOuter-envelope); - Trk::DiscSurface::m_bounds = Trk::SharedObject<const Trk::SurfaceBounds>(rDiscBounds); - // (1) resize the material properties by updating the BinUtility, assuming r/phi binning - if (Trk::Layer::m_layerMaterialProperties.get() ){ - const BinUtility* layerMaterialBU = Trk::Layer::m_layerMaterialProperties->binUtility(); - if (layerMaterialBU && layerMaterialBU->binningValue(0) == Trk::binR ){ - size_t binsR = layerMaterialBU->max(0)+1; - // create a new binning with the new dimensions - Trk::BinUtility* rBinUtility = - new Trk::BinUtility(binsR,rInner+envelope,rOuter-envelope, Trk::open, Trk::binR); - // copy the second dimension over if exist - if (layerMaterialBU->dimensions()>1){ - (*rBinUtility) += Trk::BinUtility(layerMaterialBU->max(1)+1, -M_PI, M_PI, Trk::closed, Trk::binPhi); - } - Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility); - } - } - } - - if (m_approachDescriptor && m_approachDescriptor->rebuild()){ - // rebuild the approach descriptor - delete the current approach descriptor - buildApproachDescriptor(); - } - -} - -/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ -const Trk::Surface& Trk::DiscLayer::approachSurface(const Amg::Vector3D& pos, - const Amg::Vector3D& dir, - const Trk::BoundaryCheck& bcheck) const -{ - if (m_approachDescriptor){ - // get the test surfaces from the approach Descriptor - const Trk::ApproachSurfaces* surfacesOnApproach = m_approachDescriptor->approachSurfaces(pos,dir); - if (surfacesOnApproach){ - // test the intersections and go - std::vector<Trk::Intersection> sfIntersections; - const Trk::Surface* aSurface = nullptr; - double aPathLength = 10e10; - //!< @TODO -> optimise by breaking the loop if possible - for (auto& sfIter : (*surfacesOnApproach)){ - // get the intersection with the surface - Trk::Intersection sIntersection = sfIter->straightLineIntersection(pos, dir, true, bcheck); - // validation - if (sIntersection.valid && sIntersection.pathLength < aPathLength){ - aPathLength = sIntersection.pathLength; - aSurface = sfIter; - } - } - if (aSurface) return (*aSurface); - } - } - return surfaceRepresentation(); -} - -/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ -const Trk::Surface& Trk::DiscLayer::surfaceOnApproach(const Amg::Vector3D& pos, - const Amg::Vector3D& mom, - Trk::PropDirection pDir, - const Trk::BoundaryCheck& bcheck, - bool resolveSubSurfaces, - const Trk::ICompatibilityEstimator*) const -{ - // resolve the surfaces - if (m_approachDescriptor && resolveSubSurfaces){ - // resolve based on straight line intersection - return approachSurface(pos,double(pDir)*mom.unit(),bcheck); - } - return surfaceRepresentation(); -} - + Amg::Transform3D transf = shift * (*m_transform); + m_transform=std::make_unique<Amg::Transform3D>(transf); + m_center.store(std::make_unique<Amg::Vector3D>(m_transform->translation())); + m_normal.store(std::make_unique<Amg::Vector3D>(m_transform->rotation().col(2))); + // rebuild that - deletes the current one + if (m_approachDescriptor && m_approachDescriptor->rebuild()) { + buildApproachDescriptor(); + } +} + +void Trk::DiscLayer::resizeLayer(const VolumeBounds& bounds, double envelope) { + // only do this if the volume bounds a CylinderVolumeBounds + const Trk::CylinderVolumeBounds* cvb = dynamic_cast<const Trk::CylinderVolumeBounds*>(&bounds); + if (cvb){ + // get the dimensions + double rInner = cvb->innerRadius(); + double rOuter = cvb->outerRadius(); + // (0) first, resize the layer itself + Trk::DiscBounds* rDiscBounds = new Trk::DiscBounds(rInner+envelope,rOuter-envelope); + Trk::DiscSurface::m_bounds = Trk::SharedObject<const Trk::SurfaceBounds>(rDiscBounds); + // (1) resize the material properties by updating the BinUtility, assuming r/phi binning + if (Trk::Layer::m_layerMaterialProperties.get() ){ + const BinUtility* layerMaterialBU = Trk::Layer::m_layerMaterialProperties->binUtility(); + if (layerMaterialBU && layerMaterialBU->binningValue(0) == Trk::binR ){ + size_t binsR = layerMaterialBU->max(0)+1; + // create a new binning with the new dimensions + Trk::BinUtility* rBinUtility = + new Trk::BinUtility(binsR,rInner+envelope,rOuter-envelope, Trk::open, Trk::binR); + // copy the second dimension over if exist + if (layerMaterialBU->dimensions()>1){ + (*rBinUtility) += Trk::BinUtility(layerMaterialBU->max(1)+1, -M_PI, M_PI, Trk::closed, Trk::binPhi); + } + Trk::Layer::m_layerMaterialProperties->updateBinning(rBinUtility); + } + } + } + + if (m_approachDescriptor && m_approachDescriptor->rebuild()){ + // rebuild the approach descriptor - delete the current approach descriptor + buildApproachDescriptor(); + } + +} + +/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ +const Trk::Surface& Trk::DiscLayer::approachSurface(const Amg::Vector3D& pos, + const Amg::Vector3D& dir, + const Trk::BoundaryCheck& bcheck) const +{ + if (m_approachDescriptor){ + // get the test surfaces from the approach Descriptor + const Trk::ApproachSurfaces* surfacesOnApproach = m_approachDescriptor->approachSurfaces(pos,dir); + if (surfacesOnApproach){ + // test the intersections and go + std::vector<Trk::Intersection> sfIntersections; + const Trk::Surface* aSurface = nullptr; + double aPathLength = 10e10; + //!< @TODO -> optimise by breaking the loop if possible + for (auto& sfIter : (*surfacesOnApproach)){ + // get the intersection with the surface + Trk::Intersection sIntersection = sfIter->straightLineIntersection(pos, dir, true, bcheck); + // validation + if (sIntersection.valid && sIntersection.pathLength < aPathLength){ + aPathLength = sIntersection.pathLength; + aSurface = sfIter; + } + } + if (aSurface) return (*aSurface); + } + } + return surfaceRepresentation(); +} + +/** Surface seen on approach - if not defined differently, it is the surfaceRepresentation() */ +const Trk::Surface& Trk::DiscLayer::surfaceOnApproach(const Amg::Vector3D& pos, + const Amg::Vector3D& mom, + Trk::PropDirection pDir, + const Trk::BoundaryCheck& bcheck, + bool resolveSubSurfaces, + const Trk::ICompatibilityEstimator*) const +{ + // resolve the surfaces + if (m_approachDescriptor && resolveSubSurfaces){ + // resolve based on straight line intersection + return approachSurface(pos,double(pDir)*mom.unit(),bcheck); + } + return surfaceRepresentation(); +} + /** build approach surfaces */ void Trk::DiscLayer::buildApproachDescriptor(){ - // delete the current approach descriptor - delete m_approachDescriptor; + // create the surface container - Trk::ApproachSurfaces* aSurfaces = new Trk::ApproachSurfaces; + auto aSurfaces = std::make_unique<Trk::ApproachSurfaces>(); // get the center const auto halfThickness=0.5*thickness()*normal(); const Amg::Vector3D aspPosition(center()+halfThickness); @@ -255,7 +252,8 @@ void Trk::DiscLayer::buildApproachDescriptor(){ sIter->setOwner(Trk::TGOwn); } } - m_approachDescriptor = new Trk::ApproachDescriptor(aSurfaces); + //The approach descriptor takes owneship + m_approachDescriptor = std::make_unique<Trk::ApproachDescriptor>(std::move(aSurfaces)); } void Trk::DiscLayer::resizeAndRepositionLayer(const VolumeBounds& vBounds, const Amg::Vector3D& vCenter, double envelope) { diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/HomogeneousLayerMaterial.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/HomogeneousLayerMaterial.cxx index d778cf91d31416bc231909007f6f63e89338707d..a7103fc54919c89b3329166932c2a6f208b399d4 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/HomogeneousLayerMaterial.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/HomogeneousLayerMaterial.cxx @@ -26,7 +26,7 @@ Trk::HomogeneousLayerMaterial::HomogeneousLayerMaterial(const Trk::HomogeneousLa {} Trk::HomogeneousLayerMaterial::~HomogeneousLayerMaterial() -{} += default; Trk::HomogeneousLayerMaterial& Trk::HomogeneousLayerMaterial::operator=(const Trk::HomogeneousLayerMaterial& lmp) diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialLayer.cxx index f36c9f516e83877181fa1432a4f26d2f18f89793..537fe8e5f2a14d8e3bdef0d176cb2c842a22ea8b 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialLayer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -48,7 +48,7 @@ Trk::MaterialLayer::MaterialLayer(const Trk::MaterialLayer& lay): // destructor Trk::MaterialLayer::~MaterialLayer() -{} += default; Trk::MaterialLayer& Trk::MaterialLayer::operator =(const Trk::MaterialLayer& lay) { diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialProperties.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialProperties.cxx index 15d62b956253fb5d7a98f2665289975338020072..5b4ddede34eb611c941b31be9d972b0d77f04adc 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialProperties.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialProperties.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -39,12 +39,9 @@ Trk::MaterialProperties::MaterialProperties(const Trk::Material& material, float m_zOaTrTd( material.A*material.A > 10e-10 ? path*material.Z/material.A*material.rho : 0.) {} -Trk::MaterialProperties::MaterialProperties(const Trk::MaterialProperties& mprop) : - m_material(mprop.m_material), - m_dInX0(mprop.m_dInX0), - m_dInL0(mprop.m_dInL0), - m_zOaTrTd(mprop.m_zOaTrTd) -{} +Trk::MaterialProperties::MaterialProperties(const Trk::MaterialProperties& mprop) + += default; Trk::MaterialProperties* Trk::MaterialProperties::clone() const diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialStep.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialStep.cxx index 16f489f73fc219d0f2ec824266a623b7fe3338ba..39e3a36e97dc2ec43914c519b97545529c93ab37 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/MaterialStep.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/MaterialStep.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -59,16 +59,12 @@ Trk::MaterialStep::MaterialStep( {} Trk::MaterialStep::MaterialStep(const MaterialStep& mstep) - : m_steplength(mstep.m_steplength), - m_hitX(mstep.m_hitX), - m_hitY(mstep.m_hitY), - m_hitZ(mstep.m_hitZ), - m_hitR(mstep.m_hitR), - m_material(mstep.m_material) + + - {} + = default; -Trk::MaterialStep::~MaterialStep() {} +Trk::MaterialStep::~MaterialStep() = default; Trk::MaterialStep& Trk::MaterialStep::operator =( const Trk::MaterialStep& mstep ) { diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/PlaneLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/PlaneLayer.cxx index 3e1fef12cb9dc74b2cbe14026f7c1b60239af8f2..3dfeb027b27ebe431d7199f9f420cf89719b451a 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/PlaneLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/PlaneLayer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -136,10 +136,9 @@ Trk::PlaneLayer::PlaneLayer(Amg::Transform3D* transform, Layer(surfaceArray, laymatprop, thickness, olap, laytyp) {} -Trk::PlaneLayer::PlaneLayer(const Trk::PlaneLayer& play): - PlaneSurface(play), - Layer(play) -{} +Trk::PlaneLayer::PlaneLayer(const Trk::PlaneLayer& play) + += default; Trk::PlaneLayer::PlaneLayer(const Trk::PlaneLayer& play, const Amg::Transform3D& transf): PlaneSurface(play, transf), diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedCylinderLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedCylinderLayer.cxx index 1baa90d8d3722092a2045fa9d3886cf75f8a3735..06a000589c5e96d59d6aae6e1582d7de56fb1284 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedCylinderLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedCylinderLayer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -24,10 +24,9 @@ Trk::SubtractedCylinderLayer::SubtractedCylinderLayer(const Trk::SubtractedCylin Layer(laymatprop, thickness, olap, laytyp) {} -Trk::SubtractedCylinderLayer::SubtractedCylinderLayer(const Trk::SubtractedCylinderLayer& clay): - SubtractedCylinderSurface(clay), - Layer(clay) -{} +Trk::SubtractedCylinderLayer::SubtractedCylinderLayer(const Trk::SubtractedCylinderLayer& clay) + += default; Trk::SubtractedCylinderLayer::SubtractedCylinderLayer(const Trk::SubtractedCylinderLayer& clay, const Amg::Transform3D& transf): SubtractedCylinderSurface(clay, transf), diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedPlaneLayer.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedPlaneLayer.cxx index 635afffcea5a2ad7b9965e048258243c5aedcdf9..81bccc44a77df5e7f709ae5163a214b4df9c3490 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedPlaneLayer.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/SubtractedPlaneLayer.cxx @@ -1,76 +1,75 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// SubtractedPlaneLayer.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// Trk -#include "TrkGeometry/SubtractedPlaneLayer.h" -#include "TrkGeometry/LayerMaterialProperties.h" -#include "TrkGeometry/MaterialProperties.h" -#include "TrkParameters/TrackParameters.h" -// CLHEP -#include "GeoPrimitives/GeoPrimitives.h" - -Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const SubtractedPlaneSurface* subtrPlaneSurf, - const Trk::LayerMaterialProperties& laymatprop, - double thickness, - Trk::OverlapDescriptor* olap, - int laytyp) : - SubtractedPlaneSurface(*subtrPlaneSurf), - Layer(laymatprop, thickness, olap, laytyp) -{} - -Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const Trk::SubtractedPlaneLayer& play): - SubtractedPlaneSurface(play), - Layer(play) -{} - -Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const Trk::SubtractedPlaneLayer& play, const Amg::Transform3D& transf): - SubtractedPlaneSurface(play,transf), - Layer(play) -{} - -Trk::SubtractedPlaneLayer& Trk::SubtractedPlaneLayer::operator=(const SubtractedPlaneLayer& play) -{ - if (this!=&play){ - // call the assignments of the base classes - Trk::SubtractedPlaneSurface::operator=(play); - Trk::Layer::operator=(play); - } - return(*this); -} - -const Trk::SubtractedPlaneSurface& Trk::SubtractedPlaneLayer::surfaceRepresentation() const -{ - return (*this); -} - -double Trk::SubtractedPlaneLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0.; - if (Trk::SubtractedPlaneSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) - return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); -} - -double Trk::SubtractedPlaneLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, - Trk::PropDirection dir) const -{ - if (!Trk::Layer::m_layerMaterialProperties.get()) - return 0.; - if (Trk::SubtractedPlaneSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) - return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); - return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); -} - -void Trk::SubtractedPlaneLayer::moveLayer(Amg::Transform3D& shift) { +/////////////////////////////////////////////////////////////////// +// SubtractedPlaneLayer.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// Trk +#include "TrkGeometry/SubtractedPlaneLayer.h" +#include "TrkGeometry/LayerMaterialProperties.h" +#include "TrkGeometry/MaterialProperties.h" +#include "TrkParameters/TrackParameters.h" +// CLHEP +#include "GeoPrimitives/GeoPrimitives.h" + +Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const SubtractedPlaneSurface* subtrPlaneSurf, + const Trk::LayerMaterialProperties& laymatprop, + double thickness, + Trk::OverlapDescriptor* olap, + int laytyp) : + SubtractedPlaneSurface(*subtrPlaneSurf), + Layer(laymatprop, thickness, olap, laytyp) +{} + +Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const Trk::SubtractedPlaneLayer& play) + += default; + +Trk::SubtractedPlaneLayer::SubtractedPlaneLayer(const Trk::SubtractedPlaneLayer& play, const Amg::Transform3D& transf): + SubtractedPlaneSurface(play,transf), + Layer(play) +{} + +Trk::SubtractedPlaneLayer& Trk::SubtractedPlaneLayer::operator=(const SubtractedPlaneLayer& play) +{ + if (this!=&play){ + // call the assignments of the base classes + Trk::SubtractedPlaneSurface::operator=(play); + Trk::Layer::operator=(play); + } + return(*this); +} + +const Trk::SubtractedPlaneSurface& Trk::SubtractedPlaneLayer::surfaceRepresentation() const +{ + return (*this); +} + +double Trk::SubtractedPlaneLayer::preUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0.; + if (Trk::SubtractedPlaneSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) + return Trk::Layer::m_layerMaterialProperties->alongPreFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePreFactor(); +} + +double Trk::SubtractedPlaneLayer::postUpdateMaterialFactor(const Trk::TrackParameters& parm, + Trk::PropDirection dir) const +{ + if (!Trk::Layer::m_layerMaterialProperties.get()) + return 0.; + if (Trk::SubtractedPlaneSurface::normal().dot(dir*parm.momentum().normalized()) > 0. ) + return Trk::Layer::m_layerMaterialProperties->alongPostFactor(); + return Trk::Layer::m_layerMaterialProperties->oppositePostFactor(); +} + +void Trk::SubtractedPlaneLayer::moveLayer(Amg::Transform3D& shift) { Amg::Transform3D transf = shift * (*m_transform); m_transform=std::make_unique<Amg::Transform3D>(transf); m_center.store(std::make_unique<Amg::Vector3D>(m_transform->translation())); m_normal.store(std::make_unique<Amg::Vector3D>(m_transform->rotation().col(2))); -} +} diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx index 5be02d9217798ed5410bb5076f60a0f77eee2be6..673b66f310f0abb2240fd7cc8aef8d77a124c6da 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx @@ -895,10 +895,14 @@ void Trk::TrackingVolume::createBoundarySurfaces ATLAS_NOT_THREAD_SAFE () m_boundarySurfaces->push_back(Trk::SharedObject<const Trk::BoundarySurface<Trk::TrackingVolume> > (new Trk::BoundarySubtractedPlaneSurface<Trk::TrackingVolume>(in, out, *spsf))); delete spsf; continue; - } else if (psf){ m_boundarySurfaces->push_back(Trk::SharedObject<const Trk::BoundarySurface<Trk::TrackingVolume> > - (new Trk::BoundaryPlaneSurface<Trk::TrackingVolume>(in, out, *psf))); - delete psf; continue; - } + } + if (psf) { + m_boundarySurfaces->push_back( + Trk::SharedObject<const Trk::BoundarySurface<Trk::TrackingVolume>>( + new Trk::BoundaryPlaneSurface<Trk::TrackingVolume>(in, out, *psf))); + delete psf; + continue; + } const Trk::DiscSurface* dsf = dynamic_cast<const Trk::DiscSurface*>(*surfIter); if (dsf) { @@ -915,13 +919,18 @@ void Trk::TrackingVolume::createBoundarySurfaces ATLAS_NOT_THREAD_SAFE () m_boundarySurfaces->push_back(Trk::SharedObject<const Trk::BoundarySurface< Trk::TrackingVolume> > (new Trk::BoundarySubtractedCylinderSurface<Trk::TrackingVolume>(inner, outer, *scsf))); delete scsf; continue; - } else if (csf) { - Trk::TrackingVolume* inner = (sfCounter == 4 && sfNumber > 3) ? nullptr : this; - Trk::TrackingVolume* outer = (inner) ? nullptr : this; - m_boundarySurfaces->push_back(Trk::SharedObject<const Trk::BoundarySurface< Trk::TrackingVolume> > - (new Trk::BoundaryCylinderSurface<Trk::TrackingVolume>(inner, outer, *csf))); - delete csf; continue; - } + } + if (csf) { + Trk::TrackingVolume* inner = + (sfCounter == 4 && sfNumber > 3) ? nullptr : this; + Trk::TrackingVolume* outer = (inner) ? nullptr : this; + m_boundarySurfaces->push_back( + Trk::SharedObject<const Trk::BoundarySurface<Trk::TrackingVolume>>( + new Trk::BoundaryCylinderSurface<Trk::TrackingVolume>( + inner, outer, *csf))); + delete csf; + continue; + } } } else {