23#include "iThembaDataVersion.h"
74 }
catch(std::exception& e) {
75 std::cout<<
"Caught "<<e.what()<<std::endl;
92 std::cout<<
"Successfully opened file with "<<
fFileSize<<
" bytes!"<<std::endl;
124 std::cout<<
"Failed to read next 64k buffer, currently at "<<
fBytesRead<<
"/"<<
fFileSize<<std::endl;
129 if(strncmp(
fReadBuffer.data(),
"EBYEDATA", 8) != 0) {
130 std::cerr<<
fBytesRead<<
": Failed to find 'EBYEDATA' (or 0x45 42 59 45 44 41 54 41) at beginning of header (0x"<<std::hex<<std::setfill('0')<<std::setw(8)<<*reinterpret_cast<uint64_t*>(
fReadBuffer.data())<<std::hex<<std::setfill(
' ')<<
")"<<std::endl;
134 std::static_pointer_cast<TTdrEvent>(tdrEvent)->SetHeader(
fReadBuffer.data());
135 }
catch(std::exception& e) {
136 std::cout<<e.what()<<std::endl;
138 uint32_t dataSize = std::static_pointer_cast<TTdrEvent>(tdrEvent)->GetHeader().fDataLength;
139 if(24 + dataSize < 0x10000) {
141 std::static_pointer_cast<TTdrEvent>(tdrEvent)->SetData(std::vector<char>(
fReadBuffer.begin() + 24,
fReadBuffer.begin() + 24 + dataSize));
142 }
catch(std::exception& e) {
143 std::cout<<e.what()<<std::endl;
157 std::cerr<<__PRETTY_FUNCTION__<<
": input file is not open!"<<std::endl;
161 fInputFile.seekg(nofEvents * 0x10000, std::ifstream::cur);
163 std::cout<<
"Failed to skip next "<<nofEvents<<
" 64k buffer(s), currently at "<<
fBytesRead<<
"/"<<
fFileSize<<std::endl;
175 std::size_t foundslash =
fFilename.rfind(
'/');
176 std::size_t found =
fFilename.rfind(
'R');
177 if(found < foundslash || found ==std::string::npos) {
178 std::cout<<
"Warning, failed to find 'R' in filename '"<<
fFilename<<
"'!"<<std::endl;
181 std::size_t found2 =
fFilename.rfind(
'-');
182 if((found2 < foundslash && foundslash != std::string::npos) || found2 == std::string::npos) {
186 if(found2 < foundslash && foundslash != std::string::npos) {
187 found2 = std::string::npos;
190 if(found2 == std::string::npos) {
195 temp =
fFilename.substr(found + 1, found2 - (found + 1));
197 return atoi(temp.c_str());
207 std::size_t foundslash =
fFilename.rfind(
'/');
208 std::size_t found =
fFilename.rfind(
'-');
209 if((found < foundslash && foundslash != std::string::npos) || found == std::string::npos) {
212 if(found < foundslash && foundslash != std::string::npos) {
213 found = std::string::npos;
215 if(found != std::string::npos) {
216 std::string temp =
fFilename.substr(found + 1);
217 return atoi(temp.c_str());
ClassImp(THILMnemonic) void THILMnemonic
static void SetMnemonicClass(const TClassRef &cls)
virtual const char * GetFilename() const
Get the name of this file.
std::vector< char > fReadBuffer
std::string fFilename
name of the currently open file
static void ClearVersion()
static void SetRunInfo(int runnum=0, int subrunnum=-1)
static void SetVersion(const char *ver)
static void SetDetectorInformation(TDetectorInformation *inf)
Reader for MIDAS .mid files.
int Read(std::shared_ptr< TRawEvent > lstEvent) override
Read one event from the file.
void Close() override
Close input file.
std::string Status(bool long_file_description=true) override
bool Open(const char *filename) override
Open input file.
TTdrFile()
default constructor
int GetRunNumber() override
int GetSubRunNumber() override
void Skip(size_t nofEvents) override
Skip nofEvents from the file.
~TTdrFile() override
destructor