00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <fstream>
00013 #include <iomanip>
00014
00015 #include "HepPDT/defs.h"
00016 #include "HepPDT/TableBuilder.hh"
00017 #include "HepPDT/ParticleDataTable.hh"
00018 #include "HepPDT/HeavyIonUnknownID.hh"
00019
00020 #include "TestNuclearFragment.hh"
00021
00022 void pdtSimpleTest( char[300], std::ofstream & );
00023 void pdtFragmentTest( char[300], std::ofstream & );
00024 void duplicateFragmentTest( char[300], std::ofstream & );
00025 void testPDMethods( HepPDT::ParticleDataTable&, std::ofstream & );
00026
00027 int main()
00028 {
00029 char pdgfile[300] = "";
00030 const char outfile[] = "testHepPDT.out";
00031 std::cin >> pdgfile;
00032
00033 std::ofstream wpdfile( outfile );
00034 if( !wpdfile ) {
00035 std::cerr << "cannot open " << outfile << std::endl;
00036 exit(-1);
00037 }
00038
00039
00040 pdtSimpleTest( pdgfile, wpdfile );
00041
00042 pdtFragmentTest( pdgfile, wpdfile );
00043
00044 duplicateFragmentTest( pdgfile, wpdfile );
00045
00046 return 0;
00047 }
00048
00049 void pdtSimpleTest( char pdgfile[300], std::ofstream & wpdfile )
00050 {
00051
00052 std::ifstream pdfile( pdgfile );
00053 if( !pdfile ) {
00054 std::cerr << "cannot open " << pdgfile << std::endl;
00055 exit(-1);
00056 }
00057
00058 HepPDT::ParticleDataTable datacol( "2006 PDG Table" );
00059 {
00060
00061 HepPDT::TableBuilder tb(datacol);
00062
00063 if( !HepPDT::addPDGParticles( pdfile, tb ) ) {
00064 std::cout << "error reading PDG file " << std::endl;
00065 }
00066 }
00067
00068 pdfile.close();
00069
00070 const char outfile1[] = "testHepPDTtable.out";
00071
00072 std::ofstream wpdt1( outfile1 );
00073 if( !wpdt1 ) {
00074 std::cerr << "cannot open " << outfile1 << std::endl;
00075 exit(-1);
00076 }
00077 datacol.writeParticleData(wpdt1);
00078
00079 wpdfile << std::endl;
00080
00081
00082 HepPDT::ParticleData * pd;
00083 pd=datacol.particle(HepPDT::ParticleID(111));
00084
00085 if(pd) {
00086 pd->write(wpdfile);
00087 wpdfile << "Resonance info for 111 "
00088 << pd->totalWidth().value() << " "
00089 << pd->totalWidth().sigma() << " "
00090 << pd->lowerCutoff() << " "
00091 << pd->upperCutoff() << std::endl;
00092 }
00093
00094 pd=datacol.particle(HepPDT::ParticleID(-111));
00095 if(pd) pd->write(wpdfile);
00096 pd=datacol.particle(HepPDT::ParticleID(211));
00097 if(pd) pd->write(wpdfile);
00098
00099 pd=datacol.particle(std::string("pi0"));
00100 if(pd) pd->write(wpdfile);
00101
00102
00103 datacol.writeParticleInfo(wpdfile);
00104
00105 testPDMethods( datacol, wpdfile );
00106 }
00107
00108 void pdtFragmentTest( char pdgfile[300], std::ofstream & wpdfile )
00109 {
00110 wpdfile << std::endl;
00111 wpdfile << " Begin test of HeavyIonUnknownID " << std::endl;
00112
00113 std::ifstream pdfile2( pdgfile );
00114 if( !pdfile2 ) {
00115 std::cerr << "cannot open " << pdgfile << std::endl;
00116 exit(-1);
00117 }
00118
00119
00120 HepPDT::ParticleDataTable pdt2( "Handle Heavy Ions",
00121 new HepPDT::HeavyIonUnknownID );
00122 {
00123
00124 HepPDT::TableBuilder tb2(pdt2);
00125
00126 if( !HepPDT::addPDGParticles( pdfile2, tb2 ) ) {
00127 std::cout << "error reading PDG file " << std::endl;
00128 }
00129 }
00130
00131 pdfile2.close();
00132
00133
00134 HepPDT::ParticleData * pd=pdt2.particle(HepPDT::ParticleID(1000020040));
00135 wpdfile << " Printing information for unknown nuclear fragment "
00136 << std::endl;
00137 if(pd) pd->write(wpdfile);
00138 }
00139
00140 void duplicateFragmentTest( char pdgfile[300], std::ofstream & wpdfile )
00141 {
00142 wpdfile << std::endl;
00143 wpdfile << " Begin test of duplicate nuclear fragments " << std::endl;
00144
00145 std::ifstream pdfile2( pdgfile );
00146 if( !pdfile2 ) {
00147 std::cerr << "cannot open " << pdgfile << std::endl;
00148 exit(-1);
00149 }
00150
00151 HepPDT::ParticleDataTable pdt( "Duplicate Nuclear Fragments",
00152 new HepPDT::TestNuclearFragment );
00153 {
00154
00155 HepPDT::TableBuilder tb2(pdt);
00156
00157 if( !HepPDT::addPDGParticles( pdfile2, tb2 ) ) {
00158 std::cout << "error reading PDG file " << std::endl;
00159 }
00160 }
00161
00162 pdfile2.close();
00163
00164
00165 wpdfile << " Printing information for unknown nuclear fragments "
00166 << std::endl;
00167 HepPDT::ParticleData * pd=pdt.particle(HepPDT::ParticleID(1000020040));
00168 if(pd) pd->write(wpdfile);
00169 pd=pdt.particle(HepPDT::ParticleID(1000020040));
00170 if(pd) pd->write(wpdfile);
00171 pd=pdt.particle(HepPDT::ParticleID(1000010040));
00172 if(pd) pd->write(wpdfile);
00173 pd=pdt.particle(HepPDT::ParticleID(1000020040));
00174 if(pd) pd->write(wpdfile);
00175
00176 const char outfile2[] = "testHepPDTfragment.out";
00177 std::ofstream wpdt( outfile2 );
00178 if( !wpdt ) {
00179 std::cerr << "cannot open " << outfile2 << std::endl;
00180 exit(-1);
00181 }
00182 pdt.writeParticleData(wpdt);
00183
00184
00185 const char outfile3[] = "testHepPDTstatus.out";
00186 std::ofstream wpdt3( outfile3 );
00187 if( !wpdt3 ) {
00188 std::cerr << "cannot open " << outfile3 << std::endl;
00189 exit(-1);
00190 }
00191 pdt.writeParticleStatus(wpdt3);
00192 }
00193
00194 void testPDMethods( HepPDT::ParticleDataTable& datacol, std::ofstream & wpdfile )
00195 {
00196 wpdfile << std::endl;
00197 wpdfile << "Begin test of ParticleData methods " << std::endl;
00198 HepPDT::ParticleData * pd;
00199 int id[16] = { 5, 24, 15, 213, 3214, 10213, 9050225, 541, 129050225,
00200 2000025, 3101, 3301, 2212, 1000020040, 1000060120, 555 };
00201 int it;
00202 for( it=0; it < 16; it++ ) {
00203 pd=datacol.particle(HepPDT::ParticleID(id[it]));
00204 if(pd) {
00205 if( pd->hasUp() ) {
00206 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00207 << " has an up quark" << std::endl;
00208 }
00209 if( pd->hasDown() ) {
00210 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00211 << " has a down quark" << std::endl;
00212 }
00213 if( pd->hasStrange() ) {
00214 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00215 << " has a strange quark" << std::endl;
00216 }
00217 if( pd->hasCharm() ) {
00218 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00219 << " has a charmed quark" << std::endl;
00220 }
00221 if( pd->hasBottom() ) {
00222 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00223 << " has a bottom quark" << std::endl;
00224 }
00225 if( pd->hasTop() ) {
00226 wpdfile << "Particle " << pd->name() << " " << pd->pid()
00227 << " has a top quark" << std::endl;
00228 }
00229 }
00230 }
00231 }