Project
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
12
#ifndef ALICEO2_MERGER_TEST_COMMON_H_
13
#define ALICEO2_MERGER_TEST_COMMON_H_
14
15
#include <sstream>
16
#include <gsl/span>
17
#include <TH1.h>
18
#include <
Framework/CallbackService.h
>
19
20
namespace
o2::mergers::test
21
{
22
inline
auto
to_span
(
const
TH1F& histo)
23
{
24
return
gsl::span(histo.GetArray(), histo.GetSize());
25
}
26
27
void
registerCallbacksForTestFailure
(
framework::CallbackService
& cb, std::shared_ptr<bool> success)
28
{
29
cb.
set
<
framework::CallbackService::Id::EndOfStream
>([success](
framework::EndOfStreamContext
& ctx) {
30
if
(*success ==
false
) {
31
LOG
(fatal) <<
"Received an EndOfStream without having received the expected object"
;
32
}
33
});
34
cb.
set
<
framework::CallbackService::Id::Stop
>([success]() {
35
if
(*success ==
false
) {
36
LOG
(fatal) <<
"STOP transition without having received the expected object"
;
37
}
38
});
39
cb.
set
<
framework::CallbackService::Id::ExitRequested
>([success](
framework::ServiceRegistryRef
) {
40
if
(*success ==
false
) {
41
LOG
(fatal) <<
"EXIT transition without having received the expected object"
;
42
}
43
});
44
}
45
46
}
// namespace o2::mergers::test
47
48
namespace
std
49
{
50
51
template
<
typename
T,
size_t
Size>
52
inline
std::string
to_string
(gsl::span<T, Size> span)
53
{
54
std::stringstream ss{};
55
for
(
size_t
i
= 0;
auto
v
: span) {
56
ss <<
v
;
57
if
(++
i
!= span.size()) {
58
ss <<
" "
;
59
}
60
}
61
return
std::move(ss).str();
62
}
63
64
template
<
size_t
Size>
65
inline
std::string
to_string
(
const
std::array<float, Size>& arr)
66
{
67
return
to_string
(gsl::span(arr));
68
}
69
70
inline
std::string
to_string
(
const
TH1F& histo)
71
{
72
return
to_string
(
o2::mergers::test::to_span
(histo));
73
}
74
75
template
<
typename
Deleter>
76
inline
std::string
to_string
(
const
std::unique_ptr<const TH1F, Deleter>& histo_ptr)
77
{
78
return
to_string
(
o2::mergers::test::to_span
(*histo_ptr.get()));
79
}
80
81
template
<
size_t
Size>
82
inline
std::string
to_string
(
const
std::vector<std::array<float, Size>>&
arrays
)
83
{
84
std::string
res
{};
85
for
(
size_t
i
= 0;
const
auto
&
array
:
arrays
) {
86
res
.append(
"["
);
87
res
.append(
to_string
(gsl::span(
array
)));
88
res
.append(
"]"
);
89
}
90
return
res
;
91
}
92
93
template
<
typename
Deleter>
94
inline
std::string
to_string
(
const
std::unique_ptr<
const
std::vector<TObject*>, Deleter>& histos)
95
{
96
std::string
res
{};
97
for
(
size_t
i
= 0;
const
auto
& histo : *histos) {
98
res
.append(
"["
);
99
res
.append(
to_string
(*
dynamic_cast<
TH1F const*
>
(histo)));
100
res
.append(
"]"
);
101
}
102
return
res
;
103
}
104
105
}
// namespace std
106
107
#endif
CallbackService.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:436
res
uint32_t res
Definition
RawData.h:0
o2::framework::CallbackService
Definition
CallbackService.h:35
o2::framework::CallbackService::set
void set(U &&cb)
Definition
CallbackService.h:127
o2::framework::CallbackService::Id::Stop
@ Stop
o2::framework::CallbackService::Id::ExitRequested
@ ExitRequested
Invoked when the device was requested to stop.
o2::framework::CallbackService::Id::EndOfStream
@ EndOfStream
o2::framework::EndOfStreamContext
Definition
EndOfStreamContext.h:22
o2::framework::ServiceRegistryRef
Definition
ServiceRegistryRef.h:21
v
const GLdouble * v
Definition
glcorearb.h:832
array
GLenum array
Definition
glcorearb.h:4274
arrays
const GLuint * arrays
Definition
glcorearb.h:1314
o2::mergers::test
Definition
common.h:21
o2::mergers::test::registerCallbacksForTestFailure
void registerCallbacksForTestFailure(framework::CallbackService &cb, std::shared_ptr< bool > success)
Definition
common.h:27
o2::mergers::test::to_span
auto to_span(const TH1F &histo)
Definition
common.h:22
std
Definition
CcdbObjectInfo.h:121
std::to_string
std::string to_string(gsl::span< T, Size > span)
Definition
common.h:52
LOG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
Utilities
Mergers
test
common.h
Generated on Sun Apr 5 2026 19:34:09 for Project by
1.9.8