Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/TRestGeant4PrimaryGeneratorInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
2 changes: 1 addition & 1 deletion src/TRestGeant4Metadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/TRestGeant4PrimaryGeneratorInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading