|
| 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