Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
CoMPASSReader Class Reference

Cursor over a CoMPASS binary file. More...

#include <BinaryUtils.hpp>

Inheritance diagram for CoMPASSReader:
Collaboration diagram for CoMPASSReader:

Public Member Functions

 CoMPASSReader ()
 Construct a reader with no file open.
virtual ~CoMPASSReader ()
Bool_t Open (const char *fname) override
 Open a file and read its global header.
Bool_t Open (const char *fname, UShort_t header_override)
 Open a file, assuming a given global header.
Bool_t ReadEvent () override
 Decode the next event into the current-event object.
const CoMPASSDataGetCurrentEvent () const
 The event most recently read.
CoMPASSDataGetCurrentEvent ()
 Mutable access to the event most recently read.
UShort_t GetGlobalHeader () const
 The global header in force, read from the file or overridden.
Public Member Functions inherited from BinaryReader
 BinaryReader ()
 Construct a reader with no file open.
virtual ~BinaryReader ()
 Closes the file if it is still open.
virtual void Close ()
 Close the file. Safe to call when nothing is open.
Bool_t IsOpen () const
 Whether a file is currently open.
TString GetFileName () const
 Path most recently passed to Open().
Long64_t GetBytesRead () const
 Bytes consumed so far, for progress reporting.
Bool_t IsEOF () const
 Whether the file is exhausted or was never opened.

Additional Inherited Members

Protected Attributes inherited from BinaryReader
std::ifstream file
TString filename
Bool_t file_open
Long64_t bytes_read

Detailed Description

Cursor over a CoMPASS binary file.

Reads the two-byte global header on open, then decodes one event per ReadEvent() into a reused CoMPASSData.

Definition at line 253 of file BinaryUtils.hpp.

Constructor & Destructor Documentation

◆ CoMPASSReader()

CoMPASSReader::CoMPASSReader ( )
inline

Construct a reader with no file open.

Definition at line 260 of file BinaryUtils.hpp.

◆ ~CoMPASSReader()

virtual CoMPASSReader::~CoMPASSReader ( )
inlinevirtual

Definition at line 262 of file BinaryUtils.hpp.

Member Function Documentation

◆ GetCurrentEvent() [1/2]

CoMPASSData & CoMPASSReader::GetCurrentEvent ( )
inline

Mutable access to the event most recently read.

Returns
A reference valid only until the next ReadEvent().

Definition at line 306 of file BinaryUtils.hpp.

◆ GetCurrentEvent() [2/2]

const CoMPASSData & CoMPASSReader::GetCurrentEvent ( ) const
inline

The event most recently read.

Returns
A reference valid only until the next ReadEvent().

Definition at line 303 of file BinaryUtils.hpp.

Referenced by InitUtils::ConvertCoMPASSBinToHits(), and InitUtils::ConvertCoMPASSBinToROOT().

◆ GetGlobalHeader()

UShort_t CoMPASSReader::GetGlobalHeader ( ) const
inline

The global header in force, read from the file or overridden.

Definition at line 309 of file BinaryUtils.hpp.

Referenced by InitUtils::ConvertCoMPASSBinToHits(), and InitUtils::ConvertCoMPASSBinToROOT().

◆ Open() [1/2]

Bool_t CoMPASSReader::Open ( const char * fname)
overridevirtual

Open a file and read its global header.

Parameters
fnamePath to the CoMPASS binary file.
Returns
kTRUE on success.

Reimplemented from BinaryReader.

Definition at line 149 of file BinaryUtils.cpp.

Referenced by InitUtils::ConvertCoMPASSBinToHits(), and InitUtils::ConvertCoMPASSBinToROOT().

◆ Open() [2/2]

Bool_t CoMPASSReader::Open ( const char * fname,
UShort_t header_override )

Open a file, assuming a given global header.

For files whose two-byte header is missing or wrong. Passing an override also suppresses the two-byte header skip, since there is nothing to skip.

Parameters
fnamePath to the CoMPASS binary file.
header_overrideHeader word to assume. Must be non-zero.
Returns
kTRUE on success.

Definition at line 167 of file BinaryUtils.cpp.

◆ ReadEvent()

Bool_t CoMPASSReader::ReadEvent ( )
overridevirtual

Decode the next event into the current-event object.

Returns
kTRUE if an event was read; kFALSE at end of file or on a malformed record.

Decode the next event into the current-event object.

Returns
kTRUE if an event was read; kFALSE at end of file or on a malformed record.

Decode the next block into the current-event object.

Returns
kTRUE if a block was read; kFALSE at end of file.
Note
As a memory-safety measure, a block claiming more than 100 000 samples is treated as corrupt and its trace payload is skipped.

Implements BinaryReader.

Definition at line 198 of file BinaryUtils.cpp.

Referenced by InitUtils::ConvertCoMPASSBinToHits(), and InitUtils::ConvertCoMPASSBinToROOT().


The documentation for this class was generated from the following files: