22 #ifndef HRIBF_BUFFERS_H 23 #define HRIBF_BUFFERS_H 28 #define HRIBF_BUFFERS_VERSION "1.3.00" 29 #define HRIBF_BUFFERS_DATE "Sept. 19th, 2016" 31 #define ACTUAL_BUFF_SIZE 8194 43 BufferType(
unsigned int bufftype_,
unsigned int buffsize_,
unsigned int buffend_=0xFFFFFFFF);
46 virtual bool Write(std::ofstream *file_);
49 virtual bool Read(std::ifstream *file_);
88 unsigned int GetBufferLength();
106 void SetStartDateTime();
108 void SetEndDateTime();
110 void SetFacility(std::string input_);
112 void SetTitle(std::string input_);
116 void SetMaxSpillSize(
unsigned int max_spill_size_){ max_spill_size = max_spill_size_; }
122 virtual bool Write(std::ofstream *file_);
125 virtual bool Read(std::ifstream *file_);
128 virtual void Reset();
134 void PrintDelimited(
const char &delimiter_=
'\t');
145 virtual bool Write(std::ofstream *file_,
char *data_,
unsigned int nWords_);
148 virtual bool Read(std::ifstream *file_,
char *data_,
unsigned int &nBytes,
unsigned int max_bytes_,
bool dry_run_mode=
false);
174 virtual bool Write(std::ofstream *file_);
177 virtual bool Read(std::ifstream *file_);
180 virtual void Reset();
186 void PrintDelimited(
const char &delimiter_=
'\t');
217 bool SetTitle(std::string input_);
224 virtual bool Write(std::ofstream *file_);
227 virtual bool Read(std::ifstream *file_);
230 virtual void Reset();
236 void PrintDelimited(
const char &delimiter_=
'\t');
259 bool open_(std::ofstream *file_);
261 bool read_next_buffer(std::ifstream *f_,
bool force_=
false);
267 bool Close(std::ofstream *file_);
272 int GetSpillSize(std::ifstream *file_);
292 virtual bool Write(std::ofstream *file_,
char *data_,
unsigned int nWords_,
int &buffs_written);
295 virtual bool Read(std::ifstream *file_,
char *data_,
unsigned int &nBytes_,
unsigned int max_bytes_,
bool &full_spill,
bool &bad_spill,
bool dry_run_mode=
false);
298 virtual void Reset();
307 virtual bool Write(std::ofstream *file_);
310 virtual bool Read(std::ifstream *file_);
340 std::string get_filename();
343 bool get_full_filename(std::string &output);
348 bool overwrite_dir(
int total_buffers_=-1);
391 bool SetFileFormat(
unsigned int format_);
394 void SetFilenamePrefix(std::string filename_);
397 bool IsOpen(){
return (output_file.is_open() && output_file.good()); }
400 int Write(
char *data_,
unsigned int nWords_);
404 int SendPacket(
Client *cli_);
407 bool OpenNewFile(std::string title_,
unsigned int &run_num_, std::string prefix, std::string output_dir=
"./",
bool continueRun =
false);
409 std::string GetNextFileName(
unsigned int &run_num_, std::string prefix, std::string output_dir,
bool continueRun =
false);
411 unsigned int GetRunNumber();
414 void CloseFile(
float total_run_time_=0.0);
unsigned int good_chunks
Total size of ldf buffer (in 4 byte words).
unsigned int GetBufferEndFlag()
unsigned int GetRunNumber()
virtual bool Read(std::ifstream *file_)
Returns only false if not overloaded.
virtual bool Write(std::ofstream *file_)
Returns only false if not overloaded.
void SetRunNumber(unsigned int input_)
std::string current_full_filename
unsigned int current_file_num
unsigned int GetBufferSize()
std::string current_directory
unsigned int buff_head
The total number of ldf buffers read from file.
unsigned int buff_size
The ldf buffer header ID.
unsigned int GetRunNumber()
HEAD_buffer * GetHEADbuffer()
Return a pointer to the HEAD buffer object.
unsigned int buff_pos
Count of the number of missing spill chunks which were dropped.
unsigned int total_buff_size
std::vector< std::string > directories
unsigned int GetNumChunks()
Return the number of good spill chunks which were read.
unsigned int output_format
DATA_buffer * GetDATAbuffer()
Return a pointer to the DATA buffer object.
unsigned int max_spill_size
A single EOF buffer signals the end of a run (pacman .ldf format). A double EOF signals the end of th...
EOF_buffer * GetEOFbuffer()
Return a pointer to the EOF buffer object.
unsigned int missing_chunks
Count of the number of good spill chunks which were read.
unsigned int GetNumMissing()
Return the number of missing or dropped spill chunks.
void SetDebugMode(bool debug_=true)
DIR_buffer * GetDIRbuffer()
Return a pointer to the DIR buffer object.
std::ofstream output_file
unsigned int GetBufferType()
unsigned int bcount
Pointer to the next ldf buffer.
unsigned int number_spills
virtual void Reset()
Does nothing if not overloaded.
std::string GetCurrentFilename()
Get the name of the current output file.
virtual void Reset()
Set initial values.
PLD_header * GetPLDheader()
Return a pointer to the PLD header object.
BufferType(unsigned int bufftype_, unsigned int buffsize_, unsigned int buffend_=0xFFFFFFFF)
Generic BufferType constructor.
PLD_data * GetPLDdata()
Return a pointer to the PLD data object.
std::string current_filename
unsigned int * next_buffer
Pointer to the current ldf buffer.
unsigned int current_depth
unsigned int GetNumberSpills()
Return the total number of spills written since the current file was opened.
void SetRunNumber(unsigned int input_)
unsigned int GetTotalBufferSize()
bool ReadHeader(std::ifstream *file_)
Return true if the first word of the current buffer is equal to this buffer type. ...
bool IsOpen()
Return true if an output file is open and writable and false otherwise.
std::streampos GetFilesize()
Get the size of the current file, in bytes.
virtual void Reset()
Set initial values.
The DATA buffer contains all physics data within the .pld file.
unsigned int * curr_buffer
Container for a second ldf buffer.