Geant4  10.02.p03
XrayFluoDataSet Class Reference

#include <XrayFluoDataSet.hh>

Inheritance diagram for XrayFluoDataSet:
Collaboration diagram for XrayFluoDataSet:

Public Member Functions

 XrayFluoDataSet (G4int Z, G4DataVector *points, G4DataVector *values, const G4VDataSetAlgorithm *interpolation, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn)
 
 XrayFluoDataSet (G4int Z, const G4String &dataFile, const G4VDataSetAlgorithm *interpolation, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn)
 
 ~XrayFluoDataSet ()
 
G4double FindValue (G4double e, G4int) const
 
virtual const G4VEMDataSetGetComponent (G4int) const
 
virtual void AddComponent (G4VEMDataSet *)
 
virtual size_t NumberOfComponents () const
 
virtual void SetEnergiesData (G4DataVector *, G4DataVector *, int=0)
 
virtual G4bool SaveData (const G4String &) const
 
virtual G4double RandomSelect (int=0) const
 
void PrintData () const
 
const G4DataVectorGetEnergies (G4int) const
 
const G4DataVectorGetData (G4int) const
 
virtual const G4DataVectorGetLogEnergies (G4int) const
 
virtual const G4DataVectorGetLogData (G4int) const
 
virtual void SetLogEnergiesData (G4DataVector *, G4DataVector *, G4DataVector *, G4DataVector *, G4int)
 
virtual G4bool LoadNonLogData (const G4String &)
 
- Public Member Functions inherited from G4VEMDataSet
 G4VEMDataSet ()
 
virtual ~G4VEMDataSet ()
 

Private Member Functions

G4bool LoadData (const G4String &dataFile)
 
G4int FindBinLocation (G4double energy) const
 

Private Attributes

G4DataVectorenergies
 
G4DataVectordata
 
const G4VDataSetAlgorithmalgorithm
 
G4double unit1
 
G4double unit2
 
size_t numberOfBins
 

Detailed Description

Definition at line 51 of file XrayFluoDataSet.hh.

Constructor & Destructor Documentation

◆ XrayFluoDataSet() [1/2]

XrayFluoDataSet::XrayFluoDataSet ( G4int  Z,
G4DataVector points,
G4DataVector values,
const G4VDataSetAlgorithm interpolation,
G4double  unitE = CLHEP::MeV,
G4double  unitData = CLHEP::barn 
)

Definition at line 42 of file XrayFluoDataSet.cc.

47  :energies(points), data(values), algorithm(interpolation)
48 {
49  numberOfBins = energies->size();
50  unit1 = unitE;
51  unit2 = unitData;
52 }
const G4VDataSetAlgorithm * algorithm
G4DataVector * data
G4DataVector * energies

◆ XrayFluoDataSet() [2/2]

XrayFluoDataSet::XrayFluoDataSet ( G4int  Z,
const G4String dataFile,
const G4VDataSetAlgorithm interpolation,
G4double  unitE = CLHEP::MeV,
G4double  unitData = CLHEP::barn 
)

Definition at line 56 of file XrayFluoDataSet.cc.

60  : algorithm(interpolation)
61 {
62  energies = new G4DataVector;
63  data = new G4DataVector;
64  unit1 = unitE;
65  unit2 = unitData;
66  LoadData(dataFile);
67  numberOfBins = energies->size();
68 }
G4bool LoadData(const G4String &dataFile)
const G4VDataSetAlgorithm * algorithm
G4DataVector * data
G4DataVector * energies
Here is the call graph for this function:

◆ ~XrayFluoDataSet()

XrayFluoDataSet::~XrayFluoDataSet ( )

Definition at line 73 of file XrayFluoDataSet.cc.

74 {
75  delete energies;
76  delete data;
77 }
G4DataVector * data
G4DataVector * energies

Member Function Documentation

◆ AddComponent()

virtual void XrayFluoDataSet::AddComponent ( G4VEMDataSet )
inlinevirtual

Implements G4VEMDataSet.

Definition at line 74 of file XrayFluoDataSet.hh.

74 { }

◆ FindBinLocation()

G4int XrayFluoDataSet::FindBinLocation ( G4double  energy) const
private

Definition at line 107 of file XrayFluoDataSet.cc.

108 {
109  // Protection against call outside allowed range
110  G4double e0 = (*energies)[0];
111  if (energy < e0)
112  {
113 
114  energy = e0;
115  }
116 
117  size_t lowerBound = 0;
118  size_t upperBound = numberOfBins - 1;
119 
120  // Binary search
121  while (lowerBound <= upperBound)
122  {
123  size_t midBin = (lowerBound + upperBound)/2;
124  if ( energy < (*energies)[midBin] ) upperBound = midBin-1;
125  else lowerBound = midBin+1;
126  }
127 
128  return upperBound;
129 }
double energy
Definition: plottest35.C:25
double G4double
Definition: G4Types.hh:76
G4DataVector * energies
Here is the caller graph for this function:

◆ FindValue()

G4double XrayFluoDataSet::FindValue ( G4double  e,
G4int   
) const
virtual

Implements G4VEMDataSet.

Definition at line 81 of file XrayFluoDataSet.cc.

82 {
83  G4double value;
84  G4double e0 = (*energies)[0];
85  // Protections
86  size_t bin = FindBinLocation(e);
87  if (bin == numberOfBins)
88  {
89 
90  value = (*data)[bin];
91  }
92  else if (e <= e0)
93  {
94 
95  value = (*data)[0];
96  }
97  else
98  {
99  value = algorithm->Calculate(e,bin,*energies,*data);
100  }
101 
102  return value;
103 }
float bin[41]
Definition: plottest35.C:14
virtual G4double Calculate(G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data) const =0
G4int FindBinLocation(G4double energy) const
const G4VDataSetAlgorithm * algorithm
double G4double
Definition: G4Types.hh:76
G4DataVector * data
G4DataVector * energies
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetComponent()

virtual const G4VEMDataSet* XrayFluoDataSet::GetComponent ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 72 of file XrayFluoDataSet.hh.

72 { return 0;}

◆ GetData()

const G4DataVector& XrayFluoDataSet::GetData ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 88 of file XrayFluoDataSet.hh.

88 { return *data; }
G4DataVector * data

◆ GetEnergies()

const G4DataVector& XrayFluoDataSet::GetEnergies ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 87 of file XrayFluoDataSet.hh.

87 { return *energies; }
G4DataVector * energies

◆ GetLogData()

virtual const G4DataVector& XrayFluoDataSet::GetLogData ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 91 of file XrayFluoDataSet.hh.

91 { return *data; }
G4DataVector * data

◆ GetLogEnergies()

virtual const G4DataVector& XrayFluoDataSet::GetLogEnergies ( G4int  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 90 of file XrayFluoDataSet.hh.

90 { return *energies; }
G4DataVector * energies

◆ LoadData()

G4bool XrayFluoDataSet::LoadData ( const G4String dataFile)
privatevirtual

Implements G4VEMDataSet.

Definition at line 133 of file XrayFluoDataSet.cc.

134 {
135  // Build the complete string identifying the file with the data set
136  G4String dirFile = "";
137 
138  char* path;
139 
140  path = getenv("XRAYDATA");
141  if (!path)
142  path = getenv("PWD");
143 
144  //G4cout << path << G4endl;
145  //G4cout << fileName << G4endl;
146 
147 
148  G4String pathString(path);
149  pathString += "\0";
150  dirFile = pathString + "/" + fileName + ".dat";
151 
152  std::ifstream file(dirFile);
153  std::filebuf* lsdp = file.rdbuf();
154 
155  if (! (lsdp->is_open()) )
156  {
158  execp << "XrayFluoDataSet - data file: " + dirFile + " not found"<<G4endl;
159  G4Exception("XrayFluoDataSet::LoadData()","example-xray_fluorescence01",
160  FatalException, execp);
161  }
162  G4double a = 0;
163  G4int k = 1;
164 
165  do
166  {
167  file >> a;
168  G4int nColumns = 2;
169  // The file is organized into two columns:
170  // 1st column is the energy
171  // 2nd column is the corresponding value
172  // The file terminates with the pattern: -1 -1
173  // -2 -2
174  if (a == -1 || a == -2)
175  {
176 
177  }
178  else
179  {
180  if (k%nColumns != 0)
181  {
182  G4double e = a * unit1;
183  energies->push_back(e);
184 
185  k++;
186 
187  }
188  else if (k%nColumns == 0)
189  {
190  G4double value = a * unit2;
191  data->push_back(value);
192 
193  k = 1;
194  }
195  }
196 
197  } while (a != -2); // end of file
198 
199  file.close();
200  return true;
201 
202 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
TFile * file
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4DataVector * data
G4DataVector * energies
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadNonLogData()

virtual G4bool XrayFluoDataSet::LoadNonLogData ( const G4String )
inlinevirtual

Implements G4VEMDataSet.

Definition at line 100 of file XrayFluoDataSet.hh.

100 {return false;}
Here is the call graph for this function:

◆ NumberOfComponents()

virtual size_t XrayFluoDataSet::NumberOfComponents ( void  ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 76 of file XrayFluoDataSet.hh.

76 { return 0; }

◆ PrintData()

void XrayFluoDataSet::PrintData ( void  ) const
virtual

Implements G4VEMDataSet.

Definition at line 206 of file XrayFluoDataSet.cc.

207 {
208  size_t size = numberOfBins;
209  for (size_t i=0; i<size; i++)
210  {
211  G4double e = (*energies)[i] / unit1;
212  G4double sigma = (*data)[i] / unit2 ;
213  G4cout << "Point: "
214  << e
215  << " - Data value : "
216  << sigma
217  << G4endl;
218  }
219 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the caller graph for this function:

◆ RandomSelect()

virtual G4double XrayFluoDataSet::RandomSelect ( int  = 0) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 83 of file XrayFluoDataSet.hh.

83 {return 0;}
Here is the call graph for this function:

◆ SaveData()

virtual G4bool XrayFluoDataSet::SaveData ( const G4String ) const
inlinevirtual

Implements G4VEMDataSet.

Definition at line 81 of file XrayFluoDataSet.hh.

81 {return true;}

◆ SetEnergiesData()

virtual void XrayFluoDataSet::SetEnergiesData ( G4DataVector ,
G4DataVector ,
int  = 0 
)
inlinevirtual

Implements G4VEMDataSet.

Definition at line 78 of file XrayFluoDataSet.hh.

79  {}

◆ SetLogEnergiesData()

virtual void XrayFluoDataSet::SetLogEnergiesData ( G4DataVector ,
G4DataVector ,
G4DataVector ,
G4DataVector ,
G4int   
)
inlinevirtual

Implements G4VEMDataSet.

Definition at line 94 of file XrayFluoDataSet.hh.

98  {;}

Member Data Documentation

◆ algorithm

const G4VDataSetAlgorithm* XrayFluoDataSet::algorithm
private

Definition at line 116 of file XrayFluoDataSet.hh.

◆ data

G4DataVector* XrayFluoDataSet::data
private

Definition at line 114 of file XrayFluoDataSet.hh.

◆ energies

G4DataVector* XrayFluoDataSet::energies
private

Definition at line 113 of file XrayFluoDataSet.hh.

◆ numberOfBins

size_t XrayFluoDataSet::numberOfBins
private

Definition at line 121 of file XrayFluoDataSet.hh.

◆ unit1

G4double XrayFluoDataSet::unit1
private

Definition at line 118 of file XrayFluoDataSet.hh.

◆ unit2

G4double XrayFluoDataSet::unit2
private

Definition at line 119 of file XrayFluoDataSet.hh.


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