source: trunk/Mars/mcorsika/MCorsikaFormat.h@ 19342

Last change on this file since 19342 was 19330, checked in by tbretz, 6 years ago
Moved magic numbers to an enum, changed hasMagicNumber into the block length (273 floats for raw data and 312 data for THIN data)
File size: 2.0 KB
Line 
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
15class MCorsikaFormat
16{
17protected:
18 std::istream *fIn;
19
20public:
21 enum
22 {
23 kBlockLengthRaw = 0x00005994, // Raw Corsika without Thinning
24 kBlockLengthThin = 0x00006660, // Raw Corsika with Thinning
25
26 kSyncMarker = 0xd41f8a37, // EventIO
27
28 kRUNH = 0x484e5552, // "RUNH"
29 kRUNE = 0x454e5552, // "RUNE"
30 kEVTH = 0x48545645, // "EVTH"
31 kEVTE = 0x45545645, // "EVTE"
32 };
33
34 MCorsikaFormat(std::istream * in)
35 : fIn(in) { }
36 virtual ~MCorsikaFormat();
37
38 virtual Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
39 Int_t & blockIdentifier, Int_t & blockLength) const = 0;
40
41 void Seek(std::streampos offset) {fIn->seekg(offset, std::ios::cur);}
42
43 virtual Bool_t SeekEvtEnd() = 0;
44
45 virtual Bool_t IsEventioFormat() const = 0;
46
47 virtual Bool_t Eof() const;
48
49 Bool_t Read(void *ptr, Int_t i) const;
50
51 static MCorsikaFormat *CorsikaFormatFactory(const char *fileName);
52};
53
54
55class MCorsikaFormatRaw : public MCorsikaFormat
56{
57private:
58 uint32_t fBlockLength;
59
60public:
61 MCorsikaFormatRaw(std::istream * in, const uint32_t &bl)
62 : MCorsikaFormat(in), fBlockLength(bl) {}
63
64 Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
65 Int_t & blockIdentifier, Int_t & blockLength) const;
66
67 Bool_t SeekEvtEnd();
68
69 Bool_t IsEventioFormat() const {return kFALSE;}
70};
71
72
73class MCorsikaFormatEventIO : public MCorsikaFormat
74{
75
76public:
77 MCorsikaFormatEventIO(std::istream *in)
78 : MCorsikaFormat(in) {}
79
80
81 Bool_t NextBlock(Int_t readState, Int_t & blockType, Int_t & blockVersion,
82 Int_t & blockIdentifier, Int_t & blockLength) const;
83
84 Bool_t SeekEvtEnd();
85
86 Bool_t IsEventioFormat() const { return kTRUE; }
87
88};
89
90#endif
91
Note: See TracBrowser for help on using the repository browser.