1 #include <io/RawCorsikaFile.h>
2 #include <io/CorsikaBlock.h>
3 #include <io/CorsikaIOException.h>
4 #include <utl/ErrorLogger.h>
12 using namespace io::Corsika;
15 RawFile::RawFile(
const std::string& name) :
16 fDiskStream(name.c_str())
19 const string msg =
"Error opening Corsika file '" + name +
"'.";
31 const string msg =
"Cannot open Corsika file '" + name +
32 "' - *this is already open";
43 const string msg =
"Error opening Corsika file '" + name +
"'.";
54 bool foundRUNH =
false;
55 unsigned int posRUNH = 0;
57 const unsigned int toRead = 20;
58 char buff[toRead] = {
'\0' };
60 for ( ; posRUNH+3 < toRead; ++posRUNH) {
61 if (buff[posRUNH+0] ==
'R' &&
62 buff[posRUNH+1] ==
'U' &&
63 buff[posRUNH+2] ==
'N' &&
64 buff[posRUNH+3] ==
'H') {
99 const bool thinned =
true;
118 const bool thinned =
false;
151 char*
const buff = thinned ?
PositionType fCurrentBlockNumber
static const unsigned int kBlocksInDiskBlock
Padding bytes at the beginning of a raw block.
void Close()
Close file (no-op for closed file).
ThinnedDiskBlock fDiskThinnBlockBuffer
BlockUnthinned fBlock[kBlocksInDiskBlock]
initial padding - works also for size 0
bool GetNextBlock(Block &block)
Read one block and advance.
unsigned int fIndexInDiskBlock
bool IsOpen() const
Check if the file is open.
Block fBlock[kBlocksInDiskBlock]
initial padding - works also for size 0
Base for exceptions in the CORSIKA reader.
bool GetNextBlockUnthinned(BlockUnthinned &block)
Read one block and advance.
void SeekTo(const PositionType position, const bool reset=false)
Seek to a given block, the next block will be thePosition.
std::ifstream fDiskStream
bool ReadDiskBlock(const bool thinned)
Read the block at the current position from disk.
PositionType GetNextPosition() const
Number of the block read by the next call to GetNextBlock.
bool Open(const std::string &name, const bool noException=false)
#define ERROR(message)
Macro for logging error messages.
UnthinnedDiskBlock fDiskUnthinnBlockBuffer
unsigned long int PositionType