00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <fstream>
00010
00011 #include "HepPDT/defs.h"
00012 #include "HepPDT/TableBuilder.hh"
00013 #include "HepPDT/ParticleDataTable.hh"
00014
00015 int main()
00016 {
00017 const char infile[] = "@top_srcdir@/data/particle.tbl";
00018 const char infile2[] = "@top_srcdir@/tests/HepPDT/extras.tbl";
00019 const char outfile[] = "testReadParticleTable.out";
00020
00021 std::ifstream pdfile( infile );
00022 if( !pdfile ) {
00023 std::cerr << "cannot open " << infile << std::endl;
00024 exit(-1);
00025 }
00026 std::ifstream pdfile2( infile2 );
00027 if( !pdfile2 ) {
00028 std::cerr << "cannot open " << infile2 << std::endl;
00029 exit(-1);
00030 }
00031
00032 HepPDT::ParticleDataTable datacol( "Generic Particle Table" );
00033 {
00034
00035 HepPDT::TableBuilder tb(datacol);
00036
00037
00038
00039
00040 if( !addParticleTable( pdfile, tb, true ) ) {
00041 std::cout << "error reading PDG pdt file " << std::endl;
00042 }
00043 if( !addParticleTable( pdfile2, tb, true ) ) {
00044 std::cout << "error reading extra pdt file " << std::endl;
00045 }
00046 }
00047
00048 std::ofstream wfile( outfile );
00049 if( !wfile ) {
00050 std::cerr << "cannot open " << outfile << std::endl;
00051 exit(-1);
00052 }
00053
00054 datacol.writeParticleData(wfile);
00055
00056 wfile << std::endl;
00057 wfile << std::endl;
00058 HepPDT::ParticleData * pd;
00059 pd=datacol.particle(HepPDT::ParticleID(1000020040));
00060 if(pd) pd->write(wfile);
00061 pd=datacol.particle(HepPDT::ParticleID(1000050110));
00062 if(pd) pd->write(wfile);
00063
00064
00065 const char outfile3[] = "testReadParticleTableStatus.out";
00066 std::ofstream wpdt3( outfile3 );
00067 if( !wpdt3 ) {
00068 std::cerr << "cannot open " << outfile3 << std::endl;
00069 exit(-1);
00070 }
00071 datacol.writeParticleStatus(wpdt3);
00072
00073 return 0;
00074 }