From bcea0ed531b2b462b7e96529118c75c149ffa619 Mon Sep 17 00:00:00 2001 From: jdevivi Date: Fri, 3 Dec 2021 14:44:29 +0100 Subject: [PATCH 1/5] more MT safe --- .../ATLAS_CHECK_THREAD_SAFETY | 1 + .../ElectronPhotonVariableCorrectionBase.h | 15 +--- .../ElectronPhotonVariableCorrectionBase.cxx | 69 ++++++++----------- 3 files changed, 30 insertions(+), 55 deletions(-) create mode 100644 PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ATLAS_CHECK_THREAD_SAFETY diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ATLAS_CHECK_THREAD_SAFETY b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 00000000000..31c05f14f0b --- /dev/null +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h index cfafd950278..a439b284e88 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h @@ -23,7 +23,6 @@ //Root includes #include "TF1.h" -#include "TRandom.h" // forward declarations class TObject; @@ -141,8 +140,6 @@ private: std::string m_correctionVariable; //! @brief Whether to apply normal correction or smearing correction bool m_doGaussianSmearing = false; - //! @brief TRandom3 for setting seed of random smearing correction - mutable TRandom m_random; //! @brief Values of discontinuities in the variable which should not be corrected std::vector m_uncorrectedDiscontinuities; //! @brief Function to use for the variable correction, TF1 style @@ -233,13 +230,12 @@ private: const StatusCode getObjectFromRootFile(TEnv& env, const int parameter_number, const TString& filePathKey, const TString& nameKey, std::unique_ptr& return_object); /** @brief Get the actual parameters entering the correction TF1 for the current e/y object to be corrected - * @param properties The vector where the values of the correction TF1 parameters will be saved in * @param pt The pT of the current e/y object to be corrected * @param eta The eta of the current e/y object to be corrected * @details As every electron/photon has different values of pT/eta, the correction function must be adapted accordingly for every e/y. The according values of * each of the correction function parameters are updated with this function. */ - const StatusCode getCorrectionParameters(std::vector& properties, const float pt, const float eta, const float phi) const; + const StatusCode getCorrectionParameters(const float pt, const float eta, const float phi) const; /** @brief Get the correction function parameter value if its type is eta- or pT-binned * @param return_parameter_value The respective correction function parameter value is saved in this parameter @@ -323,14 +319,7 @@ private: * @param original_variable The original value of the corrected variable * @param properties The vector containing the correction TF1 parameters so the correction TF1 can be set for the respective e/y object */ - const StatusCode correct(float& return_corrected_variable, const float original_variable, std::vector& properties) const; - - /** @brief Set the seed of the TRandom object m_random - * @param pt The pT value of the Egamma object - * @param eta The eta value of the Egamma object - * @param phi The phi value of the Egamma object - */ - StatusCode setRandomSeed(const float pt, const float eta, const float phi) const; + void correct(float& return_corrected_variable, const float original_variable, double rndSeed = 0.) const; }; //end class ElectronPhotonVariableCorrectionBase diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx index 755b0a09f50..7408e0b017b 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx @@ -24,6 +24,7 @@ #include "TGraph.h" #include "TH2.h" #include "TFile.h" +#include "TRandom3.h" //allow advanced math for the TF1 #include "TMath.h" @@ -227,9 +228,6 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } - //declare objects needed to retrieve photon properties - std::vector properties; //safe value of function parameter i at place i - properties.resize(m_numberOfFunctionParameters); float eta; //safe value of eta of event float pt; //safe pt of event float phi; //safe phi of event @@ -241,16 +239,14 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } ATH_MSG_VERBOSE("Got the photon kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi); - if (getCorrectionParameters(properties, pt, eta, phi) != StatusCode::SUCCESS) + if (getCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) { ATH_MSG_ERROR("Could not get the correction parameters for this photon object."); return CP::CorrectionCode::Error; } - for (auto p : properties) - ATH_MSG_VERBOSE("prop " << p); // Apply the correction, write to the corrected AuxElement - correct((*m_variableToCorrect)(photon),original_variable, properties).ignore(); // ignore as will always return SUCCESS + correct((*m_variableToCorrect)(photon),original_variable); // everything worked out, so return CP::CorrectionCode::Ok; @@ -284,9 +280,6 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } - //declare objects needed to retrieve electron properties - std::vector properties; //safe value of function parameter i at place i - properties.resize(m_numberOfFunctionParameters); float eta; //safe value of eta of event float pt; //safe pt of event float phi; //safe phi of event @@ -298,7 +291,7 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } ATH_MSG_VERBOSE("Got the electron kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi); - if (getCorrectionParameters(properties, pt, eta, phi) != StatusCode::SUCCESS) + if (getCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) { ATH_MSG_ERROR("Could not get the correction parameters for this electron object."); return CP::CorrectionCode::Error; @@ -306,33 +299,21 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x // If applying a Gaussian smearing correction, set the seed based on the // electron properties + double rndSeed(0); if (m_doGaussianSmearing) { - if (setRandomSeed(pt, eta, phi) != StatusCode::SUCCESS) - { - ATH_MSG_ERROR("Error setting TRandom Seed"); - return CP::CorrectionCode::Error; - } + rndSeed = 1 + pt + std::abs(eta) * 1E3 + std::abs(phi) * 1E6; } - for (auto p : properties) - ATH_MSG_VERBOSE("prop " << p); - // Apply the correction, write to the corrected AuxElement - correct((*m_variableToCorrect)(electron),original_variable, properties).ignore(); // ignore as will always return SUCCESS + correct((*m_variableToCorrect)(electron),original_variable, rndSeed); // everything worked out, so return CP::CorrectionCode::Ok; } -const StatusCode ElectronPhotonVariableCorrectionBase::correct(float& return_corrected_variable, const float original_variable, std::vector& properties) const +void ElectronPhotonVariableCorrectionBase::correct(float& return_corrected_variable, const float original_variable, double rndSeed) const { - // set the parameters of the correction function - for (unsigned int parameter_itr = 0; parameter_itr < properties.size(); parameter_itr++) - { - m_correctionFunctionTF1->SetParameter(parameter_itr,properties.at(parameter_itr)); - } - ATH_MSG_VERBOSE("original var " << original_variable); // If not smearing, apply correction in normal way @@ -346,9 +327,8 @@ const StatusCode ElectronPhotonVariableCorrectionBase::correct(float& return_cor // otherwise default range is 0 to 1, and shape of PDF will be incorrect // NB - this assumes random function is a Gaussian, or at least a PDF // with a mean and width parameters - const double gaussMean = properties.at(0); - const double gaussAbsWidth = std::abs(properties.at(1)); - const double gaussWidth = properties.at(1); + const double gaussMean = m_correctionFunctionTF1->GetParameter(0); + const double gaussAbsWidth = std::abs(m_correctionFunctionTF1->GetParameter(1)); const double maxRange = gaussMean + 5*gaussAbsWidth; const double minRange = gaussMean - 5*gaussAbsWidth; @@ -359,29 +339,22 @@ const StatusCode ElectronPhotonVariableCorrectionBase::correct(float& return_cor m_correctionFunctionTF1->SetNpx(500); // If the Gaussian width is 0, can't use GetRandom() - just apply shift - if (gaussWidth == 0.0) + if (gaussAbsWidth == 0.0) { return_corrected_variable = original_variable + gaussMean; } // Otherwise, can apply smear using GetRandom on TF1 else { - return_corrected_variable = original_variable + m_correctionFunctionTF1->GetRandom(&m_random); + TRandom3 rnd; + rnd.SetSeed(rndSeed); + return_corrected_variable = original_variable + m_correctionFunctionTF1->GetRandom(&rnd); } } ATH_MSG_VERBOSE("corrected var " << return_corrected_variable); - - // everything worked out, so - return StatusCode::SUCCESS; } - -StatusCode ElectronPhotonVariableCorrectionBase::setRandomSeed(const float pt, const float eta, const float phi) const -{ - m_random.SetSeed(1 + pt + std::abs(eta) * 1E3 + std::abs(phi) * 1E6); - return StatusCode::SUCCESS; -} // =========================================================================== // Corrected Copies // =========================================================================== @@ -679,8 +652,12 @@ const StatusCode ElectronPhotonVariableCorrectionBase::getObjectFromRootFile(TEn } -const StatusCode ElectronPhotonVariableCorrectionBase::getCorrectionParameters(std::vector& properties, const float pt, const float eta, const float phi) const +const StatusCode ElectronPhotonVariableCorrectionBase::getCorrectionParameters(const float pt, const float eta, const float phi) const { + //declare objects needed to retrieve electron properties + std::vector properties; //safe value of function parameter i at place i + properties.resize(m_numberOfFunctionParameters); + // check if eta or abs(eta) is used for the binned variables float etaForBinned = eta; if (m_useAbsEtaBinned) @@ -739,6 +716,14 @@ const StatusCode ElectronPhotonVariableCorrectionBase::getCorrectionParameters(s } } + for (auto p : properties) + ATH_MSG_VERBOSE("prop " << p); + + for (unsigned int parameter_itr = 0; parameter_itr < properties.size(); parameter_itr++) + { + m_correctionFunctionTF1->SetParameter(parameter_itr,properties.at(parameter_itr)); + } + // everything went fine, so return StatusCode::SUCCESS; } -- GitLab From 56e6015c8994d9bdd2aead2fc0722840f2f03bac Mon Sep 17 00:00:00 2001 From: jdevivi Date: Mon, 20 Dec 2021 15:10:06 +0100 Subject: [PATCH 2/5] fix doc --- .../ElectronPhotonVariableCorrectionBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h index a439b284e88..0e00f88eef9 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h @@ -317,7 +317,7 @@ private: /** @brief Actual application of the correction to the variable * @param return_corrected_variable The corrected variable value is saved in this parameter * @param original_variable The original value of the corrected variable - * @param properties The vector containing the correction TF1 parameters so the correction TF1 can be set for the respective e/y object + * @param rndSeed A random seed determined from pT, eta and phi, in case a Gaussian smearing is used. */ void correct(float& return_corrected_variable, const float original_variable, double rndSeed = 0.) const; -- GitLab From c2aa2ce3589a461542e904d2bb268cf151fab1ca Mon Sep 17 00:00:00 2001 From: jdevivi Date: Mon, 20 Dec 2021 16:37:29 +0100 Subject: [PATCH 3/5] change name of a method --- .../ElectronPhotonVariableCorrectionBase.h | 5 +++-- .../ElectronPhotonID/EGammaVariableCorrection/README.md | 2 +- .../Root/ElectronPhotonVariableCorrectionBase.cxx | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h index 0e00f88eef9..77e67a338ea 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h @@ -229,13 +229,14 @@ private: */ const StatusCode getObjectFromRootFile(TEnv& env, const int parameter_number, const TString& filePathKey, const TString& nameKey, std::unique_ptr& return_object); - /** @brief Get the actual parameters entering the correction TF1 for the current e/y object to be corrected + /** @brief Set the actual parameters of the TF1 function used for the current e/y object to be corrected * @param pt The pT of the current e/y object to be corrected * @param eta The eta of the current e/y object to be corrected + * @param phi The phi of the current e/y object to be corrected * @details As every electron/photon has different values of pT/eta, the correction function must be adapted accordingly for every e/y. The according values of * each of the correction function parameters are updated with this function. */ - const StatusCode getCorrectionParameters(const float pt, const float eta, const float phi) const; + const StatusCode setCorrectionParameters(const float pt, const float eta, const float phi) const; /** @brief Get the correction function parameter value if its type is eta- or pT-binned * @param return_parameter_value The respective correction function parameter value is saved in this parameter diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/README.md b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/README.md index 7e487c4c7a9..f23ee1f1108 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/README.md +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/README.md @@ -374,7 +374,7 @@ If possible, use the provided parameter types which are already implemented and 3. Add the code to be executed if the correction parameter is of your new parameter type to the following functions: - `ElectronPhotonVariableCorrectionBase::GetParameterInformationFromConf` - - `ElectronPhotonVariableCorrectionBase::GetCorrectionParameters` + - `ElectronPhotonVariableCorrectionBase::setCorrectionParameters` - `ElectronPhotonVariableCorrectionBase::StringToParameterType` If there is a style which all the other types use to implement their functionalities, follow it. This holds especially for `ElectronPhotonVariableCorrectionBase::GetCorrectionParameters`. diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx index 7408e0b017b..95d82c8eb4f 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx @@ -239,7 +239,7 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } ATH_MSG_VERBOSE("Got the photon kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi); - if (getCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) + if (setCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) { ATH_MSG_ERROR("Could not get the correction parameters for this photon object."); return CP::CorrectionCode::Error; @@ -291,7 +291,7 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Error; } ATH_MSG_VERBOSE("Got the electron kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi); - if (getCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) + if (setCorrectionParameters(pt, eta, phi) != StatusCode::SUCCESS) { ATH_MSG_ERROR("Could not get the correction parameters for this electron object."); return CP::CorrectionCode::Error; @@ -652,7 +652,7 @@ const StatusCode ElectronPhotonVariableCorrectionBase::getObjectFromRootFile(TEn } -const StatusCode ElectronPhotonVariableCorrectionBase::getCorrectionParameters(const float pt, const float eta, const float phi) const +const StatusCode ElectronPhotonVariableCorrectionBase::setCorrectionParameters(const float pt, const float eta, const float phi) const { //declare objects needed to retrieve electron properties std::vector properties; //safe value of function parameter i at place i -- GitLab From c2f97e7bceeacaad78e3900bc9e593b406036e3f Mon Sep 17 00:00:00 2001 From: jdevivi Date: Mon, 20 Dec 2021 17:11:15 +0100 Subject: [PATCH 4/5] from Christos --- .../ElectronPhotonVariableCorrectionBase.h | 7 +++++++ .../ElectronPhotonVariableCorrectionBase.cxx | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h index 77e67a338ea..300c8e826f0 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h @@ -29,6 +29,7 @@ class TObject; class TGraph; class TH2; class TEnv; +class TRandom3; // =========================================================================== // Class ElectronPhotonVariableCorrectionBase @@ -140,6 +141,8 @@ private: std::string m_correctionVariable; //! @brief Whether to apply normal correction or smearing correction bool m_doGaussianSmearing = false; + //! @brief thread-safe TRandom3 for setting seed of random smearing correction + mutable boost::thread_specific_ptr m_TRandom_tls; //! @brief Values of discontinuities in the variable which should not be corrected std::vector m_uncorrectedDiscontinuities; //! @brief Function to use for the variable correction, TF1 style @@ -322,6 +325,10 @@ private: */ void correct(float& return_corrected_variable, const float original_variable, double rndSeed = 0.) const; + /** @brief Getting thread safe random generator + */ + TRandom3* getTLSRandomGen(double seed) const; + }; //end class ElectronPhotonVariableCorrectionBase #endif diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx index 95d82c8eb4f..9ed4ced170b 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx @@ -346,9 +346,8 @@ void ElectronPhotonVariableCorrectionBase::correct(float& return_corrected_varia // Otherwise, can apply smear using GetRandom on TF1 else { - TRandom3 rnd; - rnd.SetSeed(rndSeed); - return_corrected_variable = original_variable + m_correctionFunctionTF1->GetRandom(&rnd); + return_corrected_variable = original_variable + + m_correctionFunctionTF1->GetRandom(getTLSRandomGen(rndSeed)); } } @@ -1064,3 +1063,15 @@ bool ElectronPhotonVariableCorrectionBase::applyToElectrons() const bool applyToAllElectrons = (m_applyToObjects == ElectronPhotonVariableCorrectionBase::EGammaObjects::allElectrons); return (applyToAllEGamma || applyToAllElectrons); } + + +TRandom3* ElectronPhotonVariableCorrectionBase::getTLSRandomGen(double seed) const +{ + TRandom3* random = m_TRandom_tls.get(); + if (!random) { + random = new TRandom3(); + m_TRandom_tls.reset(random); + } + random->SetSeed(seed); + return random; +} -- GitLab From 154bba40c5afe898d7d86e2faabca1602f266fbe Mon Sep 17 00:00:00 2001 From: jdevivi Date: Tue, 21 Dec 2021 10:25:43 +0100 Subject: [PATCH 5/5] fix --- .../EGammaVariableCorrection/CMakeLists.txt | 5 +++-- .../ElectronPhotonVariableCorrectionBase.h | 7 +++---- .../Root/ElectronPhotonVariableCorrectionBase.cxx | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/CMakeLists.txt index f415a0d3bd8..254e6824148 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/CMakeLists.txt +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/CMakeLists.txt @@ -5,14 +5,15 @@ atlas_subdir( EGammaVariableCorrection ) # External dependencies: find_package( ROOT COMPONENTS Core MathCore Hist Graph RIO ) +find_package( Boost COMPONENTS thread ) # Component(s) in the package: atlas_add_library( EGammaVariableCorrectionLib EGammaVariableCorrection/*.h Root/*.cxx PUBLIC_HEADERS EGammaVariableCorrection - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools EgammaAnalysisInterfacesLib EgammaAnalysisHelpersLib + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools EgammaAnalysisInterfacesLib EgammaAnalysisHelpersLib PRIVATE_LINK_LIBRARIES PathResolver xAODEgamma xAODEventShape) if( NOT XAOD_STANDALONE ) diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h index 300c8e826f0..0627fa04a87 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h @@ -323,11 +323,10 @@ private: * @param original_variable The original value of the corrected variable * @param rndSeed A random seed determined from pT, eta and phi, in case a Gaussian smearing is used. */ - void correct(float& return_corrected_variable, const float original_variable, double rndSeed = 0.) const; + void correct(float& return_corrected_variable, const float original_variable, unsigned int rndSeed = 0) const; - /** @brief Getting thread safe random generator - */ - TRandom3* getTLSRandomGen(double seed) const; + //! @brief Getting thread safe random number generator (and resetting its seed) + TRandom3* getTLSRandomGen(unsigned int seed) const; }; //end class ElectronPhotonVariableCorrectionBase diff --git a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx index 9ed4ced170b..6be4d7afd50 100644 --- a/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/Root/ElectronPhotonVariableCorrectionBase.cxx @@ -299,10 +299,10 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x // If applying a Gaussian smearing correction, set the seed based on the // electron properties - double rndSeed(0); + unsigned int rndSeed(0); if (m_doGaussianSmearing) { - rndSeed = 1 + pt + std::abs(eta) * 1E3 + std::abs(phi) * 1E6; + rndSeed = 1 + static_cast(pt + std::abs(eta) * 1E3 + std::abs(phi) * 1E6); } // Apply the correction, write to the corrected AuxElement @@ -312,7 +312,7 @@ const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection(x return CP::CorrectionCode::Ok; } -void ElectronPhotonVariableCorrectionBase::correct(float& return_corrected_variable, const float original_variable, double rndSeed) const +void ElectronPhotonVariableCorrectionBase::correct(float& return_corrected_variable, const float original_variable, unsigned int rndSeed) const { ATH_MSG_VERBOSE("original var " << original_variable); @@ -1065,7 +1065,7 @@ bool ElectronPhotonVariableCorrectionBase::applyToElectrons() const } -TRandom3* ElectronPhotonVariableCorrectionBase::getTLSRandomGen(double seed) const +TRandom3* ElectronPhotonVariableCorrectionBase::getTLSRandomGen(unsigned int seed) const { TRandom3* random = m_TRandom_tls.get(); if (!random) { -- GitLab