Geant4  10.02.p03
G4NeutronCaptureXS Class Reference

#include <G4NeutronCaptureXS.hh>

Inheritance diagram for G4NeutronCaptureXS:
Collaboration diagram for G4NeutronCaptureXS:

Public Member Functions

 G4NeutronCaptureXS ()
 
virtual ~G4NeutronCaptureXS ()
 
virtual G4bool IsElementApplicable (const G4DynamicParticle *, G4int Z, const G4Material *)
 
virtual G4bool IsIsoApplicable (const G4DynamicParticle *, G4int Z, G4int A, const G4Element *, const G4Material *)
 
virtual G4double GetElementCrossSection (const G4DynamicParticle *, G4int Z, const G4Material *mat=0)
 
virtual G4double GetIsoCrossSection (const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat)
 
virtual G4Isotope * SelectIsotope (const G4Element *, G4double kinEnergy)
 
virtual void BuildPhysicsTable (const G4ParticleDefinition &)
 
virtual void CrossSectionDescription (std::ostream &) const
 
- Public Member Functions inherited from G4VCrossSectionDataSet
 G4VCrossSectionDataSet (const G4String &nam="")
 
virtual ~G4VCrossSectionDataSet ()
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=0)
 
G4double ComputeCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *mat=0)
 
virtual void DumpPhysicsTable (const G4ParticleDefinition &)
 
virtual G4int GetVerboseLevel () const
 
virtual void SetVerboseLevel (G4int value)
 
G4double GetMinKinEnergy () const
 
void SetMinKinEnergy (G4double value)
 
G4double GetMaxKinEnergy () const
 
void SetMaxKinEnergy (G4double value)
 
const G4String & GetName () const
 

Static Public Member Functions

static const char * Default_Name ()
 

Private Member Functions

void Initialise (G4int Z, const char *=0)
 
G4PhysicsVector * RetrieveVector (std::ostringstream &in, G4bool warn)
 
G4double IsoCrossSection (G4double ekin, G4int Z, G4int A)
 
G4NeutronCaptureXS & operator= (const G4NeutronCaptureXS &right)
 
 G4NeutronCaptureXS (const G4NeutronCaptureXS &)
 

Private Attributes

G4double emax
 
G4double elimit
 
G4bool isMaster
 
std::vector< G4double > temp
 

Static Private Attributes

static G4ElementData * data = 0
 
static const G4int amin [MAXZCAPTURE]
 
static const G4int amax [MAXZCAPTURE]
 

Additional Inherited Members

- Protected Member Functions inherited from G4VCrossSectionDataSet
void SetName (const G4String &)
 
- Protected Attributes inherited from G4VCrossSectionDataSet
G4int verboseLevel
 

Detailed Description

Definition at line 61 of file G4NeutronCaptureXS.hh.

Constructor & Destructor Documentation

◆ G4NeutronCaptureXS() [1/2]

G4NeutronCaptureXS::G4NeutronCaptureXS ( )

Definition at line 86 of file G4NeutronCaptureXS.cc.

88  emax(20*MeV),elimit(1.0e-10*eV)
89 {
90  // verboseLevel = 0;
91  if(verboseLevel > 0){
92  G4cout << "G4NeutronCaptureXS::G4NeutronCaptureXS: Initialise for Z < "
93  << MAXZCAPTURE << G4endl;
94  }
95  isMaster = false;
96 }
static const double MeV
Definition: G4SIunits.hh:211
G4VCrossSectionDataSet(const G4String &nam="")
const G4int MAXZCAPTURE
G4GLOB_DLL std::ostream G4cout
static const double eV
Definition: G4SIunits.hh:212
static const char * Default_Name()
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ ~G4NeutronCaptureXS()

G4NeutronCaptureXS::~G4NeutronCaptureXS ( )
virtual

Definition at line 98 of file G4NeutronCaptureXS.cc.

99 {
100  if(isMaster) { delete data; data = 0; }
101 }
static G4ElementData * data

◆ G4NeutronCaptureXS() [2/2]

G4NeutronCaptureXS::G4NeutronCaptureXS ( const G4NeutronCaptureXS &  )
private

Member Function Documentation

◆ BuildPhysicsTable()

void G4NeutronCaptureXS::BuildPhysicsTable ( const G4ParticleDefinition &  p)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 248 of file G4NeutronCaptureXS.cc.

249 {
250  if(verboseLevel > 0){
251  G4cout << "G4NeutronCaptureXS::BuildPhysicsTable for "
252  << p.GetParticleName() << G4endl;
253  }
254  if(p.GetParticleName() != "neutron") {
256  ed << p.GetParticleName() << " is a wrong particle type -"
257  << " only neutron is allowed";
258  G4Exception("G4NeutronCaptureXS::BuildPhysicsTable(..)","had012",
259  FatalException, ed, "");
260  return;
261  }
262 
263  if(!data) {
264  isMaster = true;
265  data = new G4ElementData();
266  data->SetName("NeutronCapture");
267  temp.resize(13,0.0);
268  }
269 
270  // it is possible re-initialisation for the second run
271  if(isMaster) {
272 
273  // check environment variable
274  // Build the complete string identifying the file with the data set
275  char* path = getenv("G4NEUTRONXSDATA");
276 
277  // Access to elements
278  const G4ElementTable* theElmTable = G4Element::GetElementTable();
279  size_t numOfElm = G4Element::GetNumberOfElements();
280  if(numOfElm > 0) {
281  for(size_t i=0; i<numOfElm; ++i) {
282  G4int Z = G4int(((*theElmTable)[i])->GetZ());
283  if(Z < 1) { Z = 1; }
284  else if(Z >= MAXZCAPTURE) { Z = MAXZCAPTURE-1; }
285  //G4cout << "Z= " << Z << G4endl;
286  // Initialisation
287  if(!data->GetElementData(Z)) { Initialise(Z, path); }
288  }
289  }
290  }
291 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
std::vector< G4double > temp
G4PhysicsVector * GetElementData(G4int Z)
const G4int MAXZCAPTURE
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
Definition: G4Element.cc:402
Float_t Z
void Initialise(G4int Z, const char *=0)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void SetName(const G4String &nam)
std::vector< G4Element * > G4ElementTable
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:395
static G4ElementData * data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CrossSectionDescription()

void G4NeutronCaptureXS::CrossSectionDescription ( std::ostream &  outFile) const
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 103 of file G4NeutronCaptureXS.cc.

104 {
105  outFile << "G4NeutronCaptureXS calculates the neutron capture cross sections\n"
106  << "on nuclei using data from the high precision neutron database.\n"
107  << "These data are simplified and smoothed over the resonance region\n"
108  << "in order to reduce CPU time. G4NeutronCaptureXS is valid up to\n"
109  << "20 MeV for all targets through U.\n";
110 }
Here is the caller graph for this function:

◆ Default_Name()

static const char* G4NeutronCaptureXS::Default_Name ( )
inlinestatic

Definition at line 69 of file G4NeutronCaptureXS.hh.

69 {return "G4NeutronCaptureXS";}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetElementCrossSection()

G4double G4NeutronCaptureXS::GetElementCrossSection ( const G4DynamicParticle *  aParticle,
G4int  Z,
const G4Material *  mat = 0 
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 128 of file G4NeutronCaptureXS.cc.

130 {
131  G4double xs = 0.0;
132  G4double ekin = aParticle->GetKineticEnergy();
133  if(ekin > emax || Z < 1 || Z >= MAXZCAPTURE) { return xs; }
134  if(ekin < elimit) { ekin = elimit; }
135 
136  // element was not initialised
138  if(!pv) {
139  Initialise(Z);
140  pv = data->GetElementData(Z);
141  if(!pv) { return xs; }
142  }
143 
144  G4double e1 = pv->Energy(0);
145  if(ekin < e1) { xs = (*pv)[0]*std::sqrt(e1/ekin); }
146  else if(ekin <= pv->GetMaxEnergy()) { xs = pv->Value(ekin); }
147 
148  if(verboseLevel > 0){
149  G4cout << "ekin= " << ekin << ", xs= " << xs << G4endl;
150  }
151  return xs;
152 }
G4PhysicsVector * GetElementData(G4int Z)
const G4int MAXZCAPTURE
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
Float_t Z
void Initialise(G4int Z, const char *=0)
G4double Value(G4double theEnergy, size_t &lastidx) const
static const G4double e1
#define G4endl
Definition: G4ios.hh:61
G4double Energy(size_t index) const
double G4double
Definition: G4Types.hh:76
static G4ElementData * data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIsoCrossSection()

G4double G4NeutronCaptureXS::GetIsoCrossSection ( const G4DynamicParticle *  aParticle,
G4int  Z,
G4int  A,
const G4Isotope *  iso,
const G4Element *  elm,
const G4Material *  mat 
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 155 of file G4NeutronCaptureXS.cc.

159 {
160  G4double xs = 0.0;
161  G4double ekin = aParticle->GetKineticEnergy();
162  if(ekin <= emax && Z > 0 && Z < MAXZCAPTURE) {
163  xs = IsoCrossSection(ekin, Z, A);
164  }
165  return xs;
166 }
const G4int MAXZCAPTURE
G4double GetKineticEnergy() const
double A(double temperature)
Float_t Z
G4double IsoCrossSection(G4double ekin, G4int Z, G4int A)
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialise()

void G4NeutronCaptureXS::Initialise ( G4int  Z,
const char *  p = 0 
)
private

Definition at line 294 of file G4NeutronCaptureXS.cc.

295 {
296  if(data->GetElementData(Z) || Z < 1 || Z >= MAXZCAPTURE) { return; }
297  const char* path = p;
298 
299  // check environment variable
300  if(!p) {
301  path = getenv("G4NEUTRONXSDATA");
302  if (!path) {
303  G4Exception("G4NeutronCaptureXS::Initialise(..)","had013",FatalException,
304  "Environment variable G4NEUTRONXSDATA is not defined");
305  return;
306  }
307  }
308 
309  // upload element data
310  std::ostringstream ost;
311  ost << path << "/cap" << Z ;
312  G4PhysicsVector* v = RetrieveVector(ost, true);
313  data->InitialiseForElement(Z, v);
314 
315  // upload isotope data
316  if(amin[Z] > 0) {
317  size_t nmax = (size_t)(amax[Z]-amin[Z]+1);
318  data->InitialiseForComponent(Z, nmax);
319 
320  for(G4int A=amin[Z]; A<=amax[Z]; ++A) {
321  std::ostringstream ost1;
322  ost1 << path << "/cap" << Z << "_" << A;
323  v = RetrieveVector(ost1, false);
324  data->AddComponent(Z, A, v);
325  }
326  }
327 }
static const G4int amin[MAXZCAPTURE]
G4PhysicsVector * RetrieveVector(std::ostringstream &in, G4bool warn)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
G4PhysicsVector * GetElementData(G4int Z)
const G4int MAXZCAPTURE
int G4int
Definition: G4Types.hh:78
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
double A(double temperature)
Float_t Z
const G4int nmax
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4int amax[MAXZCAPTURE]
void InitialiseForComponent(G4int Z, G4int nComponents=0)
static G4ElementData * data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsElementApplicable()

G4bool G4NeutronCaptureXS::IsElementApplicable ( const G4DynamicParticle *  ,
G4int  Z,
const G4Material *   
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 113 of file G4NeutronCaptureXS.cc.

115 {
116  return true;
117 }
Here is the caller graph for this function:

◆ IsIsoApplicable()

G4bool G4NeutronCaptureXS::IsIsoApplicable ( const G4DynamicParticle *  ,
G4int  Z,
G4int  A,
const G4Element *  ,
const G4Material *   
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 120 of file G4NeutronCaptureXS.cc.

123 {
124  return true;
125 }
Here is the caller graph for this function:

◆ IsoCrossSection()

G4double G4NeutronCaptureXS::IsoCrossSection ( G4double  ekin,
G4int  Z,
G4int  A 
)
private

Definition at line 168 of file G4NeutronCaptureXS.cc.

169 {
170  G4double xs = 0.0;
171  if(ekin < elimit) { ekin = elimit; }
172 
173  // element was not initialised
175  if(!pv) {
176  Initialise(Z);
177  pv = data->GetElementData(Z);
178  }
179 
180  // isotope cross section exist
181  if(pv && amin[Z] > 0 && A >= amin[Z] && A <= amax[Z]) {
182  pv = data->GetComponentDataByID(Z, A - amin[Z]);
183  if(pv) {
184 
185  G4double e1 = pv->Energy(1);
186  if(ekin < e1) { xs = (*pv)[1]*std::sqrt(e1/ekin); }
187  else if(ekin <= pv->GetMaxEnergy()) { xs = pv->Value(ekin); }
188  }
189  }
190  if(verboseLevel > 0) {
191  G4cout << "G4NeutronCaptureXS::IsoCrossSection: Ekin(MeV)= " << ekin/MeV
192  << " xs(b)= " << xs/barn
193  << " Z= " << Z << " A= " << A << G4endl;
194  }
195  return xs;
196 }
static const G4int amin[MAXZCAPTURE]
static const double MeV
Definition: G4SIunits.hh:211
G4PhysicsVector * GetComponentDataByID(G4int Z, G4int id)
G4PhysicsVector * GetElementData(G4int Z)
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
Float_t Z
void Initialise(G4int Z, const char *=0)
G4double Value(G4double theEnergy, size_t &lastidx) const
static const G4double e1
static const G4int amax[MAXZCAPTURE]
#define G4endl
Definition: G4ios.hh:61
static const double barn
Definition: G4SIunits.hh:104
G4double Energy(size_t index) const
double G4double
Definition: G4Types.hh:76
static G4ElementData * data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

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

◆ RetrieveVector()

G4PhysicsVector * G4NeutronCaptureXS::RetrieveVector ( std::ostringstream &  in,
G4bool  warn 
)
private

Definition at line 330 of file G4NeutronCaptureXS.cc.

331 {
332  G4PhysicsLogVector* v = 0;
333  std::ifstream filein(ost.str().c_str());
334  if (!(filein)) {
335  if(warn) {
337  ed << "Data file <" << ost.str().c_str()
338  << "> is not opened!";
339  G4Exception("G4NeutronCaptureXS::RetrieveVector(..)","had014",
340  FatalException, ed, "Check G4NEUTRONXSDATA");
341  }
342  } else {
343  if(verboseLevel > 1) {
344  G4cout << "File " << ost.str()
345  << " is opened by G4NeutronCaptureXS" << G4endl;
346  }
347  // retrieve data from DB
348  v = new G4PhysicsLogVector();
349  if(!v->Retrieve(filein, true)) {
351  ed << "Data file <" << ost.str().c_str()
352  << "> is not retrieved!";
353  G4Exception("G4NeutronCaptureXS::RetrieveVector(..)","had015",
354  FatalException, ed, "Check G4NEUTRONXSDATA");
355  }
356  }
357  return v;
358 }
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectIsotope()

G4Isotope * G4NeutronCaptureXS::SelectIsotope ( const G4Element *  anElement,
G4double  kinEnergy 
)
virtual

Reimplemented from G4VCrossSectionDataSet.

Definition at line 198 of file G4NeutronCaptureXS.cc.

200 {
201  size_t nIso = anElement->GetNumberOfIsotopes();
202  G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
203  G4Isotope* iso = (*isoVector)[0];
204 
205  // more than 1 isotope
206  if(1 < nIso) {
207  G4int Z = G4lrint(anElement->GetZ());
208 
209  G4double* abundVector = anElement->GetRelativeAbundanceVector();
210  G4double q = G4UniformRand();
211  G4double sum = 0.0;
212 
213  // is there isotope wise cross section?
214  size_t j;
215  if(0 == amin[Z] || Z >= MAXZCAPTURE) {
216  for (j = 0; j<nIso; ++j) {
217  sum += abundVector[j];
218  if(q <= sum) {
219  iso = (*isoVector)[j];
220  break;
221  }
222  }
223  } else {
224 
225  // element may be not initialised in unit test
226  if(!data->GetElementData(Z)) { Initialise(Z); }
227  size_t nn = temp.size();
228  if(nn < nIso) { temp.resize(nIso, 0.); }
229 
230  for (j=0; j<nIso; ++j) {
231  sum += abundVector[j]*IsoCrossSection(kinEnergy, Z,
232  (*isoVector)[j]->GetN());
233  temp[j] = sum;
234  }
235  sum *= q;
236  for (j = 0; j<nIso; ++j) {
237  if(temp[j] >= sum) {
238  iso = (*isoVector)[j];
239  break;
240  }
241  }
242  }
243  }
244  return iso;
245 }
static const G4int amin[MAXZCAPTURE]
std::vector< G4Isotope * > G4IsotopeVector
std::vector< G4double > temp
G4PhysicsVector * GetElementData(G4int Z)
const G4int MAXZCAPTURE
int G4int
Definition: G4Types.hh:78
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
#define G4UniformRand()
Definition: Randomize.hh:97
Float_t Z
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
void Initialise(G4int Z, const char *=0)
G4double IsoCrossSection(G4double ekin, G4int Z, G4int A)
int G4lrint(double ad)
Definition: templates.hh:163
double G4double
Definition: G4Types.hh:76
G4double GetZ() const
Definition: G4Element.hh:131
static G4ElementData * data
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ amax

const G4int G4NeutronCaptureXS::amax
staticprivate
Initial value:
= {
0,
0, 0, 7, 0,11,13,15,18, 0, 0,
0, 0, 0,30, 0, 0, 0,40, 0,48,
0, 0, 0, 0, 0,58, 0,64,65,70,
0,76, 0, 0, 0, 0, 0, 0, 0,96,
0, 0, 0, 0, 0, 0,109,116, 0,124,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,186, 0, 0, 0, 0, 0, 0,
0,208, 0, 0, 0, 0, 0, 0, 0, 0,
0,238}

Definition at line 116 of file G4NeutronCaptureXS.hh.

◆ amin

const G4int G4NeutronCaptureXS::amin
staticprivate
Initial value:
= {
0,
0, 0, 6, 0,10,12,14,16, 0, 0,
0, 0, 0,28, 0, 0, 0,36, 0,40,
0, 0, 0, 0, 0,54, 0,58,63,64,
0,70, 0, 0, 0, 0, 0, 0, 0,90,
0, 0, 0, 0, 0, 0,107,106, 0,112,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,180, 0, 0, 0, 0, 0, 0,
0,204, 0, 0, 0, 0, 0, 0, 0, 0,
0,235}

Definition at line 115 of file G4NeutronCaptureXS.hh.

◆ data

G4ElementData * G4NeutronCaptureXS::data = 0
staticprivate

Definition at line 112 of file G4NeutronCaptureXS.hh.

◆ elimit

G4double G4NeutronCaptureXS::elimit
private

Definition at line 108 of file G4NeutronCaptureXS.hh.

◆ emax

G4double G4NeutronCaptureXS::emax
private

Definition at line 107 of file G4NeutronCaptureXS.hh.

◆ isMaster

G4bool G4NeutronCaptureXS::isMaster
private

Definition at line 110 of file G4NeutronCaptureXS.hh.

◆ temp

std::vector<G4double> G4NeutronCaptureXS::temp
private

Definition at line 113 of file G4NeutronCaptureXS.hh.


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