Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PayLoadSG.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PayLoadSG.h
1
// @file PayLoadSG.h
2
// @brief Declaration of class for scatter-gather buffer
3
// @author ruben.shahoyan@cern.ch
4
// @sa <O2/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PayLoadSG.h>
5
// <1c31a8d52>
6
7
#ifndef MVTXDECODER_PAYLOADSG_H
8
#define MVTXDECODER_PAYLOADSG_H
9
10
#include <cstdint>
11
#include <vector>
12
13
namespace
mvtx
14
{
15
16
class
PayLoadSG
17
{
18
// scatter-gather buffer for the payload: base pointer + vector of references for pieces to collect
19
public
:
20
21
PayLoadSG
() =
default
;
22
~PayLoadSG
() =
default
;
23
25
void
add
(
size_t
n
,
bool
err
)
26
{
27
if
(n)
28
{
29
mBuffer
.emplace_back(n, err);
30
}
31
}
32
34
void
rewind
()
35
{
36
mCurrentPieceId
= 0;
37
}
38
40
void
clear
()
41
{
42
mBuffer
.clear();
43
mCurrentPieceId
= 0;
44
}
45
46
struct
SGPiece
47
{
48
uint32_t
size
= 0;
// size of the piece
49
bool
hasError
=
false
;
50
SGPiece
() =
default
;
51
SGPiece
(
int
n
,
bool
err
) :
size
(n),
hasError
(err) {}
52
};
53
54
void
setDone
() {
mCurrentPieceId
=
mBuffer
.size(); }
55
56
size_t
&
currentPieceId
() {
return
mCurrentPieceId
; }
57
size_t
currentPieceId
()
const
{
return
mCurrentPieceId
; }
58
59
const
SGPiece
*
currentPiece
()
const
{
return
mCurrentPieceId
<
mBuffer
.size() ? &
mBuffer
[
mCurrentPieceId
] :
nullptr
; }
60
61
const
SGPiece
*
nextPiece
()
62
{
63
// move to the next piece
64
mCurrentPieceId
++;
65
return
currentPiece
();
66
}
67
68
const
SGPiece
*
getPiece
(
int
i
)
const
{
return
&
mBuffer
[
i
]; }
69
70
size_t
getNPieces
()
const
{
return
mBuffer
.size(); }
71
72
private
:
73
std::vector<SGPiece>
mBuffer
;
// list of pieces to fetch
74
size_t
mCurrentPieceId
= 0;
// current piece
75
76
//ClassDefNV(PayLoadSG, 1);
77
};
78
79
}
// namespace mvtx
80
81
#endif
online_distribution
blob
master
newbasic
mvtx_decoder
PayLoadSG.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration