| 1 | #ifndef MARS_MDataFormat
|
|---|
| 2 | #define MARS_MDataFormat
|
|---|
| 3 |
|
|---|
| 4 | #include <iostream>
|
|---|
| 5 |
|
|---|
| 6 | #ifndef MARS_MAGIC
|
|---|
| 7 | #include "MAGIC.h"
|
|---|
| 8 | #endif
|
|---|
| 9 |
|
|---|
| 10 | #ifndef ROOT_Rtypes
|
|---|
| 11 | #include <Rtypes.h>
|
|---|
| 12 | #endif
|
|---|
| 13 |
|
|---|
| 14 | #include <iosfwd>
|
|---|
| 15 | #include <fstream>
|
|---|
| 16 |
|
|---|
| 17 | class MCorsikaFormat
|
|---|
| 18 | {
|
|---|
| 19 | protected:
|
|---|
| 20 | std::istream *fIn;
|
|---|
| 21 |
|
|---|
| 22 | public:
|
|---|
| 23 | static const unsigned int kSyncMarker;
|
|---|
| 24 |
|
|---|
| 25 | MCorsikaFormat(std::istream * in)
|
|---|
| 26 | : fIn(in) { }
|
|---|
| 27 | virtual ~MCorsikaFormat();
|
|---|
| 28 |
|
|---|
| 29 | virtual Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
|
|---|
| 30 | Int_t & blockIdentifier, Int_t & blockLength) const = 0;
|
|---|
| 31 |
|
|---|
| 32 | void Seek(std::streampos offset) {fIn->seekg(offset, std::ios::cur);}
|
|---|
| 33 |
|
|---|
| 34 | virtual Bool_t SeekEvtEnd() = 0;
|
|---|
| 35 |
|
|---|
| 36 | virtual Bool_t IsEventioFormat() const = 0;
|
|---|
| 37 |
|
|---|
| 38 | virtual Bool_t Eof() const;
|
|---|
| 39 |
|
|---|
| 40 | Bool_t Read(void *ptr, Int_t i) const;
|
|---|
| 41 |
|
|---|
| 42 | static MCorsikaFormat *CorsikaFormatFactory(const char *fileName);
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | class MCorsikaFormatRaw : public MCorsikaFormat
|
|---|
| 47 | {
|
|---|
| 48 | private:
|
|---|
| 49 | Bool_t fFortranRaw;
|
|---|
| 50 | public:
|
|---|
| 51 | //MCorsikaFormatRaw(std::istream * in)
|
|---|
| 52 | // : MCorsikaFormat(in) {}
|
|---|
| 53 |
|
|---|
| 54 | MCorsikaFormatRaw(std::istream* in, Bool_t fortranRaw = false)
|
|---|
| 55 | : MCorsikaFormat(in), fFortranRaw(fortranRaw) {}//std::cout << "\n\n||||||||||||||||||||||||||||" << fortranRaw << std::endl;}
|
|---|
| 56 |
|
|---|
| 57 | Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
|
|---|
| 58 | Int_t & blockIdentifier, Int_t & blockLength) const;
|
|---|
| 59 |
|
|---|
| 60 | Bool_t SeekEvtEnd();
|
|---|
| 61 |
|
|---|
| 62 | Bool_t IsEventioFormat() const {return kFALSE;}
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | class MCorsikaFormatEventIO : public MCorsikaFormat
|
|---|
| 67 | {
|
|---|
| 68 |
|
|---|
| 69 | public:
|
|---|
| 70 | MCorsikaFormatEventIO(std::istream *in)
|
|---|
| 71 | : MCorsikaFormat(in) {}
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
|
|---|
| 75 | Int_t & blockIdentifier, Int_t & blockLength) const;
|
|---|
| 76 |
|
|---|
| 77 | Bool_t SeekEvtEnd();
|
|---|
| 78 |
|
|---|
| 79 | Bool_t IsEventioFormat() const { return kTRUE; }
|
|---|
| 80 |
|
|---|
| 81 | };
|
|---|
| 82 |
|
|---|
| 83 | #endif
|
|---|
| 84 |
|
|---|