CbmRoot
Loading...
Searching...
No Matches
CbmTbDaqBuffer.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2013-2020 PI-UHd, GSI
2
SPDX-License-Identifier: GPL-3.0-only
3
Authors: Volker Friese, Norbert Herrmann [committer] */
4
10
#include "
CbmTbDaqBuffer.h
"
11
12
#include <Logger.h>
// for Logger, LOG
13
14
#include <boost/any.hpp>
15
16
#include <iomanip>
// for setprecision, __iom_t5
17
#include <sstream>
// for basic_stringstream<>::string_type
18
19
#include <stddef.h>
// for NULL
20
21
// ----- Initialisation of static variables ------------------------------
22
CbmTbDaqBuffer
*
CbmTbDaqBuffer::fgInstance
=
nullptr
;
23
// ---------------------------------------------------------------------------
24
25
26
// ----- Constructor -----------------------------------------------------
27
CbmTbDaqBuffer::CbmTbDaqBuffer
() : fData() {}
28
// ---------------------------------------------------------------------------
29
30
31
// ----- Destructor ------------------------------------------------------
32
CbmTbDaqBuffer::~CbmTbDaqBuffer
() {}
33
// ---------------------------------------------------------------------------
34
35
Double_t
CbmTbDaqBuffer::GetTimeFirst
()
const
36
{
37
if
(!
GetSize
())
return
-1.;
38
// Return the key from the first element in the map
39
// The key of the map is the time of digi
40
return
fData
.begin()->first;
41
}
42
43
Double_t
CbmTbDaqBuffer::GetTimeLast
()
const
44
{
45
if
(!
GetSize
())
return
-1.;
46
// Return the key from the last element in the map
47
// The key of the map is the time of digi
48
return
(--
fData
.end())->first;
49
}
50
51
// ----- Access to next data ---------------------------------------------
52
CbmTbDaqBuffer::Data
CbmTbDaqBuffer::GetNextData
(Double_t time)
53
{
54
55
// --- Check for empty buffer
56
if
(!
fData
.size())
return
std::make_pair(boost::any(),
ECbmModuleId::kNotExist
);
57
58
// --- Get data from buffer
59
std::multimap<Double_t, std::pair<boost::any, ECbmModuleId>>::iterator it =
fData
.begin();
60
Double_t digi_time = it->first;
61
62
if
(digi_time < time) {
63
boost::any digi = it->second.first;
64
ECbmModuleId
sysID = it->second.second;
65
fData
.erase(it);
66
return
std::make_pair(digi, sysID);
67
}
68
return
std::make_pair(boost::any(),
ECbmModuleId::kNotExist
);
69
}
70
// ---------------------------------------------------------------------------
71
72
// ----- Instance --------------------------------------------------------
73
CbmTbDaqBuffer
*
CbmTbDaqBuffer::Instance
()
74
{
75
if
(!
fgInstance
)
fgInstance
=
new
CbmTbDaqBuffer
();
76
return
fgInstance
;
77
}
78
// ---------------------------------------------------------------------------
79
80
// ----- Print status ----------------------------------------------------
81
void
CbmTbDaqBuffer::PrintStatus
()
const
82
{
83
Int_t
size
=
GetSize
();
84
std::stringstream ss;
85
ss <<
"CbmTbDaqBuffer: Status "
;
86
if
(!
size
) {
87
LOG(info) << ss.str() <<
"empty"
;
88
return
;
89
}
90
LOG(info) << ss.str() <<
GetSize
() <<
" digis from "
<< std::fixed << std::setprecision(9) <<
GetTimeFirst
() * 1.e-9
91
<<
" s to "
<<
GetTimeLast
() * 1.e-9 <<
" s"
;
92
}
93
// ---------------------------------------------------------------------------
ECbmModuleId
ECbmModuleId
Definition
CbmDefs.h:39
ECbmModuleId::kNotExist
@ kNotExist
If not found.
CbmTbDaqBuffer.h
size
static constexpr size_t size()
Definition
KfSimdPseudo.h:2
CbmTbDaqBuffer
Singleton buffer class for CBM raw data.
Definition
CbmTbDaqBuffer.h:39
CbmTbDaqBuffer::GetTimeLast
Double_t GetTimeLast() const
Definition
CbmTbDaqBuffer.cxx:43
CbmTbDaqBuffer::CbmTbDaqBuffer
CbmTbDaqBuffer()
Definition
CbmTbDaqBuffer.cxx:27
CbmTbDaqBuffer::GetNextData
Data GetNextData(Double_t time)
Definition
CbmTbDaqBuffer.cxx:52
CbmTbDaqBuffer::fData
std::multimap< Double_t, Data > fData
Definition
CbmTbDaqBuffer.h:89
CbmTbDaqBuffer::Instance
static CbmTbDaqBuffer * Instance()
Definition
CbmTbDaqBuffer.cxx:73
CbmTbDaqBuffer::GetSize
Int_t GetSize() const
Definition
CbmTbDaqBuffer.h:61
CbmTbDaqBuffer::Data
std::pair< boost::any, ECbmModuleId > Data
Definition
CbmTbDaqBuffer.h:41
CbmTbDaqBuffer::PrintStatus
void PrintStatus() const
Definition
CbmTbDaqBuffer.cxx:81
CbmTbDaqBuffer::GetTimeFirst
Double_t GetTimeFirst() const
Definition
CbmTbDaqBuffer.cxx:35
CbmTbDaqBuffer::fgInstance
static CbmTbDaqBuffer * fgInstance
Definition
CbmTbDaqBuffer.h:93
CbmTbDaqBuffer::~CbmTbDaqBuffer
~CbmTbDaqBuffer()
Definition
CbmTbDaqBuffer.cxx:32
MQ
unpacker
CbmTbDaqBuffer.cxx
Generated on Sun Dec 22 2024 23:04:13 for CbmRoot by
1.12.0