GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
|
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 class | EOpenType { kRead , kWrite } |
Public Member Functions | |
TMidasFile () | |
TMidasFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead) | |
TMidasFile (const TMidasFile &)=default | |
TMidasFile (TMidasFile &&) noexcept=default | |
~TMidasFile () override | |
char * | BufferData () |
size_t | BufferSize () const |
virtual size_t | BytesRead () |
void | ClearBuffer () |
void | Close () override |
virtual std::string | Filename () const |
virtual void | Filename (const char *val) |
virtual size_t | FileSize () |
void | FileSize (size_t fileSize) |
void | FillBuffer (const std::shared_ptr< TMidasEvent > &midasEvent, Option_t *opt="") |
virtual const char * | GetFilename () const |
int | GetLastErrno () const |
const char * | GetLastError () const |
std::shared_ptr< TRawEvent > | GetOdbEvent () override |
int | GetRunNumber () override |
int | GetSubRunNumber () override |
void | IncrementBytesRead (size_t val=1) |
std::shared_ptr< TRawEvent > | NewEvent () override |
bool | Open (const char *filename) override |
TMidasFile & | operator= (const TMidasFile &)=default |
TMidasFile & | operator= (TMidasFile &&) noexcept=default |
void | OutClose () |
bool | OutOpen (const char *filename) |
int | Read (std::shared_ptr< TRawEvent > event) override |
void | ResizeBuffer (size_t newSize) |
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 () |
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 | |
size_t | fBytesRead {0} |
uint32_t | fCurrentBufferSize {0} |
int | fCurrentEventNumber {0} |
bool | fDoByteSwap {false} |
int | fFile {-1} |
std::string | fFilename |
size_t | fFileSize {0} |
void * | fGzFile {nullptr} |
int | fLastErrno {0} |
std::string | fLastError |
uint32_t | fMaxBufferSize {1000000} |
TXMLOdb * | fOdb |
std::shared_ptr< TMidasEvent > | fOdbEvent |
int | fOutFile {-1} |
std::string | fOutFilename |
void * | fOutGzFile {nullptr} |
void * | fPoFile {nullptr} |
std::vector< char > | fReadBuffer |
std::vector< char > | fWriteBuffer |
|
stronginherited |
Enumerator | |
---|---|
kRead | |
kWrite |
Definition at line 33 of file TRawFile.h.
TMidasFile::TMidasFile | ( | ) |
default constructor
Definition at line 25 of file TMidasFile.cxx.
|
explicit |
Definition at line 35 of file TMidasFile.cxx.
References fLastError, TRawFile::kRead, TRawFile::kWrite, Open(), OutOpen(), RED, and RESET_COLOR.
|
default |
|
defaultnoexcept |
|
override |
|
inlineinherited |
Definition at line 70 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by Read(), ReadMoreBytes(), and Skip().
|
inlineinherited |
Definition at line 69 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by Read(), ReadMoreBytes(), and Skip().
|
inlinevirtualinherited |
Definition at line 61 of file TRawFile.h.
References TRawFile::fBytesRead.
Referenced by TDataLoop::Iteration(), and Status().
|
inlineinherited |
Definition at line 71 of file TRawFile.h.
References TRawFile::fReadBuffer.
|
overridevirtual |
Close input file.
Implements TRawFile.
Definition at line 546 of file TMidasFile.cxx.
References fFile, fGzFile, TRawFile::Filename(), and fPoFile.
Referenced by ~TMidasFile(), and Open().
|
inlinevirtualinherited |
Get the name of this file.
Definition at line 66 of file TRawFile.h.
References TRawFile::fFilename.
Referenced by Close(), GetRunNumber(), GetSubRunNumber(), and Open().
|
inlinevirtualinherited |
Definition at line 67 of file TRawFile.h.
References TRawFile::fFilename.
|
inlinevirtualinherited |
Definition at line 63 of file TRawFile.h.
References TRawFile::fFileSize.
Referenced by TDataLoop::Iteration(), Open(), and Status().
|
inlineinherited |
Definition at line 64 of file TRawFile.h.
References TRawFile::fFileSize.
void TMidasFile::FillBuffer | ( | const std::shared_ptr< TMidasEvent > & | midasEvent, |
Option_t * | opt = "" ) |
Definition at line 437 of file TMidasFile.cxx.
References fCurrentBufferSize, fMaxBufferSize, fWriteBuffer, and WriteBuffer().
Referenced by ProcessEvent(), Write(), and WriteEvents().
|
inlinevirtualinherited |
Get the name of this file.
Definition at line 56 of file TRawFile.h.
References TRawFile::fFilename.
Referenced by TLstFile::Open(), Open(), TRlmdFile::Open(), TTdrFile::Open(), and WriteEvents().
|
inline |
Get error value for the last file error.
Definition at line 65 of file TMidasFile.h.
References fLastErrno.
Referenced by WriteEvents().
|
inline |
Get error text for the last file error.
Definition at line 66 of file TMidasFile.h.
References fLastError.
Referenced by WriteEvents().
|
inlineoverridevirtual |
Reimplemented from TRawFile.
Definition at line 69 of file TMidasFile.h.
References fOdbEvent.
Referenced by ExamineMidasFile().
|
overridevirtual |
Implements TRawFile.
Definition at line 587 of file TMidasFile.cxx.
References TRawFile::Filename().
Referenced by Open().
|
overridevirtual |
Implements TRawFile.
Definition at line 615 of file TMidasFile.cxx.
References TRawFile::Filename().
Referenced by Open(), and QueueEvents().
|
inlineinherited |
Definition at line 62 of file TRawFile.h.
References TRawFile::fBytesRead.
|
inlineoverridevirtual |
Implements TRawFile.
Definition at line 81 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 95 of file TMidasFile.cxx.
References TRunInfo::ClearLibraryVersion(), Close(), fFile, fGzFile, TRawFile::Filename(), TRawFile::FileSize(), fLastErrno, fLastError, fOdbEvent, fPoFile, TRawFile::GetFilename(), GetRunNumber(), GetSubRunNumber(), hasSuffix(), O_LARGEFILE, Read(), s, TRunInfo::SetDetectorInformation(), SetFileOdb(), TRunInfo::SetLibraryVersion(), TChannel::SetMnemonicClass(), and TRunInfo::SetRunInfo().
Referenced by TMidasFile(), ExamineMidasFile(), and main().
|
default |
|
defaultnoexcept |
void TMidasFile::OutClose | ( | ) |
Close output file.
Definition at line 566 of file TMidasFile.cxx.
References fOutFile, fOutFilename, fOutGzFile, fWriteBuffer, and WriteBuffer().
Referenced by ~TMidasFile(), and OutOpen().
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 229 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 309 of file TMidasFile.cxx.
References TRawFile::BufferData(), TRawFile::BufferSize(), TRawFile::ClearBuffer(), fCurrentEventNumber, fDoByteSwap, fLastErrno, fLastError, TRawFile::IncrementBytesRead(), and ReadMoreBytes().
Referenced by ExamineMidasFile(), Open(), QueueEvents(), and WriteEvents().
|
private |
Definition at line 411 of file TMidasFile.cxx.
References TRawFile::BufferData(), TRawFile::BufferSize(), fFile, fGzFile, fLastErrno, fLastError, readpipe(), and TRawFile::ResizeBuffer().
|
inlineinherited |
Definition at line 72 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by ReadMoreBytes().
|
private |
Definition at line 728 of file TMidasFile.cxx.
References TXMLOdb::FindPath(), fOdb, TXMLOdb::ReadStringArray(), and TEpicsFrag::SetEpicsNameList().
Referenced by SetFileOdb().
|
private |
Definition at line 637 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 737 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(), and TPPG::SetOdbCycle().
Referenced by SetFileOdb().
void TMidasFile::SetMaxBufferSize | ( | int | maxsize | ) |
Definition at line 539 of file TMidasFile.cxx.
References fMaxBufferSize.
|
private |
Definition at line 700 of file TMidasFile.cxx.
References DBLUE, TXMLOdb::FindPath(), fOdb, RESET_COLOR, TRunInfo::SetRunComment(), TRunInfo::SetRunStart(), TRunInfo::SetRunTitle(), and TRunInfo::SubRunNumber().
Referenced by SetFileOdb().
|
private |
Definition at line 989 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(), and TChannel::SetNumber().
Referenced by SetFileOdb().
|
private |
Definition at line 879 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(), and TChannel::SetNumber().
Referenced by SetFileOdb().
|
overridevirtual |
Skip nofEvents from the file.
Implements TRawFile.
Definition at line 357 of file TMidasFile.cxx.
References TRawFile::BufferData(), TRawFile::BufferSize(), TMidasEvent::Clear(), TRawFile::ClearBuffer(), fCurrentEventNumber, fDoByteSwap, TMidas_EVENT_HEADER::fEventId, fLastErrno, fLastError, TMidasEvent::GetDataSize(), TMidasEvent::GetEventHeader(), TRawFile::IncrementBytesRead(), TMidasEvent::IsGoodSize(), ReadMoreBytes(), and TMidasEvent::SwapBytesEventHeader().
|
overridevirtual |
Implements TRawFile.
Definition at line 56 of file TMidasFile.cxx.
References TRawFile::BytesRead(), fCurrentEventNumber, TRawFile::FileSize(), 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 497 of file TMidasFile.cxx.
References fOutFile, and fOutGzFile.
Referenced by ProcessEvent().
bool TMidasFile::WriteBuffer | ( | ) |
Definition at line 477 of file TMidasFile.cxx.
References fCurrentBufferSize, fOutFile, fOutGzFile, and fWriteBuffer.
Referenced by FillBuffer(), OutClose(), and WriteEvents().
|
privateinherited |
Definition at line 87 of file TRawFile.h.
Referenced by TRawFile::BytesRead(), TRlmdFile::Close(), TRawFile::IncrementBytesRead(), TRlmdFile::Open(), TLstFile::Read(), TRlmdFile::Read(), TTdrFile::Read(), TTdrFile::Skip(), TLstFile::Status(), and TTdrFile::Status().
|
private |
Definition at line 108 of file TMidasFile.h.
Referenced by FillBuffer(), and WriteBuffer().
|
private |
Definition at line 113 of file TMidasFile.h.
|
private |
"true" if file has to be byteswapped
Definition at line 115 of file TMidasFile.h.
|
private |
open input file descriptor
Definition at line 117 of file TMidasFile.h.
Referenced by Close(), Open(), and ReadMoreBytes().
|
privateinherited |
name of the currently open file
Definition at line 83 of file TRawFile.h.
Referenced by TRawFile::Filename(), TRawFile::Filename(), TRawFile::GetFilename(), TLstFile::GetRunNumber(), TRlmdFile::GetRunNumber(), TTdrFile::GetRunNumber(), TTdrFile::GetSubRunNumber(), TLstFile::Open(), TRlmdFile::Open(), and TTdrFile::Open().
|
privateinherited |
Definition at line 88 of file TRawFile.h.
Referenced by TRlmdFile::Close(), TRawFile::FileSize(), TRawFile::FileSize(), TLstFile::Open(), TRlmdFile::Open(), TTdrFile::Open(), TLstFile::Read(), TRlmdFile::Read(), TTdrFile::Read(), TTdrFile::Skip(), TLstFile::Status(), TRlmdFile::Status(), and TTdrFile::Status().
|
private |
zlib compressed input file reader
Definition at line 118 of file TMidasFile.h.
Referenced by Close(), Open(), and ReadMoreBytes().
|
private |
errno from the last operation
Definition at line 111 of file TMidasFile.h.
Referenced by GetLastErrno(), Open(), OutOpen(), Read(), ReadMoreBytes(), and Skip().
|
private |
error string from last errno
Definition at line 112 of file TMidasFile.h.
Referenced by TMidasFile(), GetLastError(), Open(), OutOpen(), Read(), ReadMoreBytes(), and Skip().
|
private |
Definition at line 109 of file TMidasFile.h.
Referenced by FillBuffer(), and SetMaxBufferSize().
|
private |
Definition at line 102 of file TMidasFile.h.
Referenced by SetEPICSOdb(), SetFileOdb(), SetGRIFFOdb(), SetRunInfo(), SetTIGDAQOdb(), and SetTIGOdb().
|
private |
Definition at line 98 of file TMidasFile.h.
Referenced by GetOdbEvent(), Open(), and SetFileOdb().
|
private |
open output file descriptor
Definition at line 120 of file TMidasFile.h.
Referenced by OutClose(), OutOpen(), Write(), and WriteBuffer().
|
private |
name of the currently open file
Definition at line 105 of file TMidasFile.h.
Referenced by OutClose(), and OutOpen().
|
private |
zlib compressed output file reader
Definition at line 121 of file TMidasFile.h.
Referenced by OutClose(), OutOpen(), Write(), and WriteBuffer().
|
private |
popen() input file reader
Definition at line 119 of file TMidasFile.h.
|
privateinherited |
Definition at line 85 of file TRawFile.h.
Referenced by TRawFile::BufferData(), TRawFile::BufferSize(), TRawFile::ClearBuffer(), TLstFile::Open(), TTdrFile::Open(), TLstFile::Read(), TRlmdFile::Read(), TTdrFile::Read(), and TRawFile::ResizeBuffer().
|
private |
Definition at line 107 of file TMidasFile.h.
Referenced by FillBuffer(), OutClose(), and WriteBuffer().