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 Bool_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 |
|
---|
40 | virtual Int_t GetNextEvent(Float_t **buffer, UInt_t tel=0) = 0;
|
---|
41 | virtual Bool_t IsEventioFormat() const = 0;
|
---|
42 |
|
---|
43 | virtual Bool_t Eof() const;
|
---|
44 |
|
---|
45 | std::streampos GetCurrPos() const;
|
---|
46 |
|
---|
47 | static MCorsikaFormat *CorsikaFormatFactory(const char *fileName);
|
---|
48 | };
|
---|
49 |
|
---|
50 |
|
---|
51 | class MCorsikaFormatRaw : public MCorsikaFormat
|
---|
52 | {
|
---|
53 | private:
|
---|
54 |
|
---|
55 | public:
|
---|
56 | MCorsikaFormatRaw(std::istream * in)
|
---|
57 | : MCorsikaFormat(in) {}
|
---|
58 |
|
---|
59 | Bool_t SeekNextBlock(const char * id, unsigned short type) const;
|
---|
60 | void UnreadLastHeader() const;
|
---|
61 |
|
---|
62 | Bool_t SeekEvtEnd();
|
---|
63 |
|
---|
64 | Int_t GetNextEvent(Float_t **buffer, UInt_t);
|
---|
65 | Bool_t IsEventioFormat() const {return kFALSE;}
|
---|
66 | };
|
---|
67 |
|
---|
68 |
|
---|
69 | class MCorsikaFormatEventIO : public MCorsikaFormat
|
---|
70 | {
|
---|
71 | private:
|
---|
72 | std::streampos fRunePos; // file position of the RUNE block
|
---|
73 |
|
---|
74 | public:
|
---|
75 | MCorsikaFormatEventIO(std::istream *in)
|
---|
76 | : MCorsikaFormat(in) {fRunePos = std::streampos(0);}
|
---|
77 |
|
---|
78 | Bool_t SeekNextBlock(const char *id, unsigned short type) const;
|
---|
79 | void UnreadLastHeader() const;
|
---|
80 |
|
---|
81 | Bool_t SeekEvtEnd();
|
---|
82 |
|
---|
83 | Int_t GetNextEvent(Float_t **buffer, UInt_t tel);
|
---|
84 | Bool_t IsEventioFormat() const { return kTRUE; }
|
---|
85 |
|
---|
86 | private:
|
---|
87 | Int_t NextEventObject(Int_t &length) const;
|
---|
88 | Int_t NextPhotonObject(Int_t &length) const;
|
---|
89 | };
|
---|
90 |
|
---|
91 | #endif
|
---|
92 |
|
---|