diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/GXFMaterialEffects.h b/Tracking/TrkEvent/TrkTrack/TrkTrack/GXFMaterialEffects.h index 8efebd0c9a64b03c01061c72a42bf6a8b58059fb..7164f85e531e7c9e355779f9b816386313965f71 100644 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/GXFMaterialEffects.h +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/GXFMaterialEffects.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #ifndef TRKGXFMATERIALEFFECTS_H @@ -9,12 +9,6 @@ #include <memory> -/** - * These headers, as well as other headers in the TrkGlobalChi2Fitter package - * use modern C++11 memory ownership semantics expressed through smart - * pointers. See GlobalChi2Fitter.h for more information. - */ - namespace Trk { class MaterialEffectsOnTrack; class MaterialEffectsBase; @@ -23,108 +17,110 @@ namespace Trk { class MaterialProperties; /** - * @brief class that is similar to MaterialEffectsOnTrack, but has 'set' methods for more flexibility during track fitting - + * @brief class that is similar to MaterialEffectsOnTrack, + * but has 'set' methods for more flexibility during track fitting @author thijs.cornelissen@cern.ch */ - class GXFMaterialEffects { public: - GXFMaterialEffects(); - - /** - * @brief Constructor that captures the properties of a more standard - * MaterialEffectsOnTrack object. - * - * This is one of the possible constructors for GXFMaterialEffects. It - * takes as an argument a MaterialEffectsOnTrack, which is the more widely - * used class to represent material effects. It copies the properties of - * the passed object pointer. - * - * @note This method assumes no ownership of the passed pointer whatsoever, - * and ownership of the MaterialEffectsOnTrack remains the responsibility - * of the original owner. - */ - GXFMaterialEffects(const MaterialEffectsOnTrack *); - GXFMaterialEffects(GXFMaterialEffects &); - GXFMaterialEffects & operator=(GXFMaterialEffects & rhs); + /** + * @brief Constructor that captures the properties of a more standard + * MaterialEffectsOnTrack object. + * + * This is one of the possible constructors for GXFMaterialEffects. It + * takes as an argument a MaterialEffectsOnTrack, which is the more widely + * used class to represent material effects. It copies the properties of + * the passed object pointer. + * + * @note This method assumes no ownership of the passed pointer whatsoever, + * and ownership of the MaterialEffectsOnTrack remains the responsibility + * of the original owner. + */ + GXFMaterialEffects(const MaterialEffectsOnTrack &); + GXFMaterialEffects() = default; + GXFMaterialEffects(const GXFMaterialEffects &rhs); + GXFMaterialEffects &operator=(const GXFMaterialEffects &rhs); + GXFMaterialEffects(GXFMaterialEffects &&rhs) = default; + GXFMaterialEffects &operator=(GXFMaterialEffects &&rhs) = default; + ~GXFMaterialEffects() = default; - void setScatteringAngles(double, double); - void setScatteringSigmas(double, double); - double x0() const; - void setX0(double); - double deltaPhi() const; - double measuredDeltaPhi() const; - void setMeasuredDeltaPhi(double); - double deltaTheta() const; - double sigmaDeltaPhi() const; - double sigmaDeltaTheta() const; - double deltaE() const; + void setScatteringAngles(double, double); + void setScatteringSigmas(double, double); + double x0() const; + void setX0(double); + double deltaPhi() const; + double measuredDeltaPhi() const; + void setMeasuredDeltaPhi(double); + double deltaTheta() const; + double sigmaDeltaPhi() const; + double sigmaDeltaTheta() const; + double deltaE() const; - /** - * @brief Set the energy loss properties of this material effect. - * - * This method sets the energy loss properties of the material effects - * instance through an instance of Trk::EnergyLoss. - * - * @note This method assumes full ownership of the passed pointer. - */ - void setEloss(std::unique_ptr<EnergyLoss>); - double sigmaDeltaE() const; - double sigmaDeltaEPos() const; - double sigmaDeltaENeg() const; - double sigmaDeltaEAve() const; - void setDeltaE(double); - void setSigmaDeltaE(double); - void setSigmaDeltaEPos(double); - void setSigmaDeltaENeg(double); - double delta_p() const; - void setdelta_p(double); - void setKink(bool); - bool isKink() const; - void setMeasuredEloss(bool); - bool isMeasuredEloss() const; - const Surface &associatedSurface() const; + /** + * @brief Set the energy loss properties of this material effect. + * + * This method sets the energy loss properties of the material effects + * instance through an instance of Trk::EnergyLoss. + * + * @note This method assumes full ownership of the passed pointer. + */ + void setEloss(std::unique_ptr<EnergyLoss>); + double sigmaDeltaE() const; + double sigmaDeltaEPos() const; + double sigmaDeltaENeg() const; + double sigmaDeltaEAve() const; + void setDeltaE(double); + void setSigmaDeltaE(double); + void setSigmaDeltaEPos(double); + void setSigmaDeltaENeg(double); + double delta_p() const; + void setdelta_p(double); + void setKink(bool); + bool isKink() const; + void setMeasuredEloss(bool); + bool isMeasuredEloss() const; + const Surface &associatedSurface() const; - /** - * @brief Set the surface for this material effects instance. - * - * This method links the instance of GXFMaterialEffects to a surface. The - * surface can then be accessed through the surface() method. - * - * @note This method does NOT assume ownership of the passed pointer. - */ - void setSurface(const Surface *); - std::unique_ptr<MaterialEffectsBase> makeMEOT() const; - const MaterialProperties *materialProperties() const; + /** + * @brief Set the surface for this material effects instance. + * + * This method links the instance of GXFMaterialEffects to a surface. The + * surface can then be accessed through the surface() method. + * + * @note This method does NOT assume ownership of the passed pointer. + */ + void setSurface(const Surface *); + std::unique_ptr<MaterialEffectsBase> makeMEOT() const; + const MaterialProperties *materialProperties() const; - /** - * @brief Set the material properties of this material effects instance. - * - * @note The argument pointer is a raw, non-owning pointer and the method - * assumes no ownership of the pointee. - */ - void setMaterialProperties(const MaterialProperties *); + /** + * @brief Set the material properties of this material effects instance. + * + * @note The argument pointer is a raw, non-owning pointer and the method + * assumes no ownership of the pointee. + */ + void setMaterialProperties(const MaterialProperties *); private: - double m_scatphi; - double m_scattheta; - double m_sigmascatphi; - double m_sigmascattheta; - double m_x0; - double m_deltap; - double m_deltae; - double m_sigmadeltae; - double m_sigmadeltaepos; - double m_sigmadeltaeneg; - std::unique_ptr<const EnergyLoss> m_eloss; - const Surface *m_surf; - const MaterialProperties *m_matprop; - bool m_iskink; - bool m_ismeasuredeloss; - double m_measscatphi; // fudge to stabilize fit in muon system - double m_sintheta; + double m_scatphi = 0; + double m_scattheta = 0; + double m_sigmascatphi = 0; + double m_sigmascattheta = 0; + double m_x0 = 0; + double m_deltap = 0; + double m_deltae = 0; + double m_sigmadeltae = 0; + double m_sigmadeltaepos = 0; + double m_sigmadeltaeneg = 0; + std::unique_ptr<const EnergyLoss> m_eloss; + //not owning ptrs + const Surface *m_surf = nullptr; + const MaterialProperties *m_matprop = nullptr; + bool m_iskink = false; + bool m_ismeasuredeloss = false; + double m_measscatphi = 0; // fudge to stabilize fit in muon system + double m_sintheta = 1; }; } #endif diff --git a/Tracking/TrkEvent/TrkTrack/src/GXFMaterialEffects.cxx b/Tracking/TrkEvent/TrkTrack/src/GXFMaterialEffects.cxx index f8af23b686d6fa291201f1c313e4b9970455cec3..d537b43a70a1c2e53e391c562067ef72328f7a21 100644 --- a/Tracking/TrkEvent/TrkTrack/src/GXFMaterialEffects.cxx +++ b/Tracking/TrkEvent/TrkTrack/src/GXFMaterialEffects.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #include "TrkTrack/GXFMaterialEffects.h" @@ -9,37 +9,17 @@ #include "TrkMaterialOnTrack/EnergyLoss.h" namespace Trk { - GXFMaterialEffects::GXFMaterialEffects() - : m_scatphi (0), - m_scattheta (0), - m_sigmascatphi (0), - m_sigmascattheta (0), - m_x0 (0), - m_deltap (0), - m_deltae (0), - m_sigmadeltae (0), - m_sigmadeltaepos (0), - m_sigmadeltaeneg (0), - m_surf (nullptr), - m_matprop (nullptr), - m_iskink (false), - m_ismeasuredeloss (true), - m_measscatphi (0), - m_sintheta (1) - { - } + GXFMaterialEffects::GXFMaterialEffects(const MaterialEffectsOnTrack &meot) + : m_sigmadeltae(0), m_surf(&meot.associatedSurface()) { - GXFMaterialEffects::GXFMaterialEffects(const MaterialEffectsOnTrack *meot) - : m_sigmadeltae(0) { + if (meot.energyLoss() != nullptr) { + m_deltae = meot.energyLoss()->deltaE(); + m_sigmadeltaepos = meot.energyLoss()->sigmaPlusDeltaE(); + m_sigmadeltaeneg = meot.energyLoss()->sigmaMinusDeltaE(); - if (meot->energyLoss() != nullptr) { - m_deltae = meot->energyLoss()->deltaE(); - m_sigmadeltaepos = meot->energyLoss()->sigmaPlusDeltaE(); - m_sigmadeltaeneg = meot->energyLoss()->sigmaMinusDeltaE(); - - if (meot->scatteringAngles() == nullptr) { - m_eloss = std::unique_ptr<EnergyLoss>(meot->energyLoss()->clone()); - m_sigmadeltae = meot->energyLoss()->sigmaDeltaE(); + if (meot.scatteringAngles() == nullptr) { + m_eloss = std::unique_ptr<EnergyLoss>(meot.energyLoss()->clone()); + m_sigmadeltae = meot.energyLoss()->sigmaDeltaE(); } else { m_eloss = nullptr; } @@ -50,13 +30,9 @@ namespace Trk { m_sigmadeltaeneg = 0; } - m_x0 = 0; - m_sintheta = 1; - - double x0 = meot->thicknessInX0(); + double x0 = meot.thicknessInX0(); + const ScatteringAngles *scatangles = meot.scatteringAngles(); - const ScatteringAngles *scatangles = meot->scatteringAngles(); - if ((scatangles != nullptr) && x0 > 0) { m_x0 = x0; m_sintheta = scatangles->sigmaDeltaTheta() / scatangles->sigmaDeltaPhi(); @@ -67,16 +43,9 @@ namespace Trk { } else { m_scatphi = m_scattheta = m_sigmascatphi = m_sigmascattheta = 0; } - - m_surf = &meot->associatedSurface(); - m_matprop = nullptr; - m_iskink = false; - m_ismeasuredeloss = true; - m_deltap = 0; - m_measscatphi = 0; } - GXFMaterialEffects::GXFMaterialEffects(GXFMaterialEffects & rhs) + GXFMaterialEffects::GXFMaterialEffects(const GXFMaterialEffects & rhs) : m_scatphi (rhs.m_scatphi), m_scattheta (rhs.m_scattheta), m_sigmascatphi (rhs.m_sigmascatphi), @@ -97,7 +66,7 @@ namespace Trk { { } - GXFMaterialEffects & GXFMaterialEffects::operator =(GXFMaterialEffects & rhs) { + GXFMaterialEffects & GXFMaterialEffects::operator = (const GXFMaterialEffects & rhs) { if (this != &rhs) { m_eloss = std::unique_ptr<EnergyLoss>(rhs.m_eloss != nullptr ? rhs.m_eloss->clone() : nullptr); m_scatphi = rhs.m_scatphi; diff --git a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx index 97d792e1e20642582e536de1c33b7fea7e90c484..0fe60b826c0b40066cfb1b5375c61eb7ad3c30ac 100644 --- a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx +++ b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx @@ -1142,9 +1142,9 @@ namespace Trk { } } - std::unique_ptr<GXFMaterialEffects> firstscatmeff = std::make_unique<GXFMaterialEffects>(&calomeots[0]); - std::unique_ptr<GXFMaterialEffects> elossmeff = std::make_unique<GXFMaterialEffects>(&calomeots[1]); - std::unique_ptr<GXFMaterialEffects> secondscatmeff = std::make_unique<GXFMaterialEffects>(&calomeots[2]); + std::unique_ptr<GXFMaterialEffects> firstscatmeff = std::make_unique<GXFMaterialEffects>(calomeots[0]); + std::unique_ptr<GXFMaterialEffects> elossmeff = std::make_unique<GXFMaterialEffects>(calomeots[1]); + std::unique_ptr<GXFMaterialEffects> secondscatmeff = std::make_unique<GXFMaterialEffects>(calomeots[2]); double pull1 = std::abs(firstscatphi / firstscatmeff->sigmaDeltaPhi()); double pull2 = std::abs(secondscatphi / secondscatmeff->sigmaDeltaPhi()); @@ -1474,9 +1474,9 @@ namespace Trk { } } - std::unique_ptr<GXFMaterialEffects> firstscatmeff = std::make_unique<GXFMaterialEffects>(&calomeots[0]); - std::unique_ptr<GXFMaterialEffects> elossmeff = std::make_unique<GXFMaterialEffects>(&calomeots[1]); - std::unique_ptr<GXFMaterialEffects> secondscatmeff = std::make_unique<GXFMaterialEffects>(&calomeots[2]); + std::unique_ptr<GXFMaterialEffects> firstscatmeff = std::make_unique<GXFMaterialEffects>(calomeots[0]); + std::unique_ptr<GXFMaterialEffects> elossmeff = std::make_unique<GXFMaterialEffects>(calomeots[1]); + std::unique_ptr<GXFMaterialEffects> secondscatmeff = std::make_unique<GXFMaterialEffects>(calomeots[2]); double dp = 0; double sigmadp = 0; @@ -2632,7 +2632,7 @@ namespace Trk { !tsos->type(TrackStateOnSurface::Scatterer) or (tsos->trackParameters() == nullptr) ) { - newmeff = std::make_unique<GXFMaterialEffects>(meff); + newmeff = std::make_unique<GXFMaterialEffects>(*meff); } else { Trk::MaterialProperties matprop(meff->thicknessInX0(), 1., 0., 0., 0., 0.); @@ -2657,7 +2657,7 @@ namespace Trk { tsos->surface() ); - newmeff = std::make_unique<GXFMaterialEffects>(&newmeot); + newmeff = std::make_unique<GXFMaterialEffects>(newmeot); } if ( @@ -3950,7 +3950,7 @@ namespace Trk { if (meb) { if (meb->derivedType() == MaterialEffectsBase::MATERIAL_EFFECTS_ON_TRACK) { const MaterialEffectsOnTrack *meot = static_cast < const MaterialEffectsOnTrack * >(meb); - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(meot); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot); const TrackParameters * newpars = (*matvec)[i]->trackParameters() != nullptr ? (*matvec)[i]->trackParameters()->clone() : nullptr; meff->setSigmaDeltaE(0); matstates.push_back(std::make_unique<GXFTrackState>( @@ -4053,7 +4053,7 @@ namespace Trk { if (meb) { if (meb->derivedType() == MaterialEffectsBase::MATERIAL_EFFECTS_ON_TRACK) { const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb); - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(meot); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot); if (cache.m_fiteloss && (meot->energyLoss() != nullptr)) { meff->setSigmaDeltaE(meot->energyLoss()->sigmaDeltaE()); } @@ -4121,7 +4121,7 @@ namespace Trk { return; } - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(&calomeots[i]); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(calomeots[i]); if (i == 2) { lastcalopar = layerpar.get(); @@ -4180,7 +4180,7 @@ namespace Trk { return; } - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(&calomeots[i]); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(calomeots[i]); if (i == 2) { firstcalopar = unique_clone(layerpar.get()).release(); @@ -4353,7 +4353,7 @@ namespace Trk { if (meb) { if ((meb->derivedType() == MaterialEffectsBase::MATERIAL_EFFECTS_ON_TRACK) and (j < (int) matvec->size() - 1)) { const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb); - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(meot); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot); if ( !trajectory.m_straightline && @@ -4465,7 +4465,7 @@ namespace Trk { if ((meb->derivedType() == MaterialEffectsBase::MATERIAL_EFFECTS_ON_TRACK) && j < (int) matvec->size() - 1) { const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb); - std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(meot); + std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot); if ( !trajectory.m_straightline &&