From 0241ee09d2f4b21940ecaffae76f5629c2b2099d Mon Sep 17 00:00:00 2001 From: Frank Winklmeier Date: Thu, 15 Sep 2022 17:44:24 +0200 Subject: [PATCH] ISF_FatrasTools: const fixes - replace unnecessary statics by constexpr - various thread-checker fixes --- .../src/EnergyLossSamplerBetheHeitler.h | 4 +-- .../src/McMaterialEffectsUpdator.cxx | 4 +-- .../src/McMaterialEffectsUpdator.h | 4 +-- ...ltipleScatteringSamplerGaussianMixture.cxx | 34 ++++++++++--------- ...MultipleScatteringSamplerGaussianMixture.h | 25 +------------- ...ultipleScatteringSamplerGeneralMixture.cxx | 14 ++++---- .../MultipleScatteringSamplerGeneralMixture.h | 15 ++------ .../src/MultipleScatteringSamplerHighland.cxx | 13 +++---- .../src/MultipleScatteringSamplerHighland.h | 12 +------ .../src/PhotonConversionTool.cxx | 17 +++++----- .../src/PhotonConversionTool.h | 7 ++-- 11 files changed, 52 insertions(+), 97 deletions(-) diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/EnergyLossSamplerBetheHeitler.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/EnergyLossSamplerBetheHeitler.h index 72dedfc7675..fcc6fe0ce29 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/EnergyLossSamplerBetheHeitler.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/EnergyLossSamplerBetheHeitler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -76,8 +76,6 @@ namespace iFatras{ /** Name of the random number stream */ std::string m_randomEngineName; - mutable std::vector m_pdf; - /** the one free parameter to scale */ double m_scaleFactor; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx index 067652a272e..89cab92a9ea 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx @@ -1575,7 +1575,7 @@ iFatras::McMaterialEffectsUpdator::interact(double time, if ( process == 5 ) { // positron annihilation - static ISF::ISFParticleVector children(2); + ISF::ISFParticleVector children(2); double fmin = mass/p; @@ -1688,7 +1688,7 @@ ISF::ISFParticleVector iFatras::McMaterialEffectsUpdator::interactLay(const ISF if ( process == 5 ) { // positron annihilation - static ISF::ISFParticleVector children(2); + ISF::ISFParticleVector children(2); double fmin = mass/p; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.h index f645419066c..f96ae6ec715 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.h @@ -272,10 +272,10 @@ private: std::string m_randomEngineName; //!< Name of the random number stream /** for statistics output */ - mutable int m_recordedBremPhotons; + mutable std::atomic m_recordedBremPhotons; /** for the calo energy recording */ - mutable int m_currentSample; //!< the currentSample + int m_currentSample; //!< the currentSample bool m_recordEnergyDeposition; //!< for deposition methods std::string m_layerIndexCaloSampleMapName; //!< name to record it mutable const Trk::LayerIndexSampleMap* diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.cxx index f5fa5900f47..e46c3c835a8 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.cxx @@ -15,27 +15,29 @@ #include "TrkEventPrimitives/ParticleHypothesis.h" -// static doubles -double iFatras::MultipleScatteringSamplerGaussianMixture::s_main_RutherfordScott = 13.6*Gaudi::Units::MeV; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_log_RutherfordScott = 0.038; +namespace { + constexpr double s_main_RutherfordScott = 13.6*Gaudi::Units::MeV; //!< main factor of Rutherford-Scott formula + constexpr double s_log_RutherfordScott = 0.038; //!< log factor of Rutherford-Scott formula -double iFatras::MultipleScatteringSamplerGaussianMixture::s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_log_RossiGreisen = 0.125; + constexpr double s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; //!< main factor for Rossi-Greisen formula + constexpr double s_log_RossiGreisen = 0.125; //!< log factor for Rossi-Greisen formula -// ============================= Gaussian mixture model ============= -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixSigma1_a0 = 8.471e-1; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixSigma1_a1 = 3.347e-2; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixSigma1_a2 = -1.843e-3; + // ========= Gaussian mixture model Fruehwirth, Regler Nucl. Inst. Methods A 456(2001) ========= + constexpr double s_gausMixSigma1_a0 = 8.471e-1; //!< Gaussian mixture model: Sigma parameter a0 + constexpr double s_gausMixSigma1_a1 = 3.347e-2; //!< Gaussian mixture model: Sigma parameter a1 + constexpr double s_gausMixSigma1_a2 = -1.843e-3; //!< Gaussian mixture model: Sigma parameter a2 -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_a0 = 4.841e-2; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_a1 = 6.348e-3; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_a2 = 6.096e-4; + constexpr double s_gausMixEpsilon_a0 = 4.841e-2; //!< Gaussian mixture model: Epsilon parameter a0 + constexpr double s_gausMixEpsilon_a1 = 6.348e-3; //!< Gaussian mixture model: Epsilon parameter a1 + constexpr double s_gausMixEpsilon_a2 = 6.096e-4; //!< Gaussian mixture model: Epsilon parameter a2 -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_b0 = -1.908e-2; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_b1 = 1.106e-1; -double iFatras::MultipleScatteringSamplerGaussianMixture::s_gausMixEpsilon_b2 = -5.729e-3; + constexpr double s_gausMixEpsilon_b0 = -1.908e-2; //!< Gaussian mixture model: Epsilon parameter b0 + constexpr double s_gausMixEpsilon_b1 = 1.106e-1; //!< Gaussian mixture model: Epsilon parameter b1 + constexpr double s_gausMixEpsilon_b2 = -5.729e-3; //!< Gaussian mixture model: Epsilon parameter b2 + + const double s_projectionFactor = sqrt(2.); //!< projection factor to scale the projected angle out of the plane +} -double iFatras::MultipleScatteringSamplerGaussianMixture::s_projectionFactor = sqrt(2.); // constructor iFatras::MultipleScatteringSamplerGaussianMixture::MultipleScatteringSamplerGaussianMixture(const std::string& t, const std::string& n, const IInterface* p) : diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.h index 4f4304e17f4..23a9e147e55 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGaussianMixture.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -69,29 +69,6 @@ namespace iFatras { /** Random engine */ CLHEP::HepRandomEngine* m_randomEngine; std::string m_randomEngineName; //!< Name of the random number stream - - static double s_main_RutherfordScott; //!< main factor of Rutherford-Scott formula - static double s_log_RutherfordScott; //!< log factor of Rutherford-Scott formula - - static double s_main_RossiGreisen; //!< main factor for Rossi-Greisen formula - static double s_log_RossiGreisen; //!< main factor for Rossi-Greisen formula - - - // ========= Gaussian mixture model Fruehwirth, Regler Nucl. Inst. Methods A 456(2001) ========= - static double s_gausMixSigma1_a0; //!< Gaussian mixture model: Sigma parameter a0 - static double s_gausMixSigma1_a1; //!< Gaussian mixture model: Sigma parameter a1 - static double s_gausMixSigma1_a2; //!< Gaussian mixture model: Sigma parameter a2 - - static double s_gausMixEpsilon_a0; //!< Gaussian mixture model: Epsilon parameter a0 - static double s_gausMixEpsilon_a1; //!< Gaussian mixture model: Epsilon parameter a1 - static double s_gausMixEpsilon_a2; //!< Gaussian mixture model: Epsilon parameter a2 - - static double s_gausMixEpsilon_b0; //!< Gaussian mixture model: Epsilon parameter b0 - static double s_gausMixEpsilon_b1; //!< Gaussian mixture model: Epsilon parameter b1 - static double s_gausMixEpsilon_b2; //!< Gaussian mixture model: Epsilon parameter b2 - - static double s_projectionFactor; //!< projection factor to scale the projected angle out of the plane - }; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.cxx index 0dad812117b..55b6e6db297 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.cxx @@ -14,16 +14,16 @@ #include "TrkEventPrimitives/ParticleHypothesis.h" -// static particle masses -// doubles +namespace { + constexpr double s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; //!< main factor for Rossi-Greisen formula + constexpr double s_log_RossiGreisen = 0.125; //!< main factor for Rossi-Greisen formula -double iFatras::MultipleScatteringSamplerGeneralMixture::s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; -double iFatras::MultipleScatteringSamplerGeneralMixture::s_log_RossiGreisen = 0.125; + const double s_projectionFactor = sqrt(2.); //!< projection factor to scale the projected angle out of the plane -double iFatras::MultipleScatteringSamplerGeneralMixture::s_projectionFactor = sqrt(2.); + // ========= General mixture model R.Frühwirth, M. Liendl. Comp. Phys. Comm. 141 (2001) 230–246 ========= + constexpr double s_genMixScale = 0.608236; //!< numerically derived scaling factor +} -// ============================= General mixture model ============= -double iFatras::MultipleScatteringSamplerGeneralMixture::s_genMixScale = 0.608236; //numerically derived scaling factor // constructor iFatras::MultipleScatteringSamplerGeneralMixture::MultipleScatteringSamplerGeneralMixture(const std::string& t, const std::string& n, const IInterface* p) : diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.h index 3c688b8f97b..78bfb8d6f3a 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerGeneralMixture.h @@ -59,24 +59,13 @@ namespace iFatras { private: bool m_log_include; //!< boolean switch to include log term - static double s_projectionFactor; //!< projection factor to scale the projected angle out of the plane - - //========== used for General mixture model ================================================= - + /** Random Generator service */ ServiceHandle m_rndGenSvc; /** Random engine */ CLHEP::HepRandomEngine* m_randomEngine; std::string m_randomEngineName; //!< Name of the random number stream - - - static double s_main_RossiGreisen; //!< main factor for Rossi-Greisen formula - static double s_log_RossiGreisen; //!< main factor for Rossi-Greisen formula - - - // ========= General mixture model R.Frühwirth, M. Liendl. Comp. Phys. Comm. 141 (2001) 230–246 ========= - static double s_genMixScale; //!< General mixture model: Scaling factor - + //!< General mixture model: get parameters for single gaussian simulation static std::vector getGaussian(double beta, double p,double dOverX0, double scale) ; //!< General mixture model: get parameters for gaussian mixture diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.cxx index 287d02f4f88..b55dd653897 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.cxx @@ -16,14 +16,15 @@ #include "TrkEventPrimitives/ParticleHypothesis.h" -// static doubles -double iFatras::MultipleScatteringSamplerHighland::s_main_RutherfordScott = 13.6*Gaudi::Units::MeV; -double iFatras::MultipleScatteringSamplerHighland::s_log_RutherfordScott = 0.038; +namespace { + constexpr double s_main_RutherfordScott = 13.6*Gaudi::Units::MeV; //!< main factor of Rutherford-Scott formula + constexpr double s_log_RutherfordScott = 0.038; //!< log factor of Rutherford-Scott formula -double iFatras::MultipleScatteringSamplerHighland::s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; -double iFatras::MultipleScatteringSamplerHighland::s_log_RossiGreisen = 0.125; + constexpr double s_main_RossiGreisen = 17.5*Gaudi::Units::MeV; //!< main factor for Rossi-Greisen formula + constexpr double s_log_RossiGreisen = 0.125; //!< main factor for Rossi-Greisen formula -double iFatras::MultipleScatteringSamplerHighland::s_projectionFactor = sqrt(2.); + const double s_projectionFactor = sqrt(2.); //!< projection factor to scale the projected angle out of the plane +} Trk::MaterialInteraction matInt; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.h index b9ab3d02387..e381ca27f77 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/MultipleScatteringSamplerHighland.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -73,16 +73,6 @@ namespace iFatras { CLHEP::HepRandomEngine* m_randomEngine; std::string m_randomEngineName; //!< Name of the random number stream - - static double s_main_RutherfordScott; //!< main factor of Rutherford-Scott formula - static double s_log_RutherfordScott; //!< log factor of Rutherford-Scott formula - - static double s_main_RossiGreisen; //!< main factor for Rossi-Greisen formula - static double s_log_RossiGreisen; //!< main factor for Rossi-Greisen formula - - static double s_projectionFactor; //!< projection factor to scale the projected angle out of the plane - - }; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.cxx index 909f9f0e40d..63ecbd9cfd1 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.cxx @@ -51,10 +51,13 @@ #include "TrkEventPrimitives/ParticleHypothesis.h" -// statics doubles -double iFatras::PhotonConversionTool::s_alpha = 1./137.; -double iFatras::PhotonConversionTool::s_oneOverThree = 1./3.; -Trk::PdgToParticleHypothesis iFatras::PhotonConversionTool::s_pdgToHypo; +/** Inverse fine structure constant */ +namespace { + constexpr double s_alpha = 1./137.; + constexpr double s_oneOverThree = 1./3.; +} + +const Trk::PdgToParticleHypothesis iFatras::PhotonConversionTool::s_pdgToHypo; // constructor iFatras::PhotonConversionTool::PhotonConversionTool(const std::string& t, const std::string& n, const IInterface* p) : @@ -314,8 +317,6 @@ ISF::ISFParticleVector iFatras::PhotonConversionTool::getChilds(const ISF::ISFPa const Amg::Vector3D& childDirection, Trk::ParticleHypothesis childType) const { - static ISF::ISFParticleVector children(2); - // calculate the child momentum double p1 = sqrt(childEnergy*childEnergy-Trk::ParticleMasses::mass[childType]*Trk::ParticleMasses::mass[childType]); @@ -363,8 +364,8 @@ ISF::ISFParticleVector iFatras::PhotonConversionTool::getChilds(const ISF::ISFPa time, *parent)); - children[0] = ch1.release(); - children[1] = ch2.release(); + ISF::ISFParticleVector children{ch1.release(), + ch2.release()}; // register TruthIncident ISF::ISFTruthIncident truth( const_cast(*parent), diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.h index 5b2547f11e1..1cdbf6d084d 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/PhotonConversionTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -157,10 +157,7 @@ namespace iFatras { mutable float m_conversionChildAngle; // -------------------------------------------------------------------------------- - static Trk::PdgToParticleHypothesis s_pdgToHypo; - /** Inverse fine structure constant */ - static double s_alpha; - static double s_oneOverThree; + static const Trk::PdgToParticleHypothesis s_pdgToHypo; }; -- GitLab