R3BROOT
R3B analysis software
Toggle main menu visibility
Loading...
Searching...
No Matches
Mille.h
Go to the documentation of this file.
1
#pragma once
2
#include "
MilleEntry.h
"
3
#include <cstddef>
4
#include <cstdint>
5
#include <fstream>
6
#include <string_view>
7
#include <utility>
8
#include <vector>
9
10
namespace
R3B
11
{
12
constexpr
auto
DEFAULT_BUFFER_SIZE
= std::size_t{ 10000 };
13
template
<
typename
IndexType =
int
,
typename
ValueType =
float
>
14
class
MilleBuffer
15
{
16
public
:
17
MilleBuffer
() =
default
;
18
void
clear
()
19
{
20
index_buffer_
.clear();
21
value_buffer_
.clear();
22
}
23
auto
get_current_size
() -> std::size_t {
return
index_buffer_
.size() +
value_buffer_
.size(); }
24
inline
void
add_entry
(IndexType index, ValueType value)
// NOLINT
25
{
26
index_buffer_
.emplace_back(index);
27
value_buffer_
.emplace_back(value);
28
}
29
auto
is_empty
() ->
bool
{
return
get_current_size
() == 0; }
30
31
auto
get_indices
() ->
const
auto
& {
return
index_buffer_
; }
32
auto
get_values
() ->
const
auto
& {
return
value_buffer_
; }
33
34
private
:
35
std::vector<IndexType>
index_buffer_
;
// buffer to store local and global indices
36
std::vector<ValueType>
value_buffer_
;
// buffer to store local and global derivatives
37
};
38
39
class
Mille
40
{
41
public
:
42
explicit
Mille
(std::string_view outFileName,
bool
asBinary =
true
,
bool
writeZero =
false
);
43
void
set_buffer_size
(std::size_t buffer_size) {
max_buffer_size_
= buffer_size; }
44
60
void
mille
(
const
MilleDataPoint
& data_point);
61
void
special
(
const
std::vector<std::pair<int, float>>& special_data);
62
void
reset
();
63
71
void
end
();
72
void
close
();
73
74
auto
get_n_entries
() const -> uint64_t {
return
num_of_entries_
; }
75
76
private
:
77
bool
has_special_done_
=
false
;
78
bool
is_binary_
=
true
;
79
bool
is_zero_written_
=
false
;
80
MilleBuffer<int, float>
buffer_
;
81
std::size_t
max_buffer_size_
=
DEFAULT_BUFFER_SIZE
;
82
std::ofstream
output_file_
;
83
uint64_t
num_of_entries_
= 0;
84
85
static
constexpr
unsigned
int
max_label_size_
= (0xFFFFFFFF - (1U << 31U));
86
87
void
check_buffer_size
(std::size_t nLocal, std::size_t nGlobal);
88
void
write_to_binary
();
89
void
write_to_non_binary
();
90
};
91
}
// namespace R3B
MilleEntry.h
R3B::MilleBuffer
Definition
Mille.h:15
R3B::MilleBuffer::value_buffer_
std::vector< ValueType > value_buffer_
Definition
Mille.h:36
R3B::MilleBuffer::is_empty
auto is_empty() -> bool
Definition
Mille.h:29
R3B::MilleBuffer::add_entry
void add_entry(IndexType index, ValueType value)
Definition
Mille.h:24
R3B::MilleBuffer::get_indices
auto get_indices() -> const auto &
Definition
Mille.h:31
R3B::MilleBuffer::get_current_size
auto get_current_size() -> std::size_t
Definition
Mille.h:23
R3B::MilleBuffer::clear
void clear()
Definition
Mille.h:18
R3B::MilleBuffer::get_values
auto get_values() -> const auto &
Definition
Mille.h:32
R3B::MilleBuffer::index_buffer_
std::vector< IndexType > index_buffer_
Definition
Mille.h:35
R3B::MilleBuffer::MilleBuffer
MilleBuffer()=default
R3B::Mille::write_to_non_binary
void write_to_non_binary()
Definition
Mille.cxx:142
R3B::Mille::get_n_entries
auto get_n_entries() const -> uint64_t
Definition
Mille.h:74
R3B::Mille::has_special_done_
bool has_special_done_
if true, special(..) already called for this record
Definition
Mille.h:77
R3B::Mille::mille
void mille(const MilleDataPoint &data_point)
Write the MilleDataPoint structure to the internal data buffer of the type MilleBuffer.
Definition
Mille.cxx:55
R3B::Mille::check_buffer_size
void check_buffer_size(std::size_t nLocal, std::size_t nGlobal)
Definition
Mille.cxx:156
R3B::Mille::Mille
Mille(std::string_view outFileName, bool asBinary=true, bool writeZero=false)
Definition
Mille.cxx:42
R3B::Mille::close
void close()
Definition
Mille.cxx:155
R3B::Mille::output_file_
std::ofstream output_file_
C-binary for output.
Definition
Mille.h:82
R3B::Mille::is_binary_
bool is_binary_
if false output as text
Definition
Mille.h:78
R3B::Mille::max_label_size_
static constexpr unsigned int max_label_size_
Definition
Mille.h:85
R3B::Mille::max_buffer_size_
std::size_t max_buffer_size_
Maximum size of the data buffer.
Definition
Mille.h:81
R3B::Mille::is_zero_written_
bool is_zero_written_
if true also write out derivatives/labels ==0
Definition
Mille.h:79
R3B::Mille::write_to_binary
void write_to_binary()
Definition
Mille.cxx:132
R3B::Mille::reset
void reset()
Definition
Mille.cxx:149
R3B::Mille::set_buffer_size
void set_buffer_size(std::size_t buffer_size)
Definition
Mille.h:43
R3B::Mille::buffer_
MilleBuffer< int, float > buffer_
Data buffer to store the points of the events.
Definition
Mille.h:80
R3B::Mille::special
void special(const std::vector< std::pair< int, float > > &special_data)
Definition
Mille.cxx:97
R3B::Mille::end
void end()
Streaming an entry data to the output file.
Definition
Mille.cxx:121
R3B::Mille::num_of_entries_
uint64_t num_of_entries_
Definition
Mille.h:83
R3B
Definition
R3BNeulandAnalysisApp.cxx:44
R3B::DEFAULT_BUFFER_SIZE
constexpr auto DEFAULT_BUFFER_SIZE
Definition
Mille.h:12
R3B::MilleDataPoint
Definition
MilleEntry.h:25
neuland
calibration
mille
Mille.h
Generated by
1.18.0