Belle II Software development
NodeNetworkHelperFunctions.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingVXD/segmentNetwork/CACell.h>
11#include <tracking/trackFindingVXD/segmentNetwork/DirectedNodeNetwork.h>
12
13#include <fstream>
14#include <string>
15
16namespace Belle2 {
23 namespace DNN {
24
36 template<class NodeEntryType>
37 // cppcheck-suppress constParameter
38 void printCANetwork(DirectedNodeNetwork<NodeEntryType, CACell>& network, const std::string& fName)
39 {
40 std::string fullOut = "digraph G {\n";
41 fullOut +=
42 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
43 // write vertices:
44 for (auto* node : network) {
45 fullOut += "\"" + node->getEntry().getName() + "\"" +
46 " [label=\"" +
47 node->getEntry().getName() +
48 " State,Seed: " +
49 std::to_string(node->getMetaInfo().getState()) +
50 "," +
51 std::to_string(node->getMetaInfo().isSeed()) +
52 "\"];\n";
53 }
54 // write edges:
55 for (auto* node : network) {
56 for (auto* innerNode : node->getInnerNodes()) {
57 auto innerEntry = innerNode->getEntry();
58 std::string arrowStyle = (node->getMetaInfo().getState() == (innerNode->getMetaInfo().getState() + 1)) ? "" : " [style=dotted]";
59 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
60 }
61 }
62 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
63 fullOut += "}\n";
64
65 std::ofstream ofs;
66 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
67 ofs << fullOut;
68 ofs.close();
69 };
70
71
73 template<class NodeEntryType, class AnyMetaInfo>
74 // cppcheck-suppress constParameter
75 void printNetwork(DirectedNodeNetwork<NodeEntryType, AnyMetaInfo>& network, const std::string& fName)
76 {
77 std::string fullOut = "digraph G {\n";
78 fullOut +=
79 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
80
81 // write vertices:
82 for (auto* node : network) {
83 fullOut += "\"" + node->getEntry().getName() + "\"" +
84 " [label=\"" +
85 node->getEntry().getName() +
86 "\"];\n";
87 }
88 // write edges:
89 for (auto* node : network) {
90 for (auto* innerNode : node->getInnerNodes()) {
91 auto innerEntry = innerNode->getEntry();
92 std::string arrowStyle = "";
93 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
94 }
95 }
96 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
97 fullOut += "}\n";
98
99 std::ofstream ofs;
100 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
101 ofs << fullOut;
102 ofs.close();
103 };
104
105 } // DNN namespace
107} //Belle2 namespace
Network of directed nodes of the type EntryType.
void printNetwork(DirectedNodeNetwork< NodeEntryType, AnyMetaInfo > &network, const std::string &fName)
overloaded print-version for typical activeSector-networks without CACell-stuff
void printCANetwork(DirectedNodeNetwork< NodeEntryType, CACell > &network, const std::string &fName)
TODO.
Abstract base class for different kinds of events.