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 |
|
---|
14 | class MCorsikaFormat
|
---|
15 | {
|
---|
16 | protected:
|
---|
17 | std::istream *fIn;
|
---|
18 |
|
---|
19 | std::streampos fPrevPos; // file position before previous read
|
---|
20 | std::streampos fPos;
|
---|
21 |
|
---|
22 | public:
|
---|
23 | static const unsigned int kSyncMarker;
|
---|
24 |
|
---|
25 | MCorsikaFormat(std::istream * in)
|
---|
26 | : fIn(in) { }
|
---|
27 | virtual ~MCorsikaFormat();
|
---|
28 |
|
---|
29 | virtual Int_t SeekNextBlock(const char * id, unsigned short type) const = 0;
|
---|
30 | virtual void UnreadLastHeader() const = 0;
|
---|
31 |
|
---|
32 | virtual Bool_t ReadData(Int_t numValues, Float_t * buffer,
|
---|
33 | Int_t minSeekValues = 272);
|
---|
34 | virtual void UnreadLastData() const;
|
---|
35 |
|
---|
36 | virtual Bool_t SeekEvtEnd() = 0;
|
---|
37 | virtual void StorePos();
|
---|
38 | virtual void ResetPos() const;
|
---|
39 | virtual void Rewind() const;
|
---|
40 |
|
---|
41 | virtual Int_t GetNextEvent(Float_t **buffer, Int_t tel=0) = 0;
|
---|
42 | virtual Bool_t IsEventioFormat() const = 0;
|
---|
43 |
|
---|
44 | virtual Bool_t Eof() const;
|
---|
45 |
|
---|
46 | std::streampos GetCurrPos() const;
|
---|
47 |
|
---|
48 | void Read(void *ptr, Int_t i=4) const;
|
---|
49 |
|
---|
50 | static MCorsikaFormat *CorsikaFormatFactory(const char *fileName);
|
---|
51 | };
|
---|
52 |
|
---|
53 |
|
---|
54 | class MCorsikaFormatRaw : public MCorsikaFormat
|
---|
55 | {
|
---|
56 | private:
|
---|
57 |
|
---|
58 | public:
|
---|
59 | MCorsikaFormatRaw(std::istream * in)
|
---|
60 | : MCorsikaFormat(in) {}
|
---|
61 |
|
---|
62 | Int_t SeekNextBlock(const char * id, unsigned short type) const;
|
---|
63 | void UnreadLastHeader() const;
|
---|
64 |
|
---|
65 | Bool_t SeekEvtEnd();
|
---|
66 |
|
---|
67 | Int_t GetNextEvent(Float_t **buffer, Int_t);
|
---|
68 | Bool_t IsEventioFormat() const {return kFALSE;}
|
---|
69 | };
|
---|
70 |
|
---|
71 |
|
---|
72 | class MCorsikaFormatEventIO : public MCorsikaFormat
|
---|
73 | {
|
---|
74 | private:
|
---|
75 | std::streampos fRunePos; // file position of the RUNE block
|
---|
76 |
|
---|
77 | public:
|
---|
78 | MCorsikaFormatEventIO(std::istream *in)
|
---|
79 | : MCorsikaFormat(in) {fRunePos = std::streampos(0);}
|
---|
80 |
|
---|
81 | Int_t SeekNextBlock(const char *id, unsigned short type) const;
|
---|
82 | void UnreadLastHeader() const;
|
---|
83 |
|
---|
84 | Bool_t SeekEvtEnd();
|
---|
85 |
|
---|
86 | Int_t GetNextEvent(Float_t **buffer, Int_t tel);
|
---|
87 | Bool_t IsEventioFormat() const { return kTRUE; }
|
---|
88 |
|
---|
89 | private:
|
---|
90 | Int_t NextEventObject(Int_t &length) const;
|
---|
91 | Int_t NextPhotonObject(Int_t &length) const;
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif
|
---|
95 |
|
---|