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

Last change on this file since 18534 was 18532, checked in by tbretz, 8 years ago
Implemented handling of the magic number at the beginning of the file and skipping it at the end when searching for the RUNE section. Return kFALSE if RUNE has not been found.
File size: 1.7 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 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
45class MCorsikaFormatRaw : public MCorsikaFormat
46{
47private:
48 bool fHasMagicNumber;
49
50public:
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
63class MCorsikaFormatEventIO : public MCorsikaFormat
64{
65
66public:
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
Note: See TracBrowser for help on using the repository browser.