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 ()=default
 
 TTdrFile (const char *filename, TRawFile::EOpenType open_type=TRawFile::EOpenType::kRead)
 
 ~TTdrFile () 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)
 
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
 
std::vector< char > & ReadBuffer ()
 
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

default constructor

◆ TTdrFile() [2/2]

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

Definition at line 25 of file TTdrFile.cxx.

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

◆ ~TTdrFile()

TTdrFile::~TTdrFile ( )
override

destructor

Definition at line 34 of file TTdrFile.cxx.

References Close().

Member Function Documentation

◆ BufferData()

char * TRawFile::BufferData ( )
inlineinherited

◆ BufferSize()

size_t TRawFile::BufferSize ( ) const
inlineinherited

Definition at line 71 of file TRawFile.h.

References TRawFile::fReadBuffer.

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

◆ BytesRead() [1/2]

virtual size_t TRawFile::BytesRead ( )
inlinevirtualinherited

◆ BytesRead() [2/2]

void TRawFile::BytesRead ( size_t bytesRead)
inlineinherited

Definition at line 62 of file TRawFile.h.

References TRawFile::fBytesRead.

◆ ClearBuffer()

void TRawFile::ClearBuffer ( )
inlineinherited

Definition at line 73 of file TRawFile.h.

References TRawFile::fReadBuffer.

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

◆ Close()

void TTdrFile::Close ( )
overridevirtual

Close input file.

Implements TRawFile.

Definition at line 96 of file TTdrFile.cxx.

Referenced by ~TTdrFile().

◆ Filename() [1/2]

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

◆ Filename() [2/2]

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

Definition at line 68 of file TRawFile.h.

References TRawFile::fFilename.

◆ FileSize() [1/2]

◆ FileSize() [2/2]

void TRawFile::FileSize ( size_t fileSize)
inlineinherited

Definition at line 65 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 77 of file TRawFile.h.

◆ GetRunNumber()

int TTdrFile::GetRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 157 of file TTdrFile.cxx.

References TRawFile::Filename().

Referenced by Open().

◆ GetSubRunNumber()

int TTdrFile::GetSubRunNumber ( )
overridevirtual

Implements TRawFile.

Definition at line 189 of file TTdrFile.cxx.

References TRawFile::Filename().

Referenced by Open().

◆ IncrementBytesRead()

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

Definition at line 63 of file TRawFile.h.

References TRawFile::fBytesRead.

Referenced by TLstFile::Read(), TMidasFile::Read(), TRlmdFile::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 50 of file TTdrFile.cxx.

References TRunInfo::ClearVersion(), TRawFile::Filename(), TRawFile::FileSize(), fInputFile, TRawFile::GetFilename(), GetRunNumber(), GetSubRunNumber(), TRawFile::ResizeBuffer(), 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 105 of file TTdrFile.cxx.

References TRawFile::BufferData(), TRawFile::BytesRead(), TRawFile::FileSize(), fInputFile, and TRawFile::ReadBuffer().

◆ ReadBuffer()

std::vector< char > & TRawFile::ReadBuffer ( )
inlineinherited

Definition at line 70 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TLstFile::Read(), TRlmdFile::Read(), and Read().

◆ ResizeBuffer()

void TRawFile::ResizeBuffer ( size_t newSize)
inlineinherited

Definition at line 74 of file TRawFile.h.

References TRawFile::fReadBuffer.

Referenced by TLstFile::Open(), Open(), TRlmdFile::Read(), and TMidasFile::ReadMoreBytes().

◆ Skip()

void TTdrFile::Skip ( size_t nofEvents)
overridevirtual

Skip nofEvents from the file.

Implements TRawFile.

Definition at line 143 of file TTdrFile.cxx.

References TRawFile::BytesRead(), TRawFile::FileSize(), and fInputFile.

◆ Status()

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

Implements TRawFile.

Definition at line 40 of file TTdrFile.cxx.

References TRawFile::BytesRead(), TRawFile::FileSize(), HIDE_CURSOR, and SHOW_CURSOR.

Member Data Documentation

◆ fBytesRead

size_t TRawFile::fBytesRead {0}
privateinherited

◆ fFilename

std::string TRawFile::fFilename
privateinherited

name of the currently open file

Definition at line 85 of file TRawFile.h.

Referenced by TRawFile::Filename(), TRawFile::Filename(), and TRawFile::GetFilename().

◆ fFileSize

size_t TRawFile::fFileSize {0}
privateinherited

Definition at line 90 of file TRawFile.h.

Referenced by TRawFile::FileSize(), and TRawFile::FileSize().

◆ fInputFile

std::ifstream TTdrFile::fInputFile
protected

Definition at line 61 of file TTdrFile.h.

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

◆ fReadBuffer

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