Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CompositeDataSet Class Reference

#include <G4CompositeDataSet.hh>

+ Inheritance diagram for G4CompositeDataSet:

Public Member Functions

 G4CompositeDataSet (G4IInterpolator *argAlgorithm, G4double eUnit=CLHEP::MeV, G4double dataUnit=CLHEP::barn, G4int zMin=1, G4int zMax=99)
 
virtual ~G4CompositeDataSet ()
 
virtual G4double FindValue (G4double x, G4int componentId=0) const
 
virtual void PrintData (void) const
 
virtual const G4IDataSetGetComponent (G4int componentId) const
 
virtual void AddComponent (G4IDataSet *dataSet)
 
virtual size_t NumberOfComponents () const
 
virtual const G4DataVectorGetEnergies (G4int componentId) const
 
virtual const G4DataVectorGetData (G4int componentId) const
 
virtual void SetEnergiesData (G4DataVector *x, G4DataVector *data, G4int componentId)
 
virtual G4bool LoadData (const G4String &fileName)
 
virtual G4bool SaveData (const G4String &fileName) const
 
virtual G4double RandomSelect (G4int componentId) const
 
- Public Member Functions inherited from G4IDataSet
 G4IDataSet ()
 
virtual ~G4IDataSet ()
 
virtual G4double FindValue (G4double x, G4int componentId=0) const =0
 
virtual void PrintData (void) const =0
 
virtual const G4IDataSetGetComponent (G4int componentId) const =0
 
virtual void AddComponent (G4IDataSet *dataSet)=0
 
virtual size_t NumberOfComponents (void) const =0
 
virtual const G4DataVectorGetEnergies (G4int componentId) const =0
 
virtual const G4DataVectorGetData (G4int componentId) const =0
 
virtual void SetEnergiesData (G4DataVector *x, G4DataVector *data, G4int component=0)=0
 
virtual G4bool LoadData (const G4String &fileName)=0
 
virtual G4bool SaveData (const G4String &fileName) const =0
 
virtual G4double RandomSelect (G4int componentId=0) const =0
 

Detailed Description

Definition at line 54 of file G4CompositeDataSet.hh.

Constructor & Destructor Documentation

◆ G4CompositeDataSet()

G4CompositeDataSet::G4CompositeDataSet ( G4IInterpolator argAlgorithm,
G4double  eUnit = CLHEP::MeV,
G4double  dataUnit = CLHEP::barn,
G4int  zMin = 1,
G4int  zMax = 99 
)

Definition at line 44 of file G4CompositeDataSet.cc.

49 :
50 algorithm(algo),
51 unitEnergies(eUnit),
52 unitData(dataUnit),
53 minZ(zMin),
54 maxZ(zMax)
55{
56 if (algorithm == 0)
57 G4Exception("G4CompositeDataSet::G4CompositeDataSet",
58 "pii00000001",
60 "Interpolation == 0");
61}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59

Referenced by G4CompositeDataSet().

◆ ~G4CompositeDataSet()

G4CompositeDataSet::~G4CompositeDataSet ( )
virtual

Definition at line 65 of file G4CompositeDataSet.cc.

66{
67 CleanUpComponents();
68 if (algorithm) delete algorithm;
69}

Member Function Documentation

◆ AddComponent()

virtual void G4CompositeDataSet::AddComponent ( G4IDataSet dataSet)
inlinevirtual

Implements G4IDataSet.

Definition at line 72 of file G4CompositeDataSet.hh.

73 { components.push_back(dataSet); }

Referenced by LoadData().

◆ FindValue()

G4double G4CompositeDataSet::FindValue ( G4double  x,
G4int  componentId = 0 
) const
virtual

Implements G4IDataSet.

Definition at line 72 of file G4CompositeDataSet.cc.

73{
74 const G4IDataSet* component(GetComponent(componentId));
75
76 if (component) return component->FindValue(energy);
77
78 std::ostringstream message;
79 message << "G4CompositeDataSet::FindValue - component " << componentId << " not found";
80
81 G4Exception("G4CompositeDataSet::FindValue",
82 "pii00000010",
84 message.str().c_str());
85
86 return 0.;
87}
virtual const G4IDataSet * GetComponent(G4int componentId) const

◆ GetComponent()

virtual const G4IDataSet * G4CompositeDataSet::GetComponent ( G4int  componentId) const
inlinevirtual

Implements G4IDataSet.

Definition at line 69 of file G4CompositeDataSet.hh.

70 { return components[componentId]; }

Referenced by FindValue(), GetData(), GetEnergies(), PrintData(), RandomSelect(), and SaveData().

◆ GetData()

virtual const G4DataVector & G4CompositeDataSet::GetData ( G4int  componentId) const
inlinevirtual

Implements G4IDataSet.

Definition at line 81 of file G4CompositeDataSet.hh.

82 { return GetComponent(componentId)->GetData(0); }
virtual const G4DataVector & GetData(G4int componentId) const =0

◆ GetEnergies()

virtual const G4DataVector & G4CompositeDataSet::GetEnergies ( G4int  componentId) const
inlinevirtual

Implements G4IDataSet.

Definition at line 78 of file G4CompositeDataSet.hh.

79 { return GetComponent(componentId)->GetEnergies(0); }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0

◆ LoadData()

G4bool G4CompositeDataSet::LoadData ( const G4String fileName)
virtual

Implements G4IDataSet.

Definition at line 126 of file G4CompositeDataSet.cc.

127{
128 CleanUpComponents();
129
130 for (G4int z(minZ); z<maxZ; ++z)
131 {
132 G4IDataSet* component = new G4DataSet(z, algorithm->Clone(), unitEnergies, unitData);
133 if (!component->LoadData(argFileName))
134 {
135 delete component;
136 return false;
137 }
138 AddComponent(component);
139 }
140 return true;
141}
int G4int
Definition: G4Types.hh:85
virtual void AddComponent(G4IDataSet *dataSet)
virtual G4bool LoadData(const G4String &fileName)=0
virtual G4IInterpolator * Clone() const =0

◆ NumberOfComponents()

virtual size_t G4CompositeDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4IDataSet.

Definition at line 75 of file G4CompositeDataSet.hh.

76 { return components.size(); }

Referenced by PrintData().

◆ PrintData()

void G4CompositeDataSet::PrintData ( void  ) const
virtual

Implements G4IDataSet.

Definition at line 89 of file G4CompositeDataSet.cc.

90{
92
93 G4cout << "The data set has " << n << " components" << G4endl;
94 G4cout << G4endl;
95
96 G4int i(0);
97
98 while (i<n)
99 {
100 G4cout << "--- Component " << i << " ---" << G4endl;
102 ++i;
103 }
104}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual size_t NumberOfComponents() const
virtual void PrintData(void) const =0

◆ RandomSelect()

G4double G4CompositeDataSet::RandomSelect ( G4int  componentId) const
virtual

Implements G4IDataSet.

Definition at line 179 of file G4CompositeDataSet.cc.

180{
181 G4double value = 0.;
182 if (componentId >= 0 && componentId < (G4int)components.size())
183 {
184 const G4IDataSet* dataSet = GetComponent(componentId);
185 value = dataSet->RandomSelect();
186 }
187 return value;
188}
double G4double
Definition: G4Types.hh:83
virtual G4double RandomSelect(G4int componentId=0) const =0

◆ SaveData()

G4bool G4CompositeDataSet::SaveData ( const G4String fileName) const
virtual

Implements G4IDataSet.

Definition at line 145 of file G4CompositeDataSet.cc.

146{
147 for (G4int z=minZ; z<maxZ; ++z)
148 {
149 const G4IDataSet* component(GetComponent(z-minZ));
150
151 if (!component)
152 {
153 std::ostringstream message;
154 message << "G4CompositeDataSet::SaveData - component " << (z-minZ) << " not found";
155 G4Exception("G4CompositeDataSet::SaveData",
156 "pii00000030",
158 message.str().c_str());
159 }
160
161 if (!component->SaveData(argFileName))
162 return false;
163 }
164
165 return true;
166}

◆ SetEnergiesData()

void G4CompositeDataSet::SetEnergiesData ( G4DataVector x,
G4DataVector data,
G4int  componentId 
)
virtual

Implements G4IDataSet.

Definition at line 106 of file G4CompositeDataSet.cc.

107{
108 G4IDataSet * component(components[componentId]);
109
110 if (component)
111 {
112 component->SetEnergiesData(energies, data, 0);
113 return;
114 }
115
116 std::ostringstream message;
117 message << "G4CompositeDataSet::SetEnergiesData - component " << componentId << " not found";
118
119 G4Exception("G4CompositeDataSet::SetEnergiesData",
120 "pii00000020",
122 message.str().c_str());
123
124}

The documentation for this class was generated from the following files: