source: trunk/Mars/mcorsika/MCorsikaFormat.h

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