Skip to content

Commit 8e0c5cf

Browse files
aalkinktf
authored andcommitted
DPL Analysis: add test for identification concepts
1 parent 21d7d16 commit 8e0c5cf

File tree

3 files changed

+171
-1
lines changed

3 files changed

+171
-1
lines changed

Framework/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ add_executable(o2-test-framework-core
200200
test/test_CompletionPolicy.cxx
201201
test/test_ComputingResourceHelpers.cxx
202202
test/test_ComputingQuotaEvaluator.cxx
203+
test/test_Concepts.cxx
203204
test/test_ControlServiceHelpers.cxx
204205
test/test_ConfigParamStore.cxx
205206
test/test_ConfigParamRegistry.cxx

Framework/Core/include/Framework/ASoA.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ consteval auto intersectOriginals()
175175

176176
namespace o2::soa
177177
{
178+
struct Binding;
179+
178180
template <typename T>
179181
concept not_void = requires { !std::same_as<T, void>; };
180182

@@ -192,7 +194,10 @@ template <typename C>
192194
concept is_self_index_column = not_void<typename C::self_index_t> && std::same_as<typename C::self_index_t, std::true_type>;
193195

194196
template <typename C>
195-
concept is_index_column = !is_self_index_column<C> && (requires { &C::getId; } || requires { &C::getIds; });
197+
concept is_index_column = !is_self_index_column<C> && requires(C c, o2::soa::Binding b) {
198+
{ c.setCurrentRaw(b) } -> std::same_as<bool>;
199+
requires std::same_as<decltype(c.mBinding), o2::soa::Binding>;
200+
};
196201

197202
template <typename C>
198203
using is_external_index_t = typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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 <TH1.h>
13+
#include "Framework/ASoA.h"
14+
#include "Framework/AnalysisDataModel.h"
15+
#include "Framework/Expressions.h"
16+
#include "Framework/AnalysisHelpers.h"
17+
#include "Framework/AnalysisTask.h"
18+
#include "Framework/Condition.h"
19+
#include "SimulationDataFormat/O2DatabasePDG.h"
20+
21+
#include <catch_amalgamated.hpp>
22+
23+
using namespace o2::framework;
24+
using namespace o2::soa;
25+
using namespace o2;
26+
27+
struct P {
28+
void process1(aod::Collisions const&)
29+
{
30+
}
31+
32+
PROCESS_SWITCH(P, process1, "", true);
33+
};
34+
35+
TEST_CASE("IdentificationConcepts")
36+
{
37+
// ASoA
38+
int i;
39+
REQUIRE(not_void<decltype(i)>);
40+
41+
REQUIRE(is_persistent_column<o2::aod::track::CollisionId>);
42+
43+
REQUIRE(is_self_index_column<o2::aod::mcparticle::DaughtersIdSlice>);
44+
45+
REQUIRE(!is_index_column<o2::aod::mcparticle::DaughtersIdSlice>);
46+
REQUIRE(is_index_column<o2::aod::track::CollisionId>);
47+
REQUIRE(is_index_column<o2::aod::indices::CollisionIds>);
48+
49+
REQUIRE(o2::aod::is_aod_hash<o2::aod::Hash<"AOD"_h>>);
50+
REQUIRE(o2::aod::is_origin_hash<o2::aod::Hash<"AOD"_h>>);
51+
52+
REQUIRE(has_parent_t<o2::aod::Track>);
53+
54+
REQUIRE(is_metadata<o2::aod::TracksIUExtensionMetadata>);
55+
56+
REQUIRE(is_metadata_trait<o2::aod::MetadataTrait<o2::aod::Hash<"TRACK/0"_h>>>);
57+
58+
REQUIRE(has_metadata<o2::aod::MetadataTrait<o2::aod::Hash<"TRACK/0"_h>>>);
59+
60+
REQUIRE(has_extension<o2::aod::MetadataTrait<o2::aod::Hash<"EXTRACK/0"_h>>::metadata>);
61+
62+
REQUIRE(is_spawnable_column<o2::aod::track::Pt>);
63+
64+
REQUIRE(is_indexing_column<Index<>>);
65+
66+
REQUIRE(is_dynamic_column<o2::aod::track::Energy<o2::aod::track::Signed1Pt, o2::aod::track::Tgl>>);
67+
68+
REQUIRE(is_marker_column<o2::soa::Marker<1>>);
69+
70+
REQUIRE(is_column<o2::aod::track::Pt>);
71+
REQUIRE(is_column<Index<>>);
72+
REQUIRE(is_column<o2::aod::track::Energy<o2::aod::track::Signed1Pt, o2::aod::track::Tgl>>);
73+
REQUIRE(is_column<o2::soa::Marker<1>>);
74+
75+
REQUIRE(is_table<o2::aod::Collisions>);
76+
77+
REQUIRE(is_iterator<o2::aod::Collision>);
78+
79+
REQUIRE(with_originals<o2::aod::Collisions>);
80+
81+
REQUIRE(with_sources<o2::aod::MetadataTrait<o2::aod::Hash<"MA_RN3_SP/0"_h>>::metadata>);
82+
83+
REQUIRE(with_base_table<o2::aod::Tracks>);
84+
85+
REQUIRE(is_index_table<o2::aod::Run3MatchedSparse>);
86+
87+
Preslice<o2::aod::Tracks> ps = o2::aod::track::collisionId;
88+
REQUIRE(is_preslice<decltype(ps)>);
89+
90+
REQUIRE(has_filtered_policy<soa::Filtered<o2::aod::Tracks>::iterator>);
91+
92+
REQUIRE(is_filtered_iterator<soa::Filtered<o2::aod::Tracks>::iterator>);
93+
94+
REQUIRE(is_filtered_table<soa::Filtered<o2::aod::Tracks>>);
95+
96+
REQUIRE(is_filtered<soa::Filtered<o2::aod::Tracks>::iterator>);
97+
REQUIRE(is_filtered<soa::Filtered<o2::aod::Tracks>>);
98+
99+
REQUIRE(is_not_filtered_table<o2::aod::Collisions>);
100+
101+
REQUIRE(is_join<o2::aod::Tracks>);
102+
103+
auto tl = []() -> SmallGroups<o2::aod::Collisions> { return {std::vector<std::shared_ptr<arrow::Table>>{}, SelectionVector{}, 0}; };
104+
REQUIRE(is_smallgroups<decltype(tl())>);
105+
106+
// AnalysisHelpers
107+
REQUIRE(is_producable<o2::aod::Collisions>);
108+
109+
Produces<o2::aod::Collisions> prod;
110+
REQUIRE(is_produces<decltype(prod)>);
111+
112+
struct : ProducesGroup {
113+
Produces<o2::aod::Collisions> p;
114+
} prodg;
115+
REQUIRE(is_produces_group<decltype(prodg)>);
116+
117+
REQUIRE(is_spawnable<o2::aod::Tracks>);
118+
119+
Spawns<o2::aod::Tracks> spw;
120+
REQUIRE(is_spawns<decltype(spw)>);
121+
122+
Builds<o2::aod::Run3MatchedSparse> bld;
123+
REQUIRE(is_builds<decltype(bld)>);
124+
125+
OutputObj<TH1F> oo{"test"};
126+
REQUIRE(is_outputobj<decltype(oo)>);
127+
128+
Service<o2::O2DatabasePDG> srv;
129+
REQUIRE(is_service<decltype(srv)>);
130+
131+
Partition<o2::aod::Tracks> part = o2::aod::track::collisionId >= 0;
132+
REQUIRE(is_partition<decltype(part)>);
133+
134+
// AnalysisTask
135+
Enumeration<0, 1> en;
136+
REQUIRE(is_enumeration<decltype(en)>);
137+
138+
// Condition
139+
Condition<int> c{""};
140+
REQUIRE(is_condition<decltype(c)>);
141+
142+
struct : ConditionGroup {
143+
Condition<float> c{""};
144+
} cg;
145+
REQUIRE(is_condition_group<decltype(cg)>);
146+
147+
// Configurable
148+
Configurable<int> cc{"", 1, ""};
149+
REQUIRE(is_configurable<decltype(cc)>);
150+
151+
ConfigurableAxis ca{"", {0, 1, 2, 3}, ""};
152+
REQUIRE(is_configurable_axis<decltype(ca)>);
153+
154+
REQUIRE(is_process_configurable<decltype(P::doprocess1)>);
155+
156+
struct : ConfigurableGroup {
157+
Configurable<int> c{"", 1, ""};
158+
} ccg;
159+
REQUIRE(is_configurable_group<decltype(ccg)>);
160+
161+
// Expressions
162+
expressions::Filter f = o2::aod::track::pt > 1.0f;
163+
REQUIRE(expressions::is_filter<decltype(f)>);
164+
}

0 commit comments

Comments
 (0)