diff --git a/inc/TRestGeant4PrimaryGeneratorInfo.h b/inc/TRestGeant4PrimaryGeneratorInfo.h index 927e66f..0d13f3e 100644 --- a/inc/TRestGeant4PrimaryGeneratorInfo.h +++ b/inc/TRestGeant4PrimaryGeneratorInfo.h @@ -73,7 +73,7 @@ enum class AngularDistributionTypes { std::string AngularDistributionTypesToString(const AngularDistributionTypes&); AngularDistributionTypes StringToAngularDistributionTypes(const std::string&); -enum class AngularDistributionFormulas { COS2, COS3, SIN_2THETA }; +enum class AngularDistributionFormulas { COS2, COS3, SIN_COS2, SIN_2THETA }; std::string AngularDistributionFormulasToString(const AngularDistributionFormulas&); AngularDistributionFormulas StringToAngularDistributionFormulas(const std::string&); diff --git a/src/TRestGeant4Metadata.cxx b/src/TRestGeant4Metadata.cxx index d110be1..5fa30f3 100644 --- a/src/TRestGeant4Metadata.cxx +++ b/src/TRestGeant4Metadata.cxx @@ -499,7 +499,7 @@ /// /// /// * **Formula**: It will use one of the predefined formulas to generate the primaries. -/// The available formulas are: "Cos2", "Cos3". +/// The available formulas are: "Cos2", "Cos3", "SinCos2", "Sin2theta". /// A range parameter can be specified to limit the zenith angular range of the generated primaries. /// It will not go over or under the predefined range for the formula `range=(10,45)deg`. /// A parameter `nPoints` can be defined to set the random sampling of the formula. diff --git a/src/TRestGeant4PrimaryGeneratorInfo.cxx b/src/TRestGeant4PrimaryGeneratorInfo.cxx index 34812c1..b70fe65 100644 --- a/src/TRestGeant4PrimaryGeneratorInfo.cxx +++ b/src/TRestGeant4PrimaryGeneratorInfo.cxx @@ -334,6 +334,8 @@ string TRestGeant4PrimaryGeneratorTypes::AngularDistributionFormulasToString( return "Cos2"; case AngularDistributionFormulas::COS3: return "Cos3"; + case AngularDistributionFormulas::SIN_COS2: + return "SinCos2"; case AngularDistributionFormulas::SIN_2THETA: return "Sin2theta"; } @@ -351,6 +353,10 @@ AngularDistributionFormulas TRestGeant4PrimaryGeneratorTypes::StringToAngularDis } else if (TString(type).EqualTo(AngularDistributionFormulasToString(AngularDistributionFormulas::COS3), TString::ECaseCompare::kIgnoreCase)) { return AngularDistributionFormulas::COS3; + } else if (TString(type).EqualTo( + AngularDistributionFormulasToString(AngularDistributionFormulas::SIN_COS2), + TString::ECaseCompare::kIgnoreCase)) { + return AngularDistributionFormulas::SIN_COS2; } else if (TString(type).EqualTo( AngularDistributionFormulasToString(AngularDistributionFormulas::SIN_2THETA), TString::ECaseCompare::kIgnoreCase)) { @@ -390,6 +396,18 @@ TF1 TRestGeant4PrimaryGeneratorTypes::AngularDistributionFormulasToRootFormula( f.SetTitle(title); return f; } + case AngularDistributionFormulas::SIN_COS2: { + auto sinCos2 = [](double* xs, double* ps) { + if (xs[0] >= 0 && xs[0] <= TMath::Pi() / 2) { + return TMath::Sin(xs[0]) * TMath::Power(TMath::Cos(xs[0]), 2); + } + return 0.0; + }; + const char* title = "AngularDistribution: SinCos2"; + auto f = TF1(title, sinCos2, 0.0, TMath::Pi()); + f.SetTitle(title); + return f; + } case AngularDistributionFormulas::SIN_2THETA: { auto sin2theta = [](double* xs, double* ps) { if (xs[0] >= 0 && xs[0] <= TMath::Pi() / 2) {