Geant4 9.6.0
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 55 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 45 of file G4CompositeDataSet.cc.

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

Referenced by G4CompositeDataSet().

◆ ~G4CompositeDataSet()

G4CompositeDataSet::~G4CompositeDataSet ( )
virtual

Definition at line 66 of file G4CompositeDataSet.cc.

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

Member Function Documentation

◆ AddComponent()

virtual void G4CompositeDataSet::AddComponent ( G4IDataSet dataSet)
inlinevirtual

Implements G4IDataSet.

Definition at line 73 of file G4CompositeDataSet.hh.

74 { components.push_back(dataSet); }

Referenced by LoadData().

◆ FindValue()

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

Implements G4IDataSet.

Definition at line 73 of file G4CompositeDataSet.cc.

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

◆ GetComponent()

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

Implements G4IDataSet.

Definition at line 70 of file G4CompositeDataSet.hh.

71 { 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 82 of file G4CompositeDataSet.hh.

83 { 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 79 of file G4CompositeDataSet.hh.

80 { 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 127 of file G4CompositeDataSet.cc.

128{
129 CleanUpComponents();
130
131 for (G4int z(minZ); z<maxZ; z++)
132 {
133 G4IDataSet* component = new G4DataSet(z, algorithm->Clone(), unitEnergies, unitData);
134 if (!component->LoadData(argFileName))
135 {
136 delete component;
137 return false;
138 }
139 AddComponent(component);
140 }
141 return true;
142}
int G4int
Definition: G4Types.hh:66
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 76 of file G4CompositeDataSet.hh.

77 { return components.size(); }

Referenced by PrintData().

◆ PrintData()

void G4CompositeDataSet::PrintData ( void  ) const
virtual

Implements G4IDataSet.

Definition at line 90 of file G4CompositeDataSet.cc.

91{
92 const size_t n(NumberOfComponents());
93
94 G4cout << "The data set has " << n << " components" << G4endl;
95 G4cout << G4endl;
96
97 size_t i(0);
98
99 while (i<n)
100 {
101 G4cout << "--- Component " << i << " ---" << G4endl;
103 i++;
104 }
105}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT 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 180 of file G4CompositeDataSet.cc.

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

◆ SaveData()

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

Implements G4IDataSet.

Definition at line 146 of file G4CompositeDataSet.cc.

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

◆ SetEnergiesData()

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

Implements G4IDataSet.

Definition at line 107 of file G4CompositeDataSet.cc.

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

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