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