Skip to content

Commit 9d27688

Browse files
authored
DPL Analysis: simple marker column template (#8783)
1 parent 4aaa476 commit 9d27688

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,36 @@ struct IndexColumn {
381381
static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
382382
};
383383

384+
template <typename INHERIT>
385+
struct MarkerColumn {
386+
using inherited_t = INHERIT;
387+
388+
using persistent = std::false_type;
389+
static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
390+
};
391+
392+
template <size_t M = 0>
393+
struct Marker : o2::soa::MarkerColumn<Marker<M>> {
394+
using type = size_t;
395+
using base = o2::soa::MarkerColumn<Marker<M>>;
396+
constexpr inline static auto value = M;
397+
398+
Marker() = default;
399+
Marker(Marker const&) = default;
400+
Marker(Marker&&) = default;
401+
402+
Marker& operator=(Marker const&) = default;
403+
Marker& operator=(Marker&&) = default;
404+
405+
Marker(arrow::ChunkedArray const*) {}
406+
constexpr inline auto mark()
407+
{
408+
return value;
409+
}
410+
411+
static constexpr const char* mLabel = "Marker";
412+
};
413+
384414
template <int64_t START = 0, int64_t END = -1>
385415
struct Index : o2::soa::IndexColumn<Index<START, END>> {
386416
using base = o2::soa::IndexColumn<Index<START, END>>;

Framework/Core/test/test_ASoA.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ DECLARE_SOA_EXPRESSION_COLUMN(ESum, esum, int32_t, test ::x + test::y);
4141
DECLARE_SOA_TABLE(Points, "TST", "POINTS", test::X, test::Y);
4242
DECLARE_SOA_TABLE(Points3Ds, "TST", "PTS3D", o2::soa::Index<>, test::X, test::Y, test::Z);
4343

44+
DECLARE_SOA_TABLE(Points3DsMk1, "TST", "PTS3D_1", o2::soa::Index<>, o2::soa::Marker<1>, test::X, test::Y, test::Z);
45+
DECLARE_SOA_TABLE(Points3DsMk2, "TST", "PTS3D_2", o2::soa::Index<>, o2::soa::Marker<2>, test::X, test::Y, test::Z);
46+
DECLARE_SOA_TABLE(Points3DsMk3, "TST", "PTS3D_3", o2::soa::Index<>, o2::soa::Marker<3>, test::X, test::Y, test::Z);
47+
4448
namespace test
4549
{
4650
DECLARE_SOA_COLUMN_FULL(SomeBool, someBool, bool, "someBool");
@@ -69,6 +73,24 @@ DECLARE_SOA_COLUMN(L2, l2, std::vector<int>);
6973

7074
DECLARE_SOA_TABLE(Lists, "TST", "LISTS", o2::soa::Index<>, test::L1, test::L2);
7175

76+
BOOST_AUTO_TEST_CASE(TestMarkers)
77+
{
78+
TableBuilder b1;
79+
auto pwriter = b1.cursor<Points3Ds>();
80+
for (auto i = 0; i < 20; ++i) {
81+
pwriter(0, -1 * i, (int)(i / 2), 2 * i);
82+
}
83+
auto t1 = b1.finalize();
84+
85+
auto pt = Points3Ds{t1};
86+
auto pt1 = Points3DsMk1{t1};
87+
auto pt2 = Points3DsMk2{t1};
88+
auto pt3 = Points3DsMk3{t1};
89+
BOOST_REQUIRE_EQUAL(pt1.begin().mark(), (size_t)1);
90+
BOOST_REQUIRE_EQUAL(pt2.begin().mark(), (size_t)2);
91+
BOOST_REQUIRE_EQUAL(pt3.begin().mark(), (size_t)3);
92+
}
93+
7294
BOOST_AUTO_TEST_CASE(TestTableIteration)
7395
{
7496
TableBuilder builder;

0 commit comments

Comments
 (0)