Project
Loading...
Searching...
No Matches
test_TableSpawner.cxx
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#include <catch_amalgamated.hpp>
14
17
18using namespace o2::framework;
19using namespace o2::soa;
20using namespace o2::aod;
21
22namespace o2::aod
23{
24namespace test
25{
26DECLARE_SOA_COLUMN(X, x, float);
27DECLARE_SOA_COLUMN(Y, y, float);
28DECLARE_SOA_COLUMN(Z, z, float);
29DECLARE_SOA_EXPRESSION_COLUMN(Rsq, rsq, float, test::x* test::x + test::y * test::y + test::z * test::z);
30DECLARE_SOA_EXPRESSION_COLUMN(Sin, sin, float, test::x / nsqrt(test::x * test::x + test::y * test::y));
31} // namespace test
32
33DECLARE_SOA_TABLE(Points, "AOD", "PTSNG", test::X, test::Y, test::Z);
34DECLARE_SOA_EXTENDED_TABLE(ExPoints, Points, "EXPTSNG", 0, test::Rsq, test::Sin);
35} // namespace o2::aod
36
37TEST_CASE("TestTableSpawner")
38{
40 auto w1 = b1.cursor<Points>();
41
42 for (auto i = 1; i < 10; ++i) {
43 w1(0, i * 2., i * 3., i * 4.);
44 }
45
46 auto t1 = b1.finalize();
47 Points st1{t1};
48
49 auto expoints_a = o2::soa::Extend<o2::aod::Points, test::Rsq, test::Sin>(st1);
50 auto extension = ExPointsExtension{o2::framework::spawner<o2::aod::Hash<"EXPTSNG/0"_h>>(t1, o2::aod::Hash<"ExPoints"_h>::str)};
51 auto expoints = ExPoints{{t1, extension.asArrowTable()}, 0};
52
53 REQUIRE(expoints_a.size() == 9);
54 REQUIRE(extension.size() == 9);
55 REQUIRE(expoints.size() == 9);
56
57 auto rex = extension.begin();
58 auto rexp = expoints.begin();
59 auto rexp_a = expoints_a.begin();
60
61 for (auto i = 1; i < 10; ++i) {
62 float rsq = i * i * 4 + i * i * 9 + i * i * 16;
63 float sin = i * 2 / std::sqrt(i * i * 4 + i * i * 9);
64 REQUIRE(rexp_a.rsq() == rsq);
65 REQUIRE(rex.rsq() == rsq);
66 REQUIRE(rexp.rsq() == rsq);
67 REQUIRE(rexp_a.sin() == sin);
68 REQUIRE(rex.sin() == sin);
69 REQUIRE(rexp.sin() == sin);
70 ++rex;
71 ++rexp;
72 ++rexp_a;
73 }
74}
#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_,...)
Definition ASoA.h:3052
#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_)
Definition ASoA.h:2388
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
Definition ASoA.h:2314
#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_,...)
Definition ASoA.h:3094
int32_t i
const GPUTPCGMMerger::trackCluster & b1
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition glcorearb.h:5034
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
TEST_CASE("test_prepareArguments")
auto spawner(std::vector< std::shared_ptr< arrow::Table > > &&tables, const char *name)
Expression-based column generator to materialize columns.
FIXME: do not use data model tables.
const std::string str