Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
genie::NaturalIsotopes Class Reference

Singleton class to load & serve tables of natural occurring isotopes. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+3.10-2.17-e17-debug/GENIE-Generator/src/Framework/ParticleData/NaturalIsotopes.h"

Classes

struct  Cleaner
 

Public Member Functions

int NElements (int Z) const
 
const NaturalIsotopeElementDataElementData (int Z, int ielement) const
 

Static Public Member Functions

static NaturalIsotopesInstance (void)
 

Private Member Functions

 NaturalIsotopes ()
 
 NaturalIsotopes (const NaturalIsotopes &)
 
virtual ~NaturalIsotopes ()
 
bool LoadTable (void)
 

Private Attributes

map< int, vector< NaturalIsotopeElementData * > > fNaturalIsotopesTable
 

Static Private Attributes

static NaturalIsotopesfInstance = 0
 

Friends

struct Cleaner
 

Detailed Description

Singleton class to load & serve tables of natural occurring isotopes.

Author
Costas Andreopoulos <costas.andreopoulos stfc.ac.uk> University of Liverpool & STFC Rutherford Appleton Lab

Jim Dobson j.dob.nosp@m.son0.nosp@m.7@imp.nosp@m.eria.nosp@m.l.ac..nosp@m.uk Imperial College London

May 30, 2008

Definition at line 31 of file NaturalIsotopes.h.

Constructor & Destructor Documentation

NaturalIsotopes::NaturalIsotopes ( )
private

Definition at line 40 of file NaturalIsotopes.cxx.

References fInstance, LoadTable(), LOG, and pERROR.

Referenced by Instance().

41 {
42  if( ! this->LoadTable() ) {
43  LOG("NatIsotop", pERROR) << "NaturalIsotopes initialization failed!";
44  }
45  fInstance = 0;
46 }
#define pERROR
Definition: Messenger.h:60
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
static NaturalIsotopes * fInstance
genie::NaturalIsotopes::NaturalIsotopes ( const NaturalIsotopes )
private
NaturalIsotopes::~NaturalIsotopes ( )
privatevirtual

Definition at line 48 of file NaturalIsotopes.cxx.

References om::cout, allTimeWatchdog::endl, fInstance, and fNaturalIsotopesTable.

49 {
50  cout << "NaturalIsotopes singleton dtor: "
51  << "Deleting natural isotope data tables" << endl;
52 
53  map<int, vector<NaturalIsotopeElementData*> >::iterator miter;
54  vector<NaturalIsotopeElementData*>::iterator viter;
55 
56  for(miter = fNaturalIsotopesTable.begin();
57  miter != fNaturalIsotopesTable.end(); ++miter) {
58  vector<NaturalIsotopeElementData*> vec = miter->second;
59  for(viter = vec.begin(); viter != vec.end(); ++viter) {
60  NaturalIsotopeElementData * element_data = *viter;
61  if(element_data) {
62  delete element_data;
63  element_data = 0;
64  }
65  }
66  vec.clear();
67  }
68  fNaturalIsotopesTable.clear();
69  fInstance = 0;
70 }
map< int, vector< NaturalIsotopeElementData * > > fNaturalIsotopesTable
Eigen::VectorXd vec
static NaturalIsotopes * fInstance
OStream cout
Definition: OStream.cxx:6

Member Function Documentation

const NaturalIsotopeElementData * NaturalIsotopes::ElementData ( int  Z,
int  ielement 
) const

Definition at line 99 of file NaturalIsotopes.cxx.

References fNaturalIsotopesTable, LOG, pWARN, and Z.

Referenced by main().

100 {
101  map<int, vector<NaturalIsotopeElementData*> >::const_iterator miter;
102 
103  if( (miter=fNaturalIsotopesTable.find(Z)) == fNaturalIsotopesTable.end()) {
104  LOG("NatIsotop", pWARN)
105  << "Table has no elements for natural isotope Z = " << Z;
106  return 0;
107  }
108  vector<NaturalIsotopeElementData*> vec = miter->second;
109  if(ielement >= (int)vec.size() || ielement < 0) {
110  LOG("NatIsotop", pWARN)
111  << "Natural isotope Z = " << Z << " has " << vec.size() << " elements"
112  << " (element = " << ielement << " was requested)";
113  return 0;
114  }
115  return vec[ielement];
116 }
Float_t Z
Definition: plot.C:38
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
map< int, vector< NaturalIsotopeElementData * > > fNaturalIsotopesTable
Eigen::VectorXd vec
#define pWARN
Definition: Messenger.h:61
NaturalIsotopes * NaturalIsotopes::Instance ( void  )
static

Definition at line 72 of file NaturalIsotopes.cxx.

References genie::NaturalIsotopes::Cleaner::DummyMethodAndSilentCompiler(), fInstance, LOG, NaturalIsotopes(), and pINFO.

Referenced by main().

73 {
74  if(fInstance == 0) {
75  LOG("NatIsotop", pINFO) << "NaturalIsotopes late initialization";
76 
77  static NaturalIsotopes::Cleaner cleaner;
79 
81  }
82  return fInstance;
83 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pINFO
Definition: Messenger.h:63
static NaturalIsotopes * fInstance
bool NaturalIsotopes::LoadTable ( void  )
private

eof

Definition at line 118 of file NaturalIsotopes.cxx.

References shutoffs::filename, fNaturalIsotopesTable, MECModelEnuComparisons::i, LOG, getGoodRuns4SAM::n, pDEBUG, pINFO, pWARN, string, and Z.

Referenced by NaturalIsotopes().

119 {
120  // get the natural isotopes table filename
121  string filename = string(gSystem->Getenv("GENIE")) +
122  string("/data/evgen/catalogues/iso/natural-isotopes.data");
123 
124  LOG("NatIsotop", pINFO)
125  << "Loading natural occurring isotope table from file: " << filename;
126 
127  bool is_accessible = ! (gSystem->AccessPathName( filename.c_str() ));
128  if (!is_accessible) {
129  LOG("NatIsotop", pWARN) << "Can not read file: " << filename;
130  return false;
131  }
132 
133  // load the natural isotopes .txt file
134  string input_buf;
135  std::ifstream input(filename.c_str());
136  if (input.is_open()){
137 
138  //skip first 8 lines (comments)
139  for(int i=0; i<8; i++){
140  string buffer;
141  getline(input, buffer);
142  }
143 
144  int Z = -1, Z_previous = -1, nelements = 0, pdgcode = 0;
145  double atomicmass = 0, abundance = 0;
146  string elementname, subelementname;
147 
148  while( !input.eof() ) {
149 
150  //read in naturally occuring element info
151  input >> Z;
152  input >> elementname;
153  input >> nelements;
154 
155  vector<NaturalIsotopeElementData *> vec;
157 
158  // check not re-reading same element
159  if(Z!=Z_previous){
160  LOG("NatIsotop", pDEBUG) << "Reading entry for Z = " << Z;
161  for(int n=0 ; n < nelements; n++){
162  input >> subelementname;
163  input >> pdgcode;
164  input >> atomicmass;
165  input >> abundance;
166  LOG("NatIsotop", pDEBUG)
167  << " - Element: " << n << ", pdg = " << pdgcode
168  << ", A = " << atomicmass << ", abundance = " << abundance;
169  data = new NaturalIsotopeElementData(pdgcode, abundance);
170  vec.push_back(data);
171  }
172  fNaturalIsotopesTable.insert(
173  map<int,vector<NaturalIsotopeElementData*> >::value_type(Z,vec));
174  }
175  Z_previous = Z;
176  } //!eof
177 
178  } else {
179  return false;
180  } //open?
181 
182  return true;
183 }
string filename
Definition: shutoffs.py:106
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
const XML_Char const XML_Char * data
Definition: expat.h:268
Float_t Z
Definition: plot.C:38
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
map< int, vector< NaturalIsotopeElementData * > > fNaturalIsotopesTable
#define pINFO
Definition: Messenger.h:63
Eigen::VectorXd vec
#define pWARN
Definition: Messenger.h:61
#define pDEBUG
Definition: Messenger.h:64
enum BeamMode string
int NaturalIsotopes::NElements ( int  Z) const

Definition at line 85 of file NaturalIsotopes.cxx.

References fNaturalIsotopesTable, LOG, pWARN, and Z.

Referenced by main().

86 {
87  map<int, vector<NaturalIsotopeElementData*> >::const_iterator miter;
88 
89  if( (miter=fNaturalIsotopesTable.find(Z)) == fNaturalIsotopesTable.end()) {
90  LOG("NatIsotop", pWARN)
91  << "Table has no elements for natural isotope Z = " << Z;
92  return 0;
93  }
94  vector<NaturalIsotopeElementData*> vec = miter->second;
95  return vec.size();
96 }
Float_t Z
Definition: plot.C:38
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
map< int, vector< NaturalIsotopeElementData * > > fNaturalIsotopesTable
Eigen::VectorXd vec
#define pWARN
Definition: Messenger.h:61

Friends And Related Function Documentation

friend struct Cleaner
friend

Definition at line 59 of file NaturalIsotopes.h.

Member Data Documentation

NaturalIsotopes * NaturalIsotopes::fInstance = 0
staticprivate
map<int, vector<NaturalIsotopeElementData*> > genie::NaturalIsotopes::fNaturalIsotopesTable
private

Definition at line 48 of file NaturalIsotopes.h.

Referenced by ElementData(), LoadTable(), NElements(), and ~NaturalIsotopes().


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