GRSISort
Created by P.C. Bender
Developement Team: P.C. Bender, R. Dunlop, V. Bildstein
An extension of the ROOT analysis Framework
TLstFile Class Reference

Reader for ILL .lst files.

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

Definition at line 31 of file TLstFile.h.

Public Types

enum  EOpenType { EOpenType::kRead, EOpenType::kWrite }
 

Public Member Functions

 TLstFile ()
 
 TLstFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead)
 
 ~TLstFile () override
 
void Close () override
 
virtual size_t GetBytesRead ()
 
virtual const char * GetFilename () const
 
virtual size_t GetFileSize ()
 
virtual std::shared_ptr< TRawEventGetOdbEvent ()
 
int GetRunNumber () override
 
int GetSubRunNumber () override
 
std::shared_ptr< TRawEventNewEvent () override
 
bool Open (const char *filename) override
 
int Read (std::shared_ptr< TRawEvent > lstEvent) override
 
void Skip (size_t nofEvents) override
 
std::string Status (bool long_file_description=true) override
 

Protected Attributes

size_t fBytesRead {0}
 
std::string fFilename
 
size_t fFileSize {0}
 
std::vector< char > fReadBuffer
 

Private Attributes

int32_t * fBoardHeaders
 
std::ifstream fInputStream
 
int32_t fnbBoards
 
int32_t fnbEvents
 
int32_t fTimeBase
 
int32_t fVersion
 

#include <TLstFile.h>

+ Inheritance diagram for TLstFile:
+ Collaboration diagram for TLstFile:

Member Enumeration Documentation

◆ EOpenType

enum TRawFile::EOpenType
stronginherited
Enumerator
kRead 
kWrite 

Definition at line 33 of file TRawFile.h.

Constructor & Destructor Documentation

◆ TLstFile() [1/2]

TLstFile::TLstFile ( )

default constructor

Definition at line 32 of file TLstFile.cxx.

◆ TLstFile() [2/2]

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

Definition at line 39 of file TLstFile.cxx.

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

◆ ~TLstFile()

TLstFile::~TLstFile ( )
override

destructor

Definition at line 48 of file TLstFile.cxx.

References Close(), and fBoardHeaders.

Member Function Documentation

◆ Close()

void TLstFile::Close ( )
overridevirtual

Close input file.

Implements TRawFile.

Definition at line 137 of file TLstFile.cxx.

References fInputStream.

Referenced by ~TLstFile().

◆ GetBytesRead()

virtual size_t TRawFile::GetBytesRead ( )
inlinevirtualinherited

Definition at line 56 of file TRawFile.h.

References TRawFile::fBytesRead.

Referenced by TDataLoop::Iteration().

◆ GetFilename()

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

Get the name of this file.

Reimplemented in TMidasFile.

Definition at line 51 of file TRawFile.h.

References TRawFile::fFilename.

Referenced by Open(), TTdrFile::Open(), and TRlmdFile::Open().

◆ GetFileSize()

virtual size_t TRawFile::GetFileSize ( )
inlinevirtualinherited

Definition at line 57 of file TRawFile.h.

References TRawFile::fFileSize.

Referenced by TDataLoop::Iteration().

◆ GetOdbEvent()

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

Reimplemented in TMidasFile.

Definition at line 60 of file TRawFile.h.

◆ GetRunNumber()

int TLstFile::GetRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 190 of file TLstFile.cxx.

References TRawFile::fFilename.

Referenced by Open().

◆ GetSubRunNumber()

int TLstFile::GetSubRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 218 of file TLstFile.cxx.

Referenced by Open().

◆ NewEvent()

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

Implements TRawFile.

Definition at line 53 of file TLstFile.h.

◆ Open()

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

Open input file.

Open a lst .lst 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 83 of file TLstFile.cxx.

References TRunInfo::ClearVersion(), fBoardHeaders, TRawFile::fFilename, TRawFile::fFileSize, fInputStream, fnbBoards, fnbEvents, TRawFile::fReadBuffer, fTimeBase, fVersion, TRawFile::GetFilename(), GetRunNumber(), GetSubRunNumber(), ILLDATA_RELEASE, READ_EVENT_SIZE, TRunInfo::SetDetectorInformation(), TChannel::SetMnemonicClass(), TRunInfo::SetRunInfo(), TRunInfo::SetRunLength(), and TRunInfo::SetVersion().

Referenced by TLstFile().

◆ Read()

int TLstFile::Read ( std::shared_ptr< TRawEvent Event)
overridevirtual

Read one event from the file.

Parameters
[in]EventPointer to an empty TLstEvent
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 147 of file TLstFile.cxx.

References TLstEvent::Clear(), TRawFile::fBytesRead, TRawFile::fFileSize, fInputStream, TRawFile::fReadBuffer, fVersion, and READ_EVENT_SIZE.

◆ Skip()

void TLstFile::Skip ( size_t  nofEvents)
overridevirtual

Skip nofEvents from the file.

Implements TRawFile.

Definition at line 184 of file TLstFile.cxx.

◆ Status()

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

Implements TRawFile.

Definition at line 56 of file TLstFile.cxx.

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

Member Data Documentation

◆ fBoardHeaders

int32_t* TLstFile::fBoardHeaders
private

Definition at line 60 of file TLstFile.h.

Referenced by Open(), and ~TLstFile().

◆ fBytesRead

◆ fFilename

◆ fFileSize

◆ fInputStream

std::ifstream TLstFile::fInputStream
private

Definition at line 61 of file TLstFile.h.

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

◆ fnbBoards

int32_t TLstFile::fnbBoards
private

Definition at line 59 of file TLstFile.h.

Referenced by Open().

◆ fnbEvents

int32_t TLstFile::fnbEvents
private

Definition at line 58 of file TLstFile.h.

Referenced by Open().

◆ fReadBuffer

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

◆ fTimeBase

int32_t TLstFile::fTimeBase
private

Definition at line 57 of file TLstFile.h.

Referenced by Open().

◆ fVersion

int32_t TLstFile::fVersion
private

Definition at line 56 of file TLstFile.h.

Referenced by Open(), and Read().