![]() |
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 : std::uint8_t { 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 | BytesRead (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 |
| std::vector< char > & | ReadBuffer () |
| 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 |
Inheritance diagram for TMidasFile:
Collaboration diagram for TMidasFile:
|
stronginherited |
| Enumerator | |
|---|---|
| kRead | |
| kWrite | |
Definition at line 33 of file TRawFile.h.
| TMidasFile::TMidasFile | ( | ) |
|
explicit |
Definition at line 35 of file TMidasFile.cxx.
References fLastError, TRawFile::kRead, TRawFile::kWrite, Open(), OutOpen(), RED, and RESET_COLOR.
|
default |
|
defaultnoexcept |
|
override |
destructor
Default dtor. It closes the read in midas file as well as the output midas file.
Definition at line 49 of file TMidasFile.cxx.
References Close(), fOdb, fOdbEvent, and OutClose().
|
inlineinherited |
Definition at line 72 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by Read(), TRlmdFile::Read(), TTdrFile::Read(), ReadMoreBytes(), and Skip().
|
inlineinherited |
Definition at line 71 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 TRlmdFile::Close(), TDataLoop::Iteration(), TRlmdFile::Open(), TLstFile::Read(), TRlmdFile::Read(), TTdrFile::Read(), TTdrFile::Skip(), TLstFile::Status(), Status(), and TTdrFile::Status().
|
inlineinherited |
Definition at line 62 of file TRawFile.h.
References TRawFile::fBytesRead.
|
inlineinherited |
Definition at line 73 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by TLstFile::Read(), Read(), and Skip().
|
overridevirtual |
Close input file.
Closes the input midas file. Use OutClose() to close the output Midas File.
Implements TRawFile.
Definition at line 550 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 67 of file TRawFile.h.
References TRawFile::fFilename.
Referenced by Close(), TLstFile::GetRunNumber(), GetRunNumber(), TRlmdFile::GetRunNumber(), TTdrFile::GetRunNumber(), GetSubRunNumber(), TTdrFile::GetSubRunNumber(), TLstFile::Open(), Open(), TRlmdFile::Open(), and TTdrFile::Open().
|
inlinevirtualinherited |
Definition at line 68 of file TRawFile.h.
References TRawFile::fFilename.
|
inlinevirtualinherited |
Definition at line 64 of file TRawFile.h.
References TRawFile::fFileSize.
Referenced by TRlmdFile::Close(), TDataLoop::Iteration(), TLstFile::Open(), Open(), TRlmdFile::Open(), TTdrFile::Open(), TLstFile::Read(), TRlmdFile::Read(), TTdrFile::Read(), TTdrFile::Skip(), TLstFile::Status(), Status(), TRlmdFile::Status(), and TTdrFile::Status().
|
inlineinherited |
Definition at line 65 of file TRawFile.h.
References TRawFile::fFileSize.
| void TMidasFile::FillBuffer | ( | const std::shared_ptr< TMidasEvent > & | midasEvent, |
| Option_t * | opt = "" ) |
Fills a buffer to be written to a midas file.
Definition at line 441 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 |
Parse the run number from the current TMidasFile. This assumes a format of run#####_###.mid or run#####.mid.
Implements TRawFile.
Definition at line 591 of file TMidasFile.cxx.
References TRawFile::Filename().
Referenced by Open().
|
overridevirtual |
Implements TRawFile.
Definition at line 619 of file TMidasFile.cxx.
References TRawFile::Filename().
Referenced by Open(), and QueueEvents().
|
inlineinherited |
Definition at line 63 of file TRawFile.h.
References TRawFile::fBytesRead.
Referenced by TLstFile::Read(), Read(), TRlmdFile::Read(), and Skip().
|
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 99 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(), TRunInfo::SetDetectorInformation(), SetFileOdb(), TRunInfo::SetLibraryVersion(), TChannel::SetMnemonicClass(), and TRunInfo::SetRunInfo().
Referenced by TMidasFile(), ExamineMidasFile(), and main().
|
default |
|
defaultnoexcept |
| void TMidasFile::OutClose | ( | ) |
Close output file.
Closes the output midas file. Use Close() to close the read-in midas file
Definition at line 570 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 233 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 313 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().
|
inlineinherited |
Definition at line 70 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by TLstFile::Read(), TRlmdFile::Read(), and TTdrFile::Read().
|
private |
Definition at line 415 of file TMidasFile.cxx.
References TRawFile::BufferData(), TRawFile::BufferSize(), fFile, fGzFile, fLastErrno, fLastError, readpipe(), and TRawFile::ResizeBuffer().
|
inlineinherited |
Definition at line 74 of file TRawFile.h.
References TRawFile::fReadBuffer.
Referenced by TLstFile::Open(), TTdrFile::Open(), TRlmdFile::Read(), and ReadMoreBytes().
|
private |
Definition at line 732 of file TMidasFile.cxx.
References TXMLOdb::FindPath(), fOdb, TXMLOdb::ReadStringArray(), and TEpicsFrag::SetEpicsNameList().
Referenced by SetFileOdb().
|
private |
Definition at line 641 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 741 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 | ) |
Sets the maximum buffer size for the TMidasEvents to be written to an output TMidasFile.
Definition at line 543 of file TMidasFile.cxx.
References fMaxBufferSize.
|
private |
Definition at line 704 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 993 of file TMidasFile.cxx.
References TChannel::AddChannel(), 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 883 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 361 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 60 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.
Writes an individual TMidasEvent to the output TMidasFile. This will write to a zipped file if the output file is defined as a zipped file.
Definition at line 501 of file TMidasFile.cxx.
References fOutFile, and fOutGzFile.
Referenced by ProcessEvent().
| bool TMidasFile::WriteBuffer | ( | ) |
Writes a buffer of TMidasEvents to the output file.
Definition at line 481 of file TMidasFile.cxx.
References fCurrentBufferSize, fOutFile, fOutGzFile, and fWriteBuffer.
Referenced by FillBuffer(), OutClose(), and WriteEvents().
|
privateinherited |
Definition at line 89 of file TRawFile.h.
Referenced by TRawFile::BytesRead(), TRawFile::BytesRead(), and TRawFile::IncrementBytesRead().
|
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 85 of file TRawFile.h.
Referenced by TRawFile::Filename(), TRawFile::Filename(), and TRawFile::GetFilename().
|
privateinherited |
Definition at line 90 of file TRawFile.h.
Referenced by TRawFile::FileSize(), and TRawFile::FileSize().
|
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 ~TMidasFile(), SetEPICSOdb(), SetFileOdb(), SetGRIFFOdb(), SetRunInfo(), SetTIGDAQOdb(), and SetTIGOdb().
|
private |
Definition at line 98 of file TMidasFile.h.
Referenced by ~TMidasFile(), 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 87 of file TRawFile.h.
Referenced by TRawFile::BufferData(), TRawFile::BufferSize(), TRawFile::ClearBuffer(), TRawFile::ReadBuffer(), and TRawFile::ResizeBuffer().
|
private |
Definition at line 107 of file TMidasFile.h.
Referenced by FillBuffer(), OutClose(), and WriteBuffer().