#ifndef _io_SenecaFileParser_h_ #define _io_SenecaFileParser_h_ #include #include #include using namespace std; namespace io { enum SenecaHadronicSim { eSenecaUnknown = 0, eSenecaQGS98 = 1, eSenecaQGS01 = 2, eSenecaSib21 = 3, eSenecaNex2 = 4, eSenecaNex397 = 5 }; enum SenecaEMSim { eSenecaGheisha = 1, eSenecaGFluka = 2, eSenecaGCalor = 3, eSenecaURQMD = 4 }; struct SenecaParticleRecord { int ID; float Weight; float X; float Y; float T; float Px; float Py; float Pz; }; struct SenecaHeaderRecord { int ID; float SenecaVersion; unsigned char EMSim; unsigned char HadronicSim; float HObs; int ILowHadr; int IOHadr; int IVersion; float HINJ; float HGround; float HCore; }; struct SenecaEventHeaderRecord { int ID; float E0; float Theta; float Phi; int ID0; }; /** \class SenecaFileParser \brief \author Jeff Allen \date 8 Sep 2006 \ingroup seneca */ class SenecaFileParser { public: SenecaFileParser(const std::string& FileName, const Mode mode = eRead); SenecaFileParser(); ~SenecaFileParser(); Status OpenSenecaFile(const std::string& FileName, Mode mode = eRead); void CloseSenecaFile(); unsigned int GetCurrentPosition(); Status ProcessFile(); SenecaHeaderRecord* GetFileHeader(); SenecaEventHeaderRecord* GetCurrentEventHeader(); SenecaParticleRecord* GetParticleRecord(); Status GotoPosition(unsigned int thePosition); unsigned int GetPosition(); Status GotoEvent(unsigned int theEventNumber); Status GetNextEvent(); Status ReadParticle(); unsigned int GetNumberEvents(); unsigned int GetCurrentEvent(); Status FileStatus(); bool FileHeaderValid; bool EventHeaderValid; bool ParticleRecordValid; private: Status DecodeFileHeader(unsigned char* Record); Status DecodeEventHeader(unsigned char* Record); Status DecodeParticleRecord(unsigned char* Record); int SenecaDecodeInt(unsigned char* Buffer); float SenecaDecodeFloat(unsigned char* Buffer); std::ifstream SenecaFile; string SenecaFileName; //std::ofstream DebugFile; unsigned long EventPositions[1024]; SenecaEventHeaderRecord EventHeader; SenecaHeaderRecord FileHeader; SenecaParticleRecord ParticleRecord; bool FileOpen; unsigned int NumberEvents; unsigned int CurrentEvent, NextEvent; unsigned int FileSize; unsigned long CurrentPosition; unsigned int FirstEvent; }; } //io namespace #endif //io_SenecaFileParser_h_