HepPDT Reference Documentation

HepPDT

testReadEvtGen.cc.in

00001 // $Id: testReadEvtGen.cc.in,v 1.5 2009/01/09 20:28:34 garren Exp $
00002 // ----------------------------------------------------------------------
00003 // testReadEvtGen.cc
00004 //
00005 // read EvtGen table and write it out
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 infile1[] = "@top_srcdir@/examples/data/evt.pdl";
00018     const char infile2[] = "@top_srcdir@/examples/data/DECAY.DEC";
00019     const char outfile[] = "testReadEvtGen.out";
00020     // open input files
00021     std::ifstream pdfile1( infile1 );
00022     if( !pdfile1 ) { 
00023       std::cerr << "cannot open " << infile1 << std::endl;
00024       exit(-1);
00025     }
00026     // construct empty PDT
00027     std::ifstream pdfile2( infile2 );
00028     if( !pdfile2 ) { 
00029       std::cerr << "cannot open " << infile2 << std::endl;
00030       exit(-1);
00031     }
00032     HepPDT::ParticleDataTable datacol( "EvtGen Table" );
00033     {
00034         // Construct table builder
00035         HepPDT::TableBuilder  tb(datacol);
00036         // read the input - put as many here as you want
00037         if( !addEvtGenParticles( pdfile1, tb ) ) { std::cout << "error reading EvtGen pdt file " << std::endl; }
00038         if( !addEvtGenParticles( pdfile2, tb ) ) { std::cout << "error reading EvtGen decay file " << std::endl; }
00039     }   // the tb destructor fills datacol
00040     std::ofstream wfile( outfile );
00041     if( !wfile ) { 
00042       std::cerr << "cannot open " << outfile << std::endl;
00043       exit(-1);
00044     }
00045     datacol.writeParticleData(wfile);
00046    
00047     return 0;
00048 }

Generated on Fri Dec 4 14:05:23 2009 for HepPDT by  doxygen 1.4.7