25 #include "TParticlePDG.h"
28 using namespace genie;
32 int setA(
int pdg,
int a);
35 int main(
int argc,
char** argv)
37 bool docheckpdg =
false;
40 for (
int iarg=1; iarg < argc; ++iarg) {
44 std::string argvstr = std::string(argv[iarg]);
45 if ( argvstr ==
"--check-pdg" ) docheckpdg =
true;
46 else if ( argvstr ==
"--avg-a" ) calcavg =
true;
48 cout <<
"Usage: " << argv[0] <<
" [--check-pdg] [--avg-a]" << endl;
54 <<
"Testing the NaturalIsotopes utility";
62 <<
"Check on PDG in PDGLibrary: [PDG,PDG-proton,PDG-neutron]";
65 for(
int Z = 1; Z < 104; Z++){
68 <<
" Number of elements = " << nel;
71 double abund, avg_a = 0;
73 for(
int n = 0; n < nel; n++){
77 avg_a += double(
getA(pdg)) * abund;
78 extra = ( docheckpdg ) ?
PDGcheck(pdg) :
"";
80 <<
" -- Element: " << n
81 <<
", PdgCode = " << pdg
83 <<
", Abundance = " << abund;
85 if ( calcavg && ( nel > 1 ) ) {
87 pdg =
setA(pdg,TMath::Nint(avg_a));
88 extra = ( docheckpdg ) ?
PDGcheck(pdg) :
"";
91 <<
" PdgCode = " << pdg
93 <<
", average <A> " << avg_a ;
101 {
return (
int(pdg/10)%1000); }
105 return int(pdg/10000)*10000 + 10*
a;
110 const int minus_p = 10010;
111 const int minus_n = 10;
114 int pdg_minus_p = pdg - minus_p;
115 int pdg_minus_n = pdg - minus_n;
116 const TParticlePDG * part = pdglib->
Find(pdg);
117 const TParticlePDG * part_minus_p = pdglib->
Find(pdg_minus_p);
118 const TParticlePDG * part_minus_n = pdglib->
Find(pdg_minus_n);
119 string codeck =
" [";
120 codeck += ( (part) ?
"ok" :
"NO" );
121 if ( pdg != 1000010010 ) {
123 codeck += ( (part_minus_p) ?
"ok" :
"NO" );
125 codeck += ( (part_minus_n) ?
"ok" :
"NO" );
int main(int argc, char **argv)
double Abundance(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
std::string PDGcheck(int pdg)
int NElements(int Z) const
static NaturalIsotopes * Instance(void)
static PDGLibrary * Instance(void)
Singleton class to load & serve a TDatabasePDG.
Singleton class to load & serve tables of natural occurring isotopes.
TParticlePDG * Find(int pdgc, bool must_exist=true)
const NaturalIsotopeElementData * ElementData(int Z, int ielement) const