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

Detailed Description

Reader for MIDAS .mid files.

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

Definition at line 32 of file TTdrFile.h.

Public Types

enum class  EOpenType { kRead , kWrite }
 

Public Member Functions

 TTdrFile ()
 
 TTdrFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead)
 
 ~TTdrFile () 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 > lstEvent) override
 
void ResizeBuffer (size_t newSize)
 
void Skip (size_t nofEvents) override
 
std::string Status (bool long_file_description=true) override
 

Protected Attributes

std::ifstream fInputFile
 

Private Attributes

size_t fBytesRead {0}
 
std::string fFilename
 
size_t fFileSize {0}
 
std::vector< char > fReadBuffer
 
+ Inheritance diagram for TTdrFile:
+ Collaboration diagram for TTdrFile:

Member Enumeration Documentation

◆ EOpenType

enum class TRawFile::EOpenType
stronginherited
Enumerator
kRead 
kWrite 

Definition at line 33 of file TRawFile.h.

Constructor & Destructor Documentation

◆ TTdrFile() [1/2]

TTdrFile::TTdrFile ( )

default constructor

Definition at line 29 of file TTdrFile.cxx.

◆ TTdrFile() [2/2]

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

Definition at line 36 of file TTdrFile.cxx.

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

◆ ~TTdrFile()

TTdrFile::~TTdrFile ( )
override

destructor

Definition at line 45 of file TTdrFile.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 TTdrFile::Close ( )
overridevirtual

Close input file.

Implements TRawFile.

Definition at line 107 of file TTdrFile.cxx.

Referenced by ~TTdrFile().

◆ 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(), TRlmdFile::Open(), 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 TTdrFile::GetRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 168 of file TTdrFile.cxx.

References TRawFile::fFilename.

Referenced by Open().

◆ GetSubRunNumber()

int TTdrFile::GetSubRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 200 of file TTdrFile.cxx.

References TRawFile::fFilename.

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 > TTdrFile::NewEvent ( )
inlineoverridevirtual

Implements TRawFile.

Definition at line 54 of file TTdrFile.h.

◆ Open()

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

Open input file.

Open a tdr file with given file name.

Parameters
[in]filenameThe file to open.
Returns
"true" for succes, "false" for error, use GetLastError() to see why

Implements TRawFile.

Definition at line 61 of file TTdrFile.cxx.

References TRunInfo::ClearVersion(), TRawFile::fFilename, TRawFile::fFileSize, fInputFile, TRawFile::fReadBuffer, TRawFile::GetFilename(), GetRunNumber(), GetSubRunNumber(), TRunInfo::SetDetectorInformation(), TChannel::SetMnemonicClass(), TRunInfo::SetRunInfo(), and TRunInfo::SetVersion().

Referenced by TTdrFile().

◆ Read()

int TTdrFile::Read ( std::shared_ptr< TRawEvent > tdrEvent)
overridevirtual

Read one event from the file.

Parameters
[in]tdrEventPointer to an empty TTdrEvent
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 116 of file TTdrFile.cxx.

References TRawFile::fBytesRead, TRawFile::fFileSize, fInputFile, and TRawFile::fReadBuffer.

◆ 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 TTdrFile::Skip ( size_t nofEvents)
overridevirtual

Skip nofEvents from the file.

Implements TRawFile.

Definition at line 154 of file TTdrFile.cxx.

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

◆ Status()

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

Implements TRawFile.

Definition at line 51 of file TTdrFile.cxx.

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

Member Data Documentation

◆ fBytesRead

size_t TRawFile::fBytesRead {0}
privateinherited

◆ fFilename

std::string TRawFile::fFilename
privateinherited

◆ fFileSize

◆ fInputFile

std::ifstream TTdrFile::fInputFile
protected

Definition at line 58 of file TTdrFile.h.

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

◆ fReadBuffer

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