GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TRlmdFile Class Reference

Detailed Description

This Class is used to read and write RLMD files in the root framework.

Definition at line 94 of file TRlmdFile.h.

Public Types

enum class  EOpenType { kRead , kWrite }
 

Public Member Functions

 TRlmdFile ()
 
 TRlmdFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead)
 
 ~TRlmdFile () 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)
 
virtual const char * GetFilename () const
 
virtual std::shared_ptr< TRawEventGetOdbEvent ()
 
int GetRunNumber () override
 
int GetSubRunNumber () override
 
void IncrementBytesRead (size_t val=1)
 
std::shared_ptr< TRawEventNewEvent () override
 
bool Open (const char *filename) override
 
int Read (std::shared_ptr< TRawEvent > rlmdEvent) override
 
void ResizeBuffer (size_t newSize)
 
void Skip (size_t nofEvents) override
 
std::string Status (bool long_file_description=true) override
 

Private Member Functions

time_t ConvertToEpoch (const std::string &date, const std::string &time)
 

Private Attributes

RlmdBufferHeader fBufferHeader
 
size_t fBuffersRead {0}
 
size_t fBytesRead {0}
 
std::string fFilename
 
size_t fFileSize {0}
 
std::ifstream fInputStream
 
std::vector< char > fReadBuffer
 
std::string fStartDate
 
std::string fStartTime
 
std::string fStopDate
 
std::string fStopTime
 
std::string fTemplate
 
+ Inheritance diagram for TRlmdFile:
+ Collaboration diagram for TRlmdFile:

Member Enumeration Documentation

◆ EOpenType

enum class TRawFile::EOpenType
stronginherited
Enumerator
kRead 
kWrite 

Definition at line 33 of file TRawFile.h.

Constructor & Destructor Documentation

◆ TRlmdFile() [1/2]

TRlmdFile::TRlmdFile ( )

default constructor

Definition at line 33 of file TRlmdFile.cxx.

◆ TRlmdFile() [2/2]

TRlmdFile::TRlmdFile ( const char * filename,
TRawFile::EOpenType open_type = TRawFile::EOpenType::kRead )

Definition at line 40 of file TRlmdFile.cxx.

References TRawFile::kRead, TRawFile::kWrite, and Open().

◆ ~TRlmdFile()

TRlmdFile::~TRlmdFile ( )
override

destructor

Definition at line 48 of file TRlmdFile.cxx.

References Close().

Member Function Documentation

◆ BufferData()

char * TRawFile::BufferData ( )
inlineinherited

Definition at line 70 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TMidasFile::Read(), TMidasFile::ReadMoreBytes(), and TMidasFile::Skip().

◆ BufferSize()

size_t TRawFile::BufferSize ( ) const
inlineinherited

Definition at line 69 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TMidasFile::Read(), TMidasFile::ReadMoreBytes(), and TMidasFile::Skip().

◆ BytesRead()

virtual size_t TRawFile::BytesRead ( )
inlinevirtualinherited

Definition at line 61 of file TRawFile.h.

References TRawFile::fBytesRead.

Referenced by TDataLoop::Iteration(), and TMidasFile::Status().

◆ ClearBuffer()

void TRawFile::ClearBuffer ( )
inlineinherited

Definition at line 71 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TMidasFile::Read(), and TMidasFile::Skip().

◆ Close()

void TRlmdFile::Close ( )
overridevirtual

Close input file.

Implements TRawFile.

Definition at line 129 of file TRlmdFile.cxx.

References TRawFile::fBytesRead, TRawFile::fFileSize, and fInputStream.

Referenced by ~TRlmdFile(), and Read().

◆ ConvertToEpoch()

time_t TRlmdFile::ConvertToEpoch ( const std::string & date,
const std::string & time )
private

Definition at line 226 of file TRlmdFile.cxx.

Referenced by Read().

◆ Filename() [1/2]

virtual std::string TRawFile::Filename ( ) const
inlinevirtualinherited

Get the name of this file.

Definition at line 66 of file TRawFile.h.

References TRawFile::fFilename.

Referenced by TMidasFile::Close(), TMidasFile::GetRunNumber(), TMidasFile::GetSubRunNumber(), and TMidasFile::Open().

◆ Filename() [2/2]

virtual void TRawFile::Filename ( const char * val)
inlinevirtualinherited

Definition at line 67 of file TRawFile.h.

References TRawFile::fFilename.

◆ FileSize() [1/2]

virtual size_t TRawFile::FileSize ( )
inlinevirtualinherited

Definition at line 63 of file TRawFile.h.

References TRawFile::fFileSize.

Referenced by TDataLoop::Iteration(), TMidasFile::Open(), and TMidasFile::Status().

◆ FileSize() [2/2]

void TRawFile::FileSize ( size_t fileSize)
inlineinherited

Definition at line 64 of file TRawFile.h.

References TRawFile::fFileSize.

◆ GetFilename()

virtual const char * TRawFile::GetFilename ( ) const
inlinevirtualinherited

Get the name of this file.

Definition at line 56 of file TRawFile.h.

References TRawFile::fFilename.

Referenced by TLstFile::Open(), TMidasFile::Open(), Open(), TTdrFile::Open(), and WriteEvents().

◆ GetOdbEvent()

virtual std::shared_ptr< TRawEvent > TRawFile::GetOdbEvent ( )
inlinevirtualinherited

Reimplemented in TMidasFile.

Definition at line 75 of file TRawFile.h.

◆ GetRunNumber()

int TRlmdFile::GetRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 204 of file TRlmdFile.cxx.

References TRawFile::fFilename.

Referenced by Open().

◆ GetSubRunNumber()

int TRlmdFile::GetSubRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 220 of file TRlmdFile.cxx.

Referenced by Open().

◆ IncrementBytesRead()

void TRawFile::IncrementBytesRead ( size_t val = 1)
inlineinherited

Definition at line 62 of file TRawFile.h.

References TRawFile::fBytesRead.

Referenced by TMidasFile::Read(), and TMidasFile::Skip().

◆ NewEvent()

std::shared_ptr< TRawEvent > TRlmdFile::NewEvent ( )
inlineoverridevirtual

Implements TRawFile.

Definition at line 116 of file TRlmdFile.h.

◆ Open()

bool TRlmdFile::Open ( const char * filename)
overridevirtual

Open input file.

Open a lmd .lmd file with given file name.

Remote files can be accessed using these special file names:

  • pipein://command - read data produced by given command, see examples below
  • ssh://username@hostname/path/file.mid - read remote file through an ssh pipe
  • ssh://username@hostname/path/file.mid.gz and file.mid.bz2 - same for compressed files
  • dccp://path/file.mid (also file.mid.gz and file.mid.bz2) - read data from dcache, requires dccp in the PATH

Examples:

  • ./event_dump.exe /ladd/data9/t2km11/data/run02696.mid.gz - read normal compressed file
  • ./event_dump.exe ssh://ladd09//ladd/data9/t2km11/data/run02696.mid.gz - read compressed file through ssh to ladd09 (note double "/")
  • ./event_dump.exe pipein://"cat /ladd/data9/t2km11/data/run02696.mid.gz | gzip -dc" - read data piped from a command or script (note quotes)
  • ./event_dump.exe pipein://"gzip -dc /ladd/data9/t2km11/data/run02696.mid.gz" - another way to read compressed files
  • ./event_dump.exe dccp:///pnfs/triumf.ca/data/t2km11/aug2008/run02837.mid.gz - read file directly from a dcache pool (note triple "/")
Parameters
[in]filenameThe file to open.
Returns
"true" for succes, "false" for error, use GetLastError() to see why

Implements TRawFile.

Definition at line 81 of file TRlmdFile.cxx.

References TRunInfo::ClearVersion(), RlmdFileHeader::date, TRawFile::fBytesRead, TRawFile::fFilename, TRawFile::fFileSize, fInputStream, fStartDate, fStartTime, fTemplate, TRawFile::GetFilename(), GetRunNumber(), GetSubRunNumber(), TRunInfo::SetDetectorInformation(), TChannel::SetMnemonicClass(), TRunInfo::SetRunInfo(), TRunInfo::SetRunLength(), TRunInfo::SetVersion(), RlmdFileHeader::templateName, and RlmdFileHeader::time.

Referenced by TRlmdFile().

◆ Read()

int TRlmdFile::Read ( std::shared_ptr< TRawEvent > Event)
overridevirtual

Read one event from the file.

Parameters
[in]EventPointer to an empty TRlmdEvent
Returns
"true" for success, "false" for failure, see GetLastError() to see why

EDITED FROM THE ORIGINAL TO RETURN TOTAL SUCESSFULLY BYTES READ INSTEAD OF TRUE/FALSE, PCB

Implements TRawFile.

Definition at line 140 of file TRlmdFile.cxx.

References Close(), ConvertToEpoch(), RlmdBufferHeader::dataLength, RlmdFileFooter::date, fBufferHeader, fBuffersRead, TRawFile::fBytesRead, TRawFile::fFileSize, fInputStream, TRawFile::fReadBuffer, fStartDate, fStartTime, fStopDate, fStopTime, TRunInfo::SetRunLength(), TRunInfo::SetRunStart(), TRunInfo::SetRunStop(), RlmdFileFooter::time, and RlmdBufferHeader::type.

◆ ResizeBuffer()

void TRawFile::ResizeBuffer ( size_t newSize)
inlineinherited

Definition at line 72 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TMidasFile::ReadMoreBytes().

◆ Skip()

void TRlmdFile::Skip ( size_t nofEvents)
overridevirtual

Skip nofEvents from the file.

Implements TRawFile.

Definition at line 196 of file TRlmdFile.cxx.

◆ Status()

std::string TRlmdFile::Status ( bool long_file_description = true)
overridevirtual

Implements TRawFile.

Definition at line 54 of file TRlmdFile.cxx.

References TRawFile::fFileSize, fInputStream, HIDE_CURSOR, and SHOW_CURSOR.

Member Data Documentation

◆ fBufferHeader

RlmdBufferHeader TRlmdFile::fBufferHeader
private

Definition at line 127 of file TRlmdFile.h.

Referenced by Read().

◆ fBuffersRead

size_t TRlmdFile::fBuffersRead {0}
private

Definition at line 128 of file TRlmdFile.h.

Referenced by Read().

◆ fBytesRead

size_t TRawFile::fBytesRead {0}
privateinherited

◆ fFilename

std::string TRawFile::fFilename
privateinherited

◆ fFileSize

◆ fInputStream

std::ifstream TRlmdFile::fInputStream
private

Definition at line 125 of file TRlmdFile.h.

Referenced by Close(), Open(), Read(), and Status().

◆ fReadBuffer

std::vector<char> TRawFile::fReadBuffer
privateinherited

◆ fStartDate

std::string TRlmdFile::fStartDate
private

Definition at line 120 of file TRlmdFile.h.

Referenced by Open(), and Read().

◆ fStartTime

std::string TRlmdFile::fStartTime
private

Definition at line 121 of file TRlmdFile.h.

Referenced by Open(), and Read().

◆ fStopDate

std::string TRlmdFile::fStopDate
private

Definition at line 122 of file TRlmdFile.h.

Referenced by Read().

◆ fStopTime

std::string TRlmdFile::fStopTime
private

Definition at line 123 of file TRlmdFile.h.

Referenced by Read().

◆ fTemplate

std::string TRlmdFile::fTemplate
private

Definition at line 124 of file TRlmdFile.h.

Referenced by Open().