Geant4  10.02.p03
G4CompositeDataSet Class Reference

#include <G4CompositeDataSet.hh>

Inheritance diagram for G4CompositeDataSet:
Collaboration 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 ()
 

Private Member Functions

void CleanUpComponents (void)
 
 G4CompositeDataSet ()
 
 G4CompositeDataSet (const G4CompositeDataSet &copy)
 
G4CompositeDataSetoperator= (const G4CompositeDataSet &right)
 

Private Attributes

std::vector< G4IDataSet * > components
 
G4IInterpolatoralgorithm
 
G4double unitEnergies
 
G4double unitData
 
G4int minZ
 
G4int maxZ
 

Detailed Description

Definition at line 55 of file G4CompositeDataSet.hh.

Constructor & Destructor Documentation

◆ G4CompositeDataSet() [1/3]

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 }
G4IInterpolator * algorithm
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ ~G4CompositeDataSet()

G4CompositeDataSet::~G4CompositeDataSet ( )
virtual

Definition at line 66 of file G4CompositeDataSet.cc.

67 {
69  if (algorithm) delete algorithm;
70 }
G4IInterpolator * algorithm
Here is the call graph for this function:

◆ G4CompositeDataSet() [2/3]

G4CompositeDataSet::G4CompositeDataSet ( )
private
Here is the caller graph for this function:

◆ G4CompositeDataSet() [3/3]

G4CompositeDataSet::G4CompositeDataSet ( const G4CompositeDataSet copy)
private

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); }
std::vector< G4IDataSet * > components
Here is the caller graph for this function:

◆ CleanUpComponents()

void G4CompositeDataSet::CleanUpComponents ( void  )
private

Definition at line 169 of file G4CompositeDataSet.cc.

170 {
171  while (!components.empty())
172  {
173  if (components.back())
174  delete components.back();
175  components.pop_back();
176  }
177 }
std::vector< G4IDataSet * > components
Here is the caller graph for this function:

◆ 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 }
double energy
Definition: plottest35.C:25
virtual const G4IDataSet * GetComponent(G4int componentId) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ GetComponent()

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

Implements G4IDataSet.

Definition at line 70 of file G4CompositeDataSet.hh.

71  { return components[componentId]; }
std::vector< G4IDataSet * > components
Here is the caller graph for this function:

◆ 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
virtual const G4IDataSet * GetComponent(G4int componentId) const
Here is the call graph for this function:

◆ 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
virtual const G4IDataSet * GetComponent(G4int componentId) const
Here is the call graph for this function:

◆ LoadData()

G4bool G4CompositeDataSet::LoadData ( const G4String fileName)
virtual

Implements G4IDataSet.

Definition at line 127 of file G4CompositeDataSet.cc.

128 {
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 }
virtual void AddComponent(G4IDataSet *dataSet)
int G4int
Definition: G4Types.hh:78
G4IInterpolator * algorithm
virtual G4bool LoadData(const G4String &fileName)=0
virtual G4IInterpolator * Clone() const =0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NumberOfComponents()

virtual size_t G4CompositeDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4IDataSet.

Definition at line 76 of file G4CompositeDataSet.hh.

77  { return components.size(); }
std::vector< G4IDataSet * > components
Here is the caller graph for this function:

◆ operator=()

G4CompositeDataSet& G4CompositeDataSet::operator= ( const G4CompositeDataSet right)
private
Here is the caller graph for this function:

◆ 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;
102  GetComponent(i)->PrintData();
103  i++;
104  }
105 }
virtual size_t NumberOfComponents() const
Char_t n[5]
G4GLOB_DLL std::ostream G4cout
virtual const G4IDataSet * GetComponent(G4int componentId) const
#define G4endl
Definition: G4ios.hh:61
virtual void PrintData(void) const =0
Here is the call graph for this function:

◆ 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 }
virtual G4double RandomSelect(G4int componentId=0) const =0
int G4int
Definition: G4Types.hh:78
virtual const G4IDataSet * GetComponent(G4int componentId) const
std::vector< G4IDataSet * > components
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 }
int G4int
Definition: G4Types.hh:78
virtual const G4IDataSet * GetComponent(G4int componentId) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::vector< G4IDataSet * > components
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ algorithm

G4IInterpolator* G4CompositeDataSet::algorithm
private

Definition at line 103 of file G4CompositeDataSet.hh.

◆ components

std::vector<G4IDataSet*> G4CompositeDataSet::components
private

Definition at line 101 of file G4CompositeDataSet.hh.

◆ maxZ

G4int G4CompositeDataSet::maxZ
private

Definition at line 109 of file G4CompositeDataSet.hh.

◆ minZ

G4int G4CompositeDataSet::minZ
private

Definition at line 108 of file G4CompositeDataSet.hh.

◆ unitData

G4double G4CompositeDataSet::unitData
private

Definition at line 106 of file G4CompositeDataSet.hh.

◆ unitEnergies

G4double G4CompositeDataSet::unitEnergies
private

Definition at line 105 of file G4CompositeDataSet.hh.


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