From 50a33b477e3881e611fb2413fef985fd427450ba Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sun, 29 Jun 2025 22:15:37 +0200 Subject: [PATCH 1/2] formula for environmental neutrons (aprox) --- inc/TRestGeant4PrimaryGeneratorInfo.h | 3 ++- src/TRestGeant4PrimaryGeneratorInfo.cxx | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/inc/TRestGeant4PrimaryGeneratorInfo.h b/inc/TRestGeant4PrimaryGeneratorInfo.h index 75eab77..927e66f 100644 --- a/inc/TRestGeant4PrimaryGeneratorInfo.h +++ b/inc/TRestGeant4PrimaryGeneratorInfo.h @@ -52,7 +52,8 @@ enum class EnergyDistributionFormulas { COSMIC_NEUTRONS, COSMIC_GAMMAS, FISSION_NEUTRONS_U238, - ENVIRONMENTAL_GAMMAS + ENVIRONMENTAL_GAMMAS, + ENVIRONMENTAL_NEUTRONS, }; std::string EnergyDistributionFormulasToString(const EnergyDistributionFormulas&); diff --git a/src/TRestGeant4PrimaryGeneratorInfo.cxx b/src/TRestGeant4PrimaryGeneratorInfo.cxx index 512393c..9b3a82b 100644 --- a/src/TRestGeant4PrimaryGeneratorInfo.cxx +++ b/src/TRestGeant4PrimaryGeneratorInfo.cxx @@ -178,6 +178,8 @@ string TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString( return "FissionNeutronsU238"; case EnergyDistributionFormulas::ENVIRONMENTAL_GAMMAS: return "EnvironmentalGammas"; + case EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS: + return "EnvironmentalNeutrons"; } cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToString - Error - Unknown energy " "distribution formula" @@ -202,6 +204,10 @@ EnergyDistributionFormulas TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistr EnergyDistributionFormulasToString(EnergyDistributionFormulas::ENVIRONMENTAL_GAMMAS), TString::ECaseCompare::kIgnoreCase)) { return EnergyDistributionFormulas::ENVIRONMENTAL_GAMMAS; + } else if (TString(type).EqualTo( + EnergyDistributionFormulasToString(EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS), + TString::ECaseCompare::kIgnoreCase)) { + return EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS; } else { cout << "TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionFormulas - Error - Unknown " "energyDistributionFormulas: " @@ -250,6 +256,15 @@ TF1 TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula( distribution.GetXaxis()->SetTitle("Energy (keV)"); return distribution; } + case EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS: { + // Environmental neutron radiation approximation + const char* title = "Environmental Neutrons"; + auto distribution = TF1(title, "TMath::Exp(-x * 0.0005)", 0, 10000); // keV + distribution.SetNormalized(true); + distribution.SetTitle(title); + distribution.GetXaxis()->SetTitle("Energy (keV)"); + return distribution; + } } cout << "TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula - Error - Unknown " "energy distribution formula" From c70aff290567895a87973c7bf0ddd0cf67b5a217 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 29 Jun 2025 20:16:00 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/TRestGeant4PrimaryGeneratorInfo.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TRestGeant4PrimaryGeneratorInfo.cxx b/src/TRestGeant4PrimaryGeneratorInfo.cxx index 9b3a82b..34812c1 100644 --- a/src/TRestGeant4PrimaryGeneratorInfo.cxx +++ b/src/TRestGeant4PrimaryGeneratorInfo.cxx @@ -204,10 +204,10 @@ EnergyDistributionFormulas TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistr EnergyDistributionFormulasToString(EnergyDistributionFormulas::ENVIRONMENTAL_GAMMAS), TString::ECaseCompare::kIgnoreCase)) { return EnergyDistributionFormulas::ENVIRONMENTAL_GAMMAS; - } else if (TString(type).EqualTo( - EnergyDistributionFormulasToString(EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS), - TString::ECaseCompare::kIgnoreCase)) { - return EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS; + } else if (TString(type).EqualTo( + EnergyDistributionFormulasToString(EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS), + TString::ECaseCompare::kIgnoreCase)) { + return EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS; } else { cout << "TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionFormulas - Error - Unknown " "energyDistributionFormulas: " @@ -259,7 +259,7 @@ TF1 TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula( case EnergyDistributionFormulas::ENVIRONMENTAL_NEUTRONS: { // Environmental neutron radiation approximation const char* title = "Environmental Neutrons"; - auto distribution = TF1(title, "TMath::Exp(-x * 0.0005)", 0, 10000); // keV + auto distribution = TF1(title, "TMath::Exp(-x * 0.0005)", 0, 10000); // keV distribution.SetNormalized(true); distribution.SetTitle(title); distribution.GetXaxis()->SetTitle("Energy (keV)");