Skip to content

Commit 89d008a

Browse files
committed
fix handling of sources
1 parent b75d643 commit 89d008a

File tree

2 files changed

+47
-60
lines changed

2 files changed

+47
-60
lines changed

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "Framework/ASoA.h"
1515
#include "Framework/DataAllocator.h"
16-
#include "Framework/ExpressionHelpers.h"
1716
#include "Framework/IndexBuilderHelpers.h"
1817
#include "Framework/InputSpec.h"
1918
#include "Framework/Output.h"
@@ -28,14 +27,57 @@
2827
#include <string>
2928
namespace o2::soa
3029
{
30+
template <TableRef R>
31+
constexpr auto tableRef2ConfigParamSpec()
32+
{
33+
return o2::framework::ConfigParamSpec{
34+
std::string{"input:"} + o2::aod::label<R>(),
35+
framework::VariantType::String,
36+
aod::sourceSpec<R>(),
37+
{"\"\""}};
38+
}
39+
40+
namespace {
41+
template <soa::with_sources T>
42+
inline constexpr auto getSources()
43+
{
44+
return []<size_t N, std::array<soa::TableRef, N> refs>() {
45+
return []<size_t... Is>(std::index_sequence<Is...>) {
46+
return std::vector{soa::tableRef2ConfigParamSpec<refs[Is]>()...};
47+
}(std::make_index_sequence<N>());
48+
}.template operator()<T::sources.size(), T::sources>();
49+
}
50+
51+
template <soa::with_sources T>
52+
constexpr auto getInputMetadata() -> std::vector<framework::ConfigParamSpec>
53+
{
54+
std::vector<framework::ConfigParamSpec> inputMetadata;
55+
auto inputSources = getSources<T>();
56+
std::sort(inputSources.begin(), inputSources.end(), [](framework::ConfigParamSpec const& a, framework::ConfigParamSpec const& b) { return a.name < b.name; });
57+
auto last = std::unique(inputSources.begin(), inputSources.end(), [](framework::ConfigParamSpec const& a, framework::ConfigParamSpec const& b) { return a.name == b.name; });
58+
inputSources.erase(last, inputSources.end());
59+
inputMetadata.insert(inputMetadata.end(), inputSources.begin(), inputSources.end());
60+
return inputMetadata;
61+
}
62+
63+
template <typename T>
64+
requires(!soa::with_sources<T>)
65+
constexpr auto getInputMetadata() -> std::vector<framework::ConfigParamSpec>
66+
{
67+
return {};
68+
}
69+
}
70+
3171
template <TableRef R>
3272
constexpr auto tableRef2InputSpec()
3373
{
3474
return framework::InputSpec{
3575
o2::aod::label<R>(),
3676
o2::aod::origin<R>(),
3777
o2::aod::description(o2::aod::signature<R>()),
38-
R.version};
78+
R.version,
79+
framework::Lifetime::Timeframe,
80+
getInputMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash>>::metadata>()};
3981
}
4082

4183
template <TableRef R>
@@ -64,16 +106,6 @@ constexpr auto tableRef2OutputRef()
64106
o2::aod::label<R>(),
65107
R.version};
66108
}
67-
68-
template <TableRef R>
69-
constexpr auto tableRef2ConfigParamSpec()
70-
{
71-
return o2::framework::ConfigParamSpec{
72-
std::string{"input:"} + o2::aod::label<R>(),
73-
framework::VariantType::String,
74-
aod::sourceSpec<R>(),
75-
{"\"\""}};
76-
}
77109
} // namespace o2::soa
78110

79111
namespace o2::framework

Framework/Core/include/Framework/AnalysisTask.h

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -65,46 +65,6 @@ concept is_enumeration = is_enumeration_v<std::decay_t<T>>;
6565
// the contents of an AnalysisTask...
6666
namespace {
6767
struct AnalysisDataProcessorBuilder {
68-
template <typename T>
69-
static ConfigParamSpec getSpec()
70-
{
71-
if constexpr (soa::has_metadata<aod::MetadataTrait<T>>) {
72-
return ConfigParamSpec{std::string{"input:"} + aod::MetadataTrait<T>::metadata::tableLabel(), VariantType::String, aod::MetadataTrait<T>::metadata::sourceSpec(), {"\"\""}};
73-
} else {
74-
using O1 = framework::pack_element_t<0, typename T::originals>;
75-
return ConfigParamSpec{std::string{"input:"} + aod::MetadataTrait<T>::metadata::tableLabel(), VariantType::String, aod::MetadataTrait<O1>::metadata::sourceSpec(), {"\"\""}};
76-
}
77-
}
78-
79-
template <soa::TableRef R>
80-
static ConfigParamSpec getSpec()
81-
{
82-
return soa::tableRef2ConfigParamSpec<R>();
83-
}
84-
85-
template <soa::with_sources T>
86-
static inline auto getSources()
87-
{
88-
return []<size_t N, std::array<soa::TableRef, N> refs>() {
89-
return []<size_t... Is>(std::index_sequence<Is...>) {
90-
return std::vector{soa::tableRef2ConfigParamSpec<refs[Is]>()...};
91-
}(std::make_index_sequence<N>());
92-
}.template operator()<T::sources.size(), T::sources>();
93-
}
94-
95-
template <soa::with_sources T>
96-
97-
static auto getInputMetadata()
98-
{
99-
std::vector<ConfigParamSpec> inputMetadata;
100-
auto inputSources = getSources<T>();
101-
std::sort(inputSources.begin(), inputSources.end(), [](ConfigParamSpec const& a, ConfigParamSpec const& b) { return a.name < b.name; });
102-
auto last = std::unique(inputSources.begin(), inputSources.end(), [](ConfigParamSpec const& a, ConfigParamSpec const& b) { return a.name == b.name; });
103-
inputSources.erase(last, inputSources.end());
104-
inputMetadata.insert(inputMetadata.end(), inputSources.begin(), inputSources.end());
105-
return inputMetadata;
106-
}
107-
10868
template <typename G, typename... Args>
10969
static void addGroupingCandidates(std::vector<StringPair>& bk, std::vector<StringPair>& bku)
11070
{
@@ -130,14 +90,9 @@ struct AnalysisDataProcessorBuilder {
13090
template <soa::TableRef R>
13191
static void addOriginalRef(const char* name, bool value, std::vector<InputSpec>& inputs)
13292
{
133-
using metadata = typename aod::MetadataTrait<o2::aod::Hash<R.desc_hash>>::metadata;
134-
std::vector<ConfigParamSpec> inputMetadata;
135-
inputMetadata.emplace_back(ConfigParamSpec{std::string{"control:"} + name, VariantType::Bool, value, {"\"\""}});
136-
if constexpr (soa::with_sources<metadata>) {
137-
auto inputSources = getInputMetadata<metadata>();
138-
inputMetadata.insert(inputMetadata.end(), inputSources.begin(), inputSources.end());
139-
}
140-
DataSpecUtils::updateInputList(inputs, InputSpec{o2::aod::label<R>(), o2::aod::origin<R>(), aod::description(o2::aod::signature<R>()), R.version, Lifetime::Timeframe, inputMetadata});
93+
auto spec = soa::tableRef2InputSpec<R>();
94+
spec.metadata.emplace_back(ConfigParamSpec{std::string{"control:"} + name, VariantType::Bool, value, {"\"\""}});
95+
DataSpecUtils::updateInputList(inputs, std::move(spec));
14196
}
14297

14398
/// helpers to append expression information for a single argument

0 commit comments

Comments
 (0)