Skip to content

Commit 921a386

Browse files
committed
DPL Analysis: add utility to dump the Analysis DataModel
1 parent 39fd2cd commit 921a386

File tree

3 files changed

+125
-1
lines changed

3 files changed

+125
-1
lines changed

Framework/Core/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ o2_add_executable(verify-aod-file
185185
PUBLIC_LINK_LIBRARIES O2::Framework
186186
COMPONENT_NAME Framework)
187187

188+
o2_add_executable(dump-aod-data-model
189+
SOURCES src/dumpDataModel.cxx
190+
PUBLIC_LINK_LIBRARIES O2::Framework
191+
COMPONENT_NAME Framework
192+
)
193+
188194
# tests with input data
189195

190196
o2_data_file(COPY test/test_DataSampling.json DESTINATION tests)

Framework/Core/include/Framework/AnalysisDataModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ using Muon = Muons::iterator;
175175
namespace muoncluster
176176
{
177177
/// FIXME: where does this point to???? Tracks or Muons?
178-
DECLARE_SOA_COLUMN(TrackId, trackId, int, "fMuonsID");
178+
DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Muons, "fMuonsID");
179179
DECLARE_SOA_COLUMN(X, x, float, "fX");
180180
DECLARE_SOA_COLUMN(Y, y, float, "fY");
181181
DECLARE_SOA_COLUMN(Z, z, float, "fZ");
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
#include "Framework/AnalysisDataModel.h"
11+
#include <fmt/printf.h>
12+
#include <map>
13+
14+
using namespace o2::framework;
15+
using namespace o2::aod;
16+
using namespace o2::soa;
17+
18+
static int count = 0;
19+
20+
template <typename C>
21+
void printColumn()
22+
{
23+
if constexpr (!is_index_column_v<C>) {
24+
fmt::printf("%s\\l", C::label());
25+
}
26+
}
27+
28+
template <typename C>
29+
void printIndexColumn()
30+
{
31+
if constexpr (is_index_column_v<C>) {
32+
fmt::printf("%s\\l", C::label());
33+
}
34+
}
35+
36+
template <typename C, typename T>
37+
void printIndex()
38+
{
39+
auto a = MetadataTrait<typename C::binding_t>::metadata::label();
40+
auto b = MetadataTrait<T>::metadata::label();
41+
fmt::printf("%s -> %s []\n", a, b);
42+
}
43+
44+
template <typename... C>
45+
void dumpColumns(pack<C...>)
46+
{
47+
(printColumn<C>(), ...);
48+
fmt::printf("%s", "\n");
49+
}
50+
51+
template <typename... C>
52+
void dumpIndexColumns(pack<C...>)
53+
{
54+
(printIndexColumn<C>(), ...);
55+
fmt::printf("%s", "\n");
56+
}
57+
58+
template <typename T, typename... C>
59+
void dumpIndex(pack<C...>)
60+
{
61+
(printIndex<C, T>(), ...);
62+
fmt::printf("%s", "\n");
63+
}
64+
65+
template <typename T>
66+
void dumpTable(bool index = true)
67+
{
68+
// nodes.push_back({MetadataTrait<T>::metadata::label(), nodeCount});
69+
auto label = MetadataTrait<T>::metadata::label();
70+
fmt::printf(R"(%s[label = "{%s|)", label, label);
71+
if (pack_size(typename T::iterator::persistent_columns_t{}) -
72+
pack_size(typename T::iterator::external_index_columns_t{})) {
73+
dumpColumns(typename T::iterator::persistent_columns_t{});
74+
fmt::printf("%s", "|");
75+
}
76+
if (pack_size(typename T::iterator::dynamic_columns_t{})) {
77+
dumpColumns(typename T::iterator::dynamic_columns_t{});
78+
fmt::printf("%s", "|");
79+
}
80+
dumpIndexColumns(typename T::iterator::external_index_columns_t{});
81+
fmt::printf("%s", "}\"]\n");
82+
if (index)
83+
dumpIndex<T>(typename T::iterator::external_index_columns_t{});
84+
}
85+
86+
template <typename... Ts>
87+
void dumpCluster()
88+
{
89+
fmt::printf(R"(subgraph cluster_%d {
90+
node[shape=record,style=filled,fillcolor=gray95]
91+
edge[dir=back, arrowtail=empty]
92+
)",
93+
count++);
94+
(dumpTable<Ts>(false), ...);
95+
fmt::printf("%s", "}\n");
96+
(dumpIndex<Ts>(typename Ts::iterator::external_index_columns_t{}), ...);
97+
}
98+
99+
int main(int argc, char** argv)
100+
{
101+
fmt::printf("%s", R"(digraph hierarchy {
102+
size="5,5"
103+
node[shape=record,style=filled,fillcolor=gray95]
104+
edge[dir=back, arrowtail=empty]
105+
)");
106+
dumpCluster<Tracks, TracksCov, TracksExtra>();
107+
dumpTable<Collisions>();
108+
dumpTable<Calos>();
109+
dumpTable<CaloTriggers>();
110+
dumpTable<Muons>();
111+
dumpTable<MuonClusters>();
112+
dumpTable<Zdcs>();
113+
dumpTable<VZeros>();
114+
dumpTable<V0s>();
115+
dumpTable<Cascades>();
116+
dumpTable<Timeframes>();
117+
fmt::printf("%s\n", R"(})");
118+
}

0 commit comments

Comments
 (0)