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
9
10#include "CbmTbDaqBuffer.h"
11
12#include <Logger.h> // for Logger, LOG
13
14#include <boost/any.hpp>
15
16#include <cstddef> // for NULL
17#include <iomanip> // for setprecision, __iom_t5
18#include <sstream> // for basic_stringstream<>::string_type
19
20// ----- Initialisation of static variables ------------------------------
22// ---------------------------------------------------------------------------
23
24
25// ----- Constructor -----------------------------------------------------
27// ---------------------------------------------------------------------------
28
29
30// ----- Destructor ------------------------------------------------------
32// ---------------------------------------------------------------------------
33
35{
36 if (!GetSize()) return -1.;
37 // Return the key from the first element in the map
38 // The key of the map is the time of digi
39 return fData.begin()->first;
40}
41
43{
44 if (!GetSize()) return -1.;
45 // Return the key from the last element in the map
46 // The key of the map is the time of digi
47 return (--fData.end())->first;
48}
49
50// ----- Access to next data ---------------------------------------------
52{
53
54 // --- Check for empty buffer
55 if (!fData.size()) return std::make_pair(boost::any(), ECbmModuleId::kNotExist);
56
57 // --- Get data from buffer
58 std::multimap<Double_t, std::pair<boost::any, ECbmModuleId>>::iterator it = fData.begin();
59 Double_t digi_time = it->first;
60
61 if (digi_time < time) {
62 boost::any digi = it->second.first;
63 ECbmModuleId sysID = it->second.second;
64 fData.erase(it);
65 return std::make_pair(digi, sysID);
66 }
67 return std::make_pair(boost::any(), ECbmModuleId::kNotExist);
68}
69// ---------------------------------------------------------------------------
70
71// ----- Instance --------------------------------------------------------
77// ---------------------------------------------------------------------------
78
79// ----- Print status ----------------------------------------------------
81{
82 Int_t size = GetSize();
83 std::stringstream ss;
84 ss << "CbmTbDaqBuffer: Status ";
85 if (!size) {
86 LOG(info) << ss.str() << "empty";
87 return;
88 }
89 LOG(info) << ss.str() << GetSize() << " digis from " << std::fixed << std::setprecision(9) << GetTimeFirst() * 1.e-9
90 << " s to " << GetTimeLast() * 1.e-9 << " s";
91}
92// ---------------------------------------------------------------------------
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kNotExist
If not found.
Definition CbmDefs.h:68
static constexpr size_t size()
Definition KfSimdPseudo.h:2
int Int_t
Singleton buffer class for CBM raw data.
Double_t GetTimeLast() const
Data GetNextData(Double_t time)
std::multimap< Double_t, Data > fData
static CbmTbDaqBuffer * Instance()
Int_t GetSize() const
void PrintStatus() const
Double_t GetTimeFirst() const
static CbmTbDaqBuffer * fgInstance
std::pair< boost::any, ECbmModuleId > Data