Reader for MIDAS .mid files.
This Class is used to read and write MIDAS files in the root framework. It reads and writes TMidasEvents.
Definition at line 32 of file TMidasFile.h.
Public Types | |
enum | EOpenType { EOpenType::kRead, EOpenType::kWrite } |
Public Member Functions | |
TMidasFile () | |
TMidasFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead) | |
~TMidasFile () override | |
void | Close () override |
void | FillBuffer (const std::shared_ptr< TMidasEvent > &midasEvent, Option_t *opt="") |
virtual size_t | GetBytesRead () |
const char * | GetFilename () const override |
virtual size_t | GetFileSize () |
int | GetLastErrno () const |
const char * | GetLastError () const |
std::shared_ptr< TRawEvent > | GetOdbEvent () override |
int | GetRunNumber () override |
int | GetSubRunNumber () override |
std::shared_ptr< TRawEvent > | NewEvent () override |
bool | Open (const char *filename) override |
void | OutClose () |
bool | OutOpen (const char *filename) |
int | Read (std::shared_ptr< TRawEvent > event) override |
void | SetMaxBufferSize (int maxsize) |
void | Skip (size_t nofEvents) override |
std::string | Status (bool long_file_description=true) override |
bool | Write (const std::shared_ptr< TMidasEvent > &midasEvent, Option_t *opt="") |
bool | WriteBuffer () |
Protected Attributes | |
size_t | fBytesRead {0} |
std::string | fFilename |
size_t | fFileSize {0} |
std::vector< char > | fReadBuffer |
Private Member Functions | |
void | ReadMoreBytes (size_t bytes) |
void | SetEPICSOdb () |
void | SetFileOdb () |
void | SetGRIFFOdb () |
void | SetRunInfo (uint32_t time) |
void | SetTIGDAQOdb () |
void | SetTIGOdb () |
Private Attributes | |
uint32_t | fCurrentBufferSize |
int | fCurrentEventNumber |
bool | fDoByteSwap |
int | fFile |
void * | fGzFile |
int | fLastErrno |
std::string | fLastError |
uint32_t | fMaxBufferSize |
TXMLOdb * | fOdb |
std::shared_ptr< TMidasEvent > | fOdbEvent |
int | fOutFile |
std::string | fOutFilename |
void * | fOutGzFile |
void * | fPoFile |
std::vector< char > | fWriteBuffer |
#include <TMidasFile.h>
|
stronginherited |
Enumerator | |
---|---|
kRead | |
kWrite |
Definition at line 33 of file TRawFile.h.
TMidasFile::TMidasFile | ( | ) |
default constructor
Definition at line 29 of file TMidasFile.cxx.
TMidasFile::TMidasFile | ( | const char * | filename, |
TRawFile::EOpenType | open_type = TRawFile::EOpenType::kRead |
||
) |
Definition at line 63 of file TMidasFile.cxx.
References TRawFile::kRead, TRawFile::kWrite, Open(), and OutOpen().
|
override |
|
overridevirtual |
Close input file.
Implements TRawFile.
Definition at line 567 of file TMidasFile.cxx.
References fFile, TRawFile::fFilename, fGzFile, and fPoFile.
Referenced by Open(), and ~TMidasFile().
void TMidasFile::FillBuffer | ( | const std::shared_ptr< TMidasEvent > & | midasEvent, |
Option_t * | opt = "" |
||
) |
Definition at line 458 of file TMidasFile.cxx.
References fCurrentBufferSize, fMaxBufferSize, fWriteBuffer, and WriteBuffer().
Referenced by ProcessEvent(), Write(), and WriteEvents().
|
inlinevirtualinherited |
Definition at line 56 of file TRawFile.h.
References TRawFile::fBytesRead.
Referenced by TDataLoop::Iteration().
|
inlineoverridevirtual |
Get the name of this file.
Reimplemented from TRawFile.
Definition at line 61 of file TMidasFile.h.
References TRawFile::fFilename.
Referenced by Open(), and WriteEvents().
|
inlinevirtualinherited |
Definition at line 57 of file TRawFile.h.
References TRawFile::fFileSize.
Referenced by TDataLoop::Iteration().
|
inline |
Get error value for the last file error.
Definition at line 62 of file TMidasFile.h.
References fLastErrno.
Referenced by WriteEvents().
|
inline |
Get error text for the last file error.
Definition at line 63 of file TMidasFile.h.
References fLastError.
Referenced by WriteEvents().
|
inlineoverridevirtual |
Reimplemented from TRawFile.
Definition at line 66 of file TMidasFile.h.
References fOdbEvent.
Referenced by ExamineMidasFile().
|
overridevirtual |
Implements TRawFile.
Definition at line 608 of file TMidasFile.cxx.
References TRawFile::fFilename.
Referenced by Open().
|
overridevirtual |
Implements TRawFile.
Definition at line 636 of file TMidasFile.cxx.
References TRawFile::fFilename.
Referenced by Open(), and QueueEvents().
|
inlineoverridevirtual |
Implements TRawFile.
Definition at line 75 of file TMidasFile.h.
|
overridevirtual |
Open input file.
Open a midas .mid file with given file name.
Remote files can be accessed using these special file names:
Examples:
[in] | filename | The file to open. |
Implements TRawFile.
Definition at line 116 of file TMidasFile.cxx.
References TRunInfo::ClearLibraryVersion(), Close(), fFile, TRawFile::fFilename, TRawFile::fFileSize, fGzFile, fLastErrno, fLastError, fOdbEvent, fPoFile, GetFilename(), GetRunNumber(), GetSubRunNumber(), GRSIDATA_RELEASE, hasSuffix(), O_LARGEFILE, Read(), s, TRunInfo::SetDetectorInformation(), SetFileOdb(), TRunInfo::SetLibraryVersion(), TChannel::SetMnemonicClass(), and TRunInfo::SetRunInfo().
Referenced by ExamineMidasFile(), main(), and TMidasFile().
void TMidasFile::OutClose | ( | ) |
Close output file.
Definition at line 587 of file TMidasFile.cxx.
References fOutFile, fOutFilename, fOutGzFile, fWriteBuffer, and WriteBuffer().
Referenced by OutOpen(), and ~TMidasFile().
bool TMidasFile::OutOpen | ( | const char * | filename | ) |
Open output file.
Open a midas .mid file for OUTPUT with given file name.
Remote files not yet implemented
[in] | filename | The file to open. |
Definition at line 250 of file TMidasFile.cxx.
References fLastErrno, fLastError, fOutFile, fOutFilename, fOutGzFile, hasSuffix(), O_LARGEFILE, and OutClose().
Referenced by TMidasFile().
|
overridevirtual |
Read one event from the file.
[in] | event | shared Pointer to an empty TMidasEvent |
EDITED FROM THE ORIGINAL TO RETURN TOTAL SUCESSFULLY BYTES READ INSTEAD OF TRUE/FALSE, PCB
Implements TRawFile.
Definition at line 330 of file TMidasFile.cxx.
References TRawFile::fBytesRead, fCurrentEventNumber, fDoByteSwap, fLastErrno, fLastError, TRawFile::fReadBuffer, and ReadMoreBytes().
Referenced by ExamineMidasFile(), Open(), QueueEvents(), and WriteEvents().
|
private |
Definition at line 432 of file TMidasFile.cxx.
References fFile, fGzFile, fLastErrno, fLastError, TRawFile::fReadBuffer, and readpipe().
|
private |
Definition at line 744 of file TMidasFile.cxx.
References TXMLOdb::FindPath(), fOdb, TXMLOdb::ReadStringArray(), and TEpicsFrag::SetEpicsNameList().
Referenced by SetFileOdb().
|
private |
Definition at line 658 of file TMidasFile.cxx.
References TChannel::DeleteAllChannels(), DYELLOW, TXMLOdb::FindPath(), fOdb, fOdbEvent, TGRSIOptions::Get(), TXMLOdb::GetNodeName(), RED, RESET_COLOR, SetEPICSOdb(), SetGRIFFOdb(), SetRunInfo(), SetTIGDAQOdb(), and SetTIGOdb().
Referenced by Open().
|
private |
Definition at line 753 of file TMidasFile.cxx.
References TChannel::AddChannel(), TChannel::AddENGCoefficient(), BG_WHITE, DRED, TXMLOdb::FindPath(), fOdb, TSingleton< TPPG >::Get(), TChannel::GetChannel(), TChannel::GetNumberOfChannels(), kRootFile, TXMLOdb::ReadDoubleArray(), TXMLOdb::ReadIntArray(), TXMLOdb::ReadStringArray(), RESET_COLOR, TChannel::SetAddress(), TChannel::SetDigitizerType(), TChannel::SetName(), TChannel::SetNumber(), TPPG::SetOdbCycle(), and TChannel::SetUserInfoNumber().
Referenced by SetFileOdb().
void TMidasFile::SetMaxBufferSize | ( | int | maxsize | ) |
Definition at line 560 of file TMidasFile.cxx.
References fMaxBufferSize.
|
private |
Definition at line 715 of file TMidasFile.cxx.
References DBLUE, TXMLOdb::FindPath(), fOdb, TSingleton< TRunInfo >::Get(), RESET_COLOR, TRunInfo::SetRunComment(), TRunInfo::SetRunStart(), TRunInfo::SetRunTitle(), and TRunInfo::SubRunNumber().
Referenced by SetFileOdb().
|
private |
Definition at line 1007 of file TMidasFile.cxx.
References TChannel::AddENGCoefficient(), BG_WHITE, DRED, TXMLOdb::FindPath(), fOdb, TChannel::GetChannel(), TChannel::GetNumberOfChannels(), kRootFile, TXMLOdb::ReadDoubleArray(), TXMLOdb::ReadIntArray(), TXMLOdb::ReadStringArray(), RESET_COLOR, TChannel::SetAddress(), TChannel::SetName(), TChannel::SetNumber(), and TChannel::SetUserInfoNumber().
Referenced by SetFileOdb().
|
private |
Definition at line 896 of file TMidasFile.cxx.
References TChannel::AddChannel(), TChannel::AddENGCoefficient(), BG_WHITE, DRED, TXMLOdb::FindPath(), fOdb, TChannel::GetChannel(), TChannel::GetDigitizerTypeString(), TXMLOdb::GetNodeName(), TChannel::GetNumberOfChannels(), kRootFile, TXMLOdb::ReadDoubleArray(), TXMLOdb::ReadIntArray(), TXMLOdb::ReadStringArray(), RESET_COLOR, TChannel::SetAddress(), TChannel::SetDigitizerType(), TChannel::SetIntegration(), TChannel::SetName(), TChannel::SetNumber(), and TChannel::SetUserInfoNumber().
Referenced by SetFileOdb().
|
overridevirtual |
Skip nofEvents from the file.
Implements TRawFile.
Definition at line 378 of file TMidasFile.cxx.
References TMidasEvent::Clear(), TRawFile::fBytesRead, fCurrentEventNumber, fDoByteSwap, TMidas_EVENT_HEADER::fEventId, fLastErrno, fLastError, TRawFile::fReadBuffer, TMidasEvent::GetDataSize(), TMidasEvent::GetEventHeader(), TMidasEvent::IsGoodSize(), ReadMoreBytes(), and TMidasEvent::SwapBytesEventHeader().
|
overridevirtual |
Implements TRawFile.
Definition at line 78 of file TMidasFile.cxx.
References TRawFile::fBytesRead, fCurrentEventNumber, TRawFile::fFileSize, HIDE_CURSOR, and SHOW_CURSOR.
bool TMidasFile::Write | ( | const std::shared_ptr< TMidasEvent > & | midasEvent, |
Option_t * | opt = "" |
||
) |
Write one event to the output file.
Definition at line 518 of file TMidasFile.cxx.
References fOutFile, and fOutGzFile.
Referenced by ProcessEvent().
bool TMidasFile::WriteBuffer | ( | ) |
Definition at line 498 of file TMidasFile.cxx.
References fCurrentBufferSize, fOutFile, fOutGzFile, and fWriteBuffer.
Referenced by FillBuffer(), OutClose(), and WriteEvents().
|
protectedinherited |
Definition at line 69 of file TRawFile.h.
Referenced by TRlmdFile::Close(), TRawFile::GetBytesRead(), TRlmdFile::Open(), TLstFile::Read(), TTdrFile::Read(), Read(), TRlmdFile::Read(), TTdrFile::Skip(), Skip(), TLstFile::Status(), TTdrFile::Status(), and Status().
|
private |
Definition at line 99 of file TMidasFile.h.
Referenced by FillBuffer(), and WriteBuffer().
|
private |
Definition at line 104 of file TMidasFile.h.
|
private |
"true" if file has to be byteswapped
Definition at line 106 of file TMidasFile.h.
|
private |
open input file descriptor
Definition at line 108 of file TMidasFile.h.
Referenced by Close(), Open(), and ReadMoreBytes().
|
protectedinherited |
name of the currently open file
Definition at line 65 of file TRawFile.h.
Referenced by Close(), TRawFile::GetFilename(), GetFilename(), TLstFile::GetRunNumber(), TTdrFile::GetRunNumber(), GetRunNumber(), TRlmdFile::GetRunNumber(), TTdrFile::GetSubRunNumber(), GetSubRunNumber(), TLstFile::Open(), TTdrFile::Open(), Open(), and TRlmdFile::Open().
|
protectedinherited |
Definition at line 70 of file TRawFile.h.
Referenced by TRlmdFile::Close(), TRawFile::GetFileSize(), TLstFile::Open(), Open(), TTdrFile::Open(), TRlmdFile::Open(), TLstFile::Read(), TTdrFile::Read(), TRlmdFile::Read(), TTdrFile::Skip(), TLstFile::Status(), TTdrFile::Status(), Status(), and TRlmdFile::Status().
|
private |
zlib compressed input file reader
Definition at line 109 of file TMidasFile.h.
Referenced by Close(), Open(), and ReadMoreBytes().
|
private |
errno from the last operation
Definition at line 102 of file TMidasFile.h.
Referenced by GetLastErrno(), Open(), OutOpen(), Read(), ReadMoreBytes(), and Skip().
|
private |
error string from last errno
Definition at line 103 of file TMidasFile.h.
Referenced by GetLastError(), Open(), OutOpen(), Read(), ReadMoreBytes(), and Skip().
|
private |
Definition at line 100 of file TMidasFile.h.
Referenced by FillBuffer(), and SetMaxBufferSize().
|
private |
Definition at line 89 of file TMidasFile.h.
Referenced by SetEPICSOdb(), SetFileOdb(), SetGRIFFOdb(), SetRunInfo(), SetTIGDAQOdb(), and SetTIGOdb().
|
private |
Definition at line 93 of file TMidasFile.h.
Referenced by GetOdbEvent(), Open(), and SetFileOdb().
|
private |
open output file descriptor
Definition at line 111 of file TMidasFile.h.
Referenced by OutClose(), OutOpen(), Write(), and WriteBuffer().
|
private |
name of the currently open file
Definition at line 96 of file TMidasFile.h.
Referenced by OutClose(), and OutOpen().
|
private |
zlib compressed output file reader
Definition at line 112 of file TMidasFile.h.
Referenced by OutClose(), OutOpen(), Write(), and WriteBuffer().
|
private |
popen() input file reader
Definition at line 110 of file TMidasFile.h.
|
protectedinherited |
Definition at line 67 of file TRawFile.h.
Referenced by TLstFile::Open(), TTdrFile::Open(), TLstFile::Read(), TTdrFile::Read(), Read(), TRlmdFile::Read(), ReadMoreBytes(), and Skip().
|
private |
Definition at line 98 of file TMidasFile.h.
Referenced by FillBuffer(), OutClose(), and WriteBuffer().