readWDpp
Read binary files from DRS and WDB
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
DAQFile Class Reference

Class to manage the file and the outputing of data in a DAQEvent instance. More...

#include <readWD.hh>

Public Member Functions

 DAQFile ()
 Construct a new DAQFile::DAQFile object.
 
 DAQFile (const std::string &)
 
DAQFileClose ()
 Method to close the file.
 
DAQFileOpen (const std::string &)
 Method to open a file given the file path and name.
 
DAQFileReset ()
 Method to reset the file.
 
DAQFileGetEvent (int)
 Method to select what event must be read next.
 
bool operator>> (DRSEvent &)
 Read into a DRSEvent.
 
bool operator>> (WDBEvent &)
 Read into a WDBEvent.
 
const MAPGetTimeMap ()
 

Private Types

using MAP = std::map< int, std::map< int, std::vector< float > > >
 Alias for data structure.
 

Private Member Functions

DAQFileInitialise ()
 Initialise the file reading the TIME block.
 
bool operator>> (TAG &)
 Read into a TAG.
 
bool operator>> (EventHeader &)
 Read into a EventHeader.
 
 operator bool ()
 The evaluation of boolean for the class DAQFile.
 
void Read (TAG &)
 Read a tag.
 
void Read (EventHeader &)
 Read an event header.
 
void Read (std::vector< float > &)
 
void Read (std::vector< float > &, const unsigned short &)
 
void ResetTag ()
 

Private Attributes

std::string filename_
 The name of the file.
 
std::ifstream in_
 The input file to read.
 
char o_
 The initial letter of the previous tag read.
 
char n_
 The initial letter of the newest tag read.
 
bool initialization_
 Flag to store if DAQFile::Initialise() was already called.
 
MAP times_
 Struct to hold \( \Delta t\) read from the TIMEpart of the file.
 
bool is_lab_
 Flag to check if the board is from LAB or not.
 
std::string type_
 Flag to store the type of the board.
 
int first_evt_pos_
 Position of first event header.
 

Friends

class DAQConfig
 

Detailed Description

Class to manage the file and the outputing of data in a DAQEvent instance.

Examples
main0.cc, main1.cc, and main3.cc.

Definition at line 213 of file readWD.hh.

Member Typedef Documentation

◆ MAP

using DAQFile::MAP = std::map<int, std::map<int, std::vector<float> >>
private

Alias for data structure.

Definition at line 215 of file readWD.hh.

Constructor & Destructor Documentation

◆ DAQFile()

DAQFile::DAQFile ( )

Construct a new DAQFile::DAQFile object.

Definition at line 1057 of file readWD.cc.

◆ ~DAQFile()

DAQFile::~DAQFile ( )
inline

Definition at line 220 of file readWD.hh.

Member Function Documentation

◆ Close()

DAQFile & DAQFile::Close ( )

Method to close the file.

Returns
DAQFile&
Examples
main3.cc.

Definition at line 1168 of file readWD.cc.

◆ GetEvent()

DAQFile & DAQFile::GetEvent ( int  evt_id)

Method to select what event must be read next.

If the user wants to look at one specific event, given the event serial nuber, this method will bring the file to the exact location of that event. A print of the found event header is performed to double check. The method does some checks on file boundaries, event size and file integrity. Then file >> event must be called to read the selected event.

Parameters
evt_idThe event serial number. The method considers the different numbering system between DRS (events start from 1) and WDB (events start from 0).
Returns
DAQFile&

Definition at line 1234 of file readWD.cc.

◆ GetTimeMap()

const MAP & DAQFile::GetTimeMap ( )
inline

Definition at line 231 of file readWD.hh.

◆ Initialise()

DAQFile & DAQFile::Initialise ( )
private

Initialise the file reading the TIME block.

Returns
DAQFile&

Definition at line 1084 of file readWD.cc.

◆ Open()

DAQFile & DAQFile::Open ( const std::string &  )

Method to open a file given the file path and name.

Parameters
fname
Returns
DAQFile&
Examples
main3.cc.

Definition at line 1188 of file readWD.cc.

◆ operator bool()

DAQFile::operator bool ( )
private

The evaluation of boolean for the class DAQFile.

This method evaluates all the valid possible combinations of consecutive tags to determine if the value to return is 1 or 0. It uses the same principle of a finite state machine with the usage of a map named header, where the combinations of key-value match the possible configurations of consecutive non-equal tags that can be found in the binary file.

Returns
true
false

Definition at line 1523 of file readWD.cc.

◆ operator>>() [1/4]

bool DAQFile::operator>> ( DRSEvent event)

Read into a DRSEvent.

This method reads exactly one event from the file to de DRSEvent class. A first check is made to check if the DAQConfig class has been initialised, otherwise a call to DAQEvent::MakeConfig() is made. In the nested while two things are done, the former is to ignore the time scaler if the DRS board is of type LAB-DRS (see The Binary Output), the latter is to read and convert volts and to perform a time calibration. These data are stored in the DAQEvent::times_ and DAQEvent::volts_ maps.

Parameters
event
Returns
true
false

Definition at line 1329 of file readWD.cc.

◆ operator>>() [2/4]

bool DAQFile::operator>> ( EventHeader eh)
private

Read into a EventHeader.

Parameters
eh
Returns
true
false

Definition at line 1308 of file readWD.cc.

◆ operator>>() [3/4]

bool DAQFile::operator>> ( TAG t)
private

Read into a TAG.

Parameters
t
Returns
true
false

Definition at line 1291 of file readWD.cc.

◆ operator>>() [4/4]

bool DAQFile::operator>> ( WDBEvent event)

Read into a WDBEvent.

This method reads exactly one event from the file to de WDBEvent class. A first check is made to check if the DAQConfig class has been initialised, otherwise a call to DAQEvent::MakeConfig() is made. In the nested while volts are read and converted, then a time calibration is performed. These data are stored in the DAQEvent::times_ and DAQEvent::volts_ maps.

Parameters
event
Returns
true
false

Definition at line 1400 of file readWD.cc.

◆ Read() [1/2]

void DAQFile::Read ( EventHeader eh)
private

Read an event header.

Parameters
eh

Definition at line 1474 of file readWD.cc.

◆ Read() [2/2]

void DAQFile::Read ( TAG t)
private

Read a tag.

Parameters
t

Definition at line 1462 of file readWD.cc.

◆ Reset()

DAQFile & DAQFile::Reset ( )

Method to reset the file.

This method checks for file initialisation, in case it is not a warning is printed on screen. Otherwise the file goes back to first event header.

Returns
DAQFile&

Definition at line 1213 of file readWD.cc.

◆ ResetTag()

void DAQFile::ResetTag ( )
inlineprivate

Definition at line 243 of file readWD.hh.

Friends And Related Symbol Documentation

◆ DAQConfig

friend class DAQConfig
friend

Definition at line 255 of file readWD.hh.

Member Data Documentation

◆ filename_

std::string DAQFile::filename_
private

The name of the file.

Definition at line 245 of file readWD.hh.

◆ first_evt_pos_

int DAQFile::first_evt_pos_
private

Position of first event header.

Definition at line 253 of file readWD.hh.

◆ in_

std::ifstream DAQFile::in_
private

The input file to read.

Definition at line 246 of file readWD.hh.

◆ initialization_

bool DAQFile::initialization_
private

Flag to store if DAQFile::Initialise() was already called.

Definition at line 249 of file readWD.hh.

◆ is_lab_

bool DAQFile::is_lab_
private

Flag to check if the board is from LAB or not.

Definition at line 251 of file readWD.hh.

◆ n_

char DAQFile::n_
private

The initial letter of the newest tag read.

Definition at line 248 of file readWD.hh.

◆ o_

char DAQFile::o_
private

The initial letter of the previous tag read.

Definition at line 247 of file readWD.hh.

◆ times_

MAP DAQFile::times_
private

Struct to hold \( \Delta t\) read from the TIMEpart of the file.

Definition at line 250 of file readWD.hh.

◆ type_

std::string DAQFile::type_
private

Flag to store the type of the board.

Definition at line 252 of file readWD.hh.


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