17 #ifndef RestCore_TRestGeant4ParticleSource
18 #define RestCore_TRestGeant4ParticleSource
22 #include <TRestMetadata.h>
29 #include "TRestGeant4Particle.h"
30 #include "TRestGeant4PrimaryGeneratorInfo.h"
39 TString fAngularDistributionType =
"Flux";
40 TString fAngularDistributionFilename;
41 TString fAngularDistributionNameInFile;
42 size_t fAngularDistributionFormulaNPoints = 500;
43 TF1* fAngularDistributionFunction =
nullptr;
44 TVector2 fAngularDistributionRange;
46 TString fEnergyDistributionType =
"Mono";
47 TString fEnergyDistributionFilename;
48 TString fEnergyDistributionNameInFile;
49 size_t fEnergyDistributionFormulaNPoints = 5000;
50 TF1* fEnergyDistributionFunction =
nullptr;
51 TVector2 fEnergyDistributionRange;
53 TF2* fEnergyAndAngularDistributionFunction =
nullptr;
57 std::vector<TRestGeant4Particle> fParticles;
59 std::vector<std::vector<TRestGeant4Particle>> fParticlesTemplate;
61 double (*fRandomMethod)();
64 virtual void Update();
68 inline TVector3 GetDirection()
const {
69 if (fDirection.Mag() <= 0) {
70 std::cout <<
"TRestGeant4ParticleSource::GetDirection: "
71 <<
"Direction cannot be the zero vector" << std::endl;
77 inline TString GetEnergyDistributionType()
const {
return fEnergyDistributionType; }
78 inline TVector2 GetEnergyDistributionRange()
const {
return fEnergyDistributionRange; }
79 inline Double_t GetEnergyDistributionRangeMin()
const {
return fEnergyDistributionRange.X(); }
80 inline Double_t GetEnergyDistributionRangeMax()
const {
return fEnergyDistributionRange.Y(); }
81 inline size_t GetEnergyDistributionFormulaNPoints()
const {
return fEnergyDistributionFormulaNPoints; }
82 inline TString GetEnergyDistributionFilename()
const {
return fEnergyDistributionFilename; }
83 inline TString GetEnergyDistributionNameInFile()
const {
return fEnergyDistributionNameInFile; }
84 inline const TF1* GetEnergyDistributionFunction()
const {
return fEnergyDistributionFunction; }
86 inline TString GetAngularDistributionType()
const {
return fAngularDistributionType; }
87 inline TVector2 GetAngularDistributionRange()
const {
return fAngularDistributionRange; }
88 inline Double_t GetAngularDistributionRangeMin()
const {
return fAngularDistributionRange.X(); }
89 inline Double_t GetAngularDistributionRangeMax()
const {
return fAngularDistributionRange.Y(); }
90 inline size_t GetAngularDistributionFormulaNPoints()
const {
return fAngularDistributionFormulaNPoints; }
91 inline TString GetAngularDistributionFilename()
const {
return fAngularDistributionFilename; }
92 inline TString GetAngularDistributionNameInFile()
const {
return fAngularDistributionNameInFile; }
93 inline const TF1* GetAngularDistributionFunction()
const {
return fAngularDistributionFunction; }
95 inline const TF2* GetEnergyAndAngularDistributionFunction()
const {
96 return fEnergyAndAngularDistributionFunction;
99 inline TString GetGenFilename()
const {
return fGenFilename; }
101 inline std::vector<TRestGeant4Particle> GetParticles()
const {
return fParticles; }
103 inline void SetAngularDistributionType(
const TString& type) {
104 fAngularDistributionType = TRestGeant4PrimaryGeneratorTypes::AngularDistributionTypesToString(
105 TRestGeant4PrimaryGeneratorTypes::StringToAngularDistributionTypes(type.Data()));
107 inline void SetAngularDistributionRange(
const TVector2& range) {
108 fAngularDistributionRange = range;
109 if (fAngularDistributionRange.X() < 0) {
110 fAngularDistributionRange.Set(0, fAngularDistributionRange.Y());
112 if (fAngularDistributionRange.Y() < 0) {
113 fAngularDistributionRange.Set(fAngularDistributionRange.X(), 0);
115 if (fAngularDistributionRange.Y() > TMath::Pi()) {
116 fAngularDistributionRange.Set(fAngularDistributionRange.X(), TMath::Pi());
118 if (fAngularDistributionRange.X() > fAngularDistributionRange.Y()) {
119 fAngularDistributionRange.Set(fAngularDistributionRange.Y(), fAngularDistributionRange.X());
122 inline void SetAngularDistributionFormulaNPoints(
size_t nPoints) {
123 const auto nPointsMax = 10000;
124 if (nPoints > nPointsMax) {
125 nPoints = nPointsMax;
127 fAngularDistributionFormulaNPoints = nPoints;
129 inline void SetAngularDistributionFilename(
const TString& filename) {
130 fAngularDistributionFilename = filename;
132 inline void SetAngularDistributionNameInFile(
const TString& name) {
133 fAngularDistributionNameInFile = name;
135 inline void SetAngularDistributionFormula(
const TString& formula) {
136 fAngularDistributionFunction =
137 (TF1*)TRestGeant4PrimaryGeneratorTypes::AngularDistributionFormulasToRootFormula(
138 TRestGeant4PrimaryGeneratorTypes::StringToAngularDistributionFormulas(formula.Data()))
142 inline void SetEnergyDistributionType(
const TString& type) {
143 fEnergyDistributionType = TRestGeant4PrimaryGeneratorTypes::EnergyDistributionTypesToString(
144 TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionTypes(type.Data()));
146 inline void SetEnergyDistributionRange(
const TVector2& range) {
147 fEnergyDistributionRange = range;
148 if (fEnergyDistributionRange.X() < 0) {
149 fEnergyDistributionRange.Set(0, fEnergyDistributionRange.Y());
151 if (fEnergyDistributionRange.Y() < 0) {
152 fEnergyDistributionRange.Set(fEnergyDistributionRange.X(), 0);
154 if (fEnergyDistributionRange.X() > fEnergyDistributionRange.Y()) {
155 fEnergyDistributionRange.Set(fEnergyDistributionRange.Y(), fEnergyDistributionRange.X());
158 inline void SetEnergyDistributionFormulaNPoints(
size_t nPoints) {
159 const auto nPointsMax = 10000;
160 if (nPoints > nPointsMax) {
161 nPoints = nPointsMax;
163 fEnergyDistributionFormulaNPoints = nPoints;
165 inline void SetEnergyDistributionFilename(
const TString& filename) {
166 fEnergyDistributionFilename = filename;
168 inline void SetEnergyDistributionNameInFile(
const TString& name) { fEnergyDistributionNameInFile = name; }
169 inline void SetEnergyDistributionFormula(
const TString& formula) {
170 fEnergyDistributionFunction =
171 (TF1*)TRestGeant4PrimaryGeneratorTypes::EnergyDistributionFormulasToRootFormula(
172 TRestGeant4PrimaryGeneratorTypes::StringToEnergyDistributionFormulas(formula.Data()))
176 inline void SetEnergyAndAngularDistributionFormula(
const TString& formula) {
177 fEnergyAndAngularDistributionFunction =
178 (TF2*)TRestGeant4PrimaryGeneratorTypes::EnergyAndAngularDistributionFormulasToRootFormula(
179 TRestGeant4PrimaryGeneratorTypes::StringToEnergyAndAngularDistributionFormulas(
184 inline void SetGenFilename(
const TString& name) { fGenFilename = name; }
186 inline void SetRandomMethod(
double (*method)()) { fRandomMethod = method; }
188 inline void AddParticle(
const TRestGeant4Particle& particle) { fParticles.push_back(particle); }
190 inline void RemoveParticles() { fParticles.clear(); }
191 inline void RemoveTemplates() { fParticlesTemplate.clear(); }
192 inline void FlushParticlesTemplate() {
193 fParticlesTemplate.push_back(fParticles);
void ReadEventDataFile(TString fName)
Reads an input file produced by Decay0.
virtual void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
virtual void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
bool ReadOldDecay0File(TString fileName)
Reads particle information using the file format from older Decay0 versions.
bool ReadNewDecay0File(TString fileName)
Reads particle information using the file format from newer Decay0 versions.
A class used to store particle properties.