| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

IO_AsciiParticles.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 #ifndef HEPMC_IO_ASCIIPARTICLES_H
00003 #define HEPMC_IO_ASCIIPARTICLES_H
00004 
00006 // Mikhail.Kirsanov@Cern.CH, 2006
00007 // event input/output in ascii format for eye and machine reading
00009 //
00010 // Strategy for reading or writing events/particleData as machine readable
00011 //  ascii to a file. When instantiating, the mode of file to be created 
00012 //  must be specified. Options are:
00013 //      std::ios::in     open file for input 
00014 //      std::ios::out    open file for output
00015 //      std::ios::trunc  erase old file when opening (i.e. ios::out|ios::trunc
00016 //                    removes oldfile, and creates a new one for output )
00017 //      std::ios::app    append output to end of file
00018 //  for the purposes of this class, simultaneous input and output mode 
00019 //  ( std::ios::in | std::ios::out ) is not allowed.
00020 // 
00021 // Event listings are preceded by the key:
00022 //  "HepMC::IO_AsciiParticles-START_EVENT_LISTING\n"
00023 //  and terminated by the key:
00024 //  "HepMC::IO_AsciiParticles-END_EVENT_LISTING\n"
00025 // Comments are allowed. They need not be preceded by anything, though if
00026 //  a comment is written using write_comment( const string ) then it will be
00027 //  preceded by "HepMC::IO_AsciiParticles-COMMENT\n"
00028 // Each event, vertex, particle, particle data is preceded by 
00029 //  "E ","V ","P ","D "    respectively.
00030 // Comments may appear anywhere in the file -- so long as they do not contain
00031 //  any of the 4 start/stop keys.
00032 //
00033 
00034 #include <fstream>
00035 #include <string>
00036 #include <map>
00037 #include <vector>
00038 #include "HepMC/IO_BaseClass.h"
00039 
00040 namespace HepMC {
00041 
00042     class GenEvent;
00043     class GenVertex;
00044     class GenParticle;
00045 
00047 
00054     class IO_AsciiParticles : public IO_BaseClass {
00055     public:
00057         IO_AsciiParticles( const char* filename="IO_AsciiParticles.dat", 
00058                   std::ios::openmode mode=std::ios::out );
00059         virtual       ~IO_AsciiParticles();
00060 
00062         void          write_event( const GenEvent* evt );
00064         bool          fill_next_event( GenEvent* evt );
00065     inline void          write_particle_data_table(const ParticleDataTable*);
00066     inline bool          fill_particle_data_table( ParticleDataTable* );
00070         void          write_comment( const std::string comment );
00071 
00073         void          setPrecision(int iprec);
00074 
00075         int           rdstate() const;  
00076         void          clear();  
00077 
00079         void          print( std::ostream& ostr = std::cout ) const;
00080 
00081     protected: // for internal use only
00083         bool          write_end_listing();
00084     private: // use of copy constructor is not allowed
00085         IO_AsciiParticles( const IO_AsciiParticles& ) : IO_BaseClass() {}
00086     private: // data members
00087     int                 m_precision;
00088         std::ios::openmode  m_mode;
00089         std::fstream*       m_file;
00090     std::ostream*       m_outstream;
00091         bool                m_finished_first_event_io;
00092     };
00093 
00095     // Inlines  //
00097 
00098     inline int  IO_AsciiParticles::rdstate() const { return (int)m_file->rdstate(); }
00099     inline void IO_AsciiParticles::clear() { m_file->clear(); }
00100     inline void IO_AsciiParticles::setPrecision(int iprec) { m_precision=iprec; }
00101 
00103     // Inline dummies  //
00105 
00106   void IO_AsciiParticles::write_particle_data_table(const ParticleDataTable*) {;}
00107   bool IO_AsciiParticles::fill_particle_data_table( ParticleDataTable* ) {return false;}
00108 
00109 } // HepMC
00110 
00111 #endif  // HEPMC_IO_ASCIIPARTICLES_H
00112 //--------------------------------------------------------------------------
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:56:42 2011 for HepMC by doxygen 1.4.7