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 {
21
23 namespace DNN {
24
28
36 template<class NodeEntryType>
37 void printCANetwork(DirectedNodeNetwork<NodeEntryType, CACell>& network, const std::string& fName)
38 {
39 std::string fullOut = "digraph G {\n";
40 fullOut +=
41 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
42 // write vertices:
43 for (auto* node : network) {
44 fullOut += "\"" + node->getEntry().getName() + "\"" +
45 " [label=\"" +
46 node->getEntry().getName() +
47 " State,Seed: " +
48 std::to_string(node->getMetaInfo().getState()) +
49 "," +
50 std::to_string(node->getMetaInfo().isSeed()) +
51 "\"];\n";
52 }
53 // write edges:
54 for (auto* node : network) {
55 for (auto* innerNode : node->getInnerNodes()) {
56 auto innerEntry = innerNode->getEntry();
57 std::string arrowStyle = (node->getMetaInfo().getState() == (innerNode->getMetaInfo().getState() + 1)) ? "" : " [style=dotted]";
58 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
59 }
60 }
61 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
62 fullOut += "}\n";
63
64 std::ofstream ofs;
65 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
66 ofs << fullOut;
67 ofs.close();
68 };
69
70
72 template<class NodeEntryType, class AnyMetaInfo>
73 void printNetwork(DirectedNodeNetwork<NodeEntryType, AnyMetaInfo>& network, const std::string& fName)
74 {
75 std::string fullOut = "digraph G {\n";
76 fullOut +=
77 "ranksep=\"0.2\" edge[labelfontsize=\"8\" fontsize=\"8\" arrowsize=\"0.9\"] nodesep=\"0.2\" node[shape=\"box\" width=\"0\" height=\"0\" fontsize=\"10\"]\n";
78
79 // write vertices:
80 for (auto* node : network) {
81 fullOut += "\"" + node->getEntry().getName() + "\"" +
82 " [label=\"" +
83 node->getEntry().getName() +
84 "\"];\n";
85 }
86 // write edges:
87 for (auto* node : network) {
88 for (auto* innerNode : node->getInnerNodes()) {
89 auto innerEntry = innerNode->getEntry();
90 std::string arrowStyle = "";
91 fullOut += "\"" + node->getEntry().getName() + "\" -> \"" + innerEntry.getName() + "\"" + arrowStyle + ";\n";
92 }
93 }
94 fullOut += "labelloc=\"t\";\nlabel=\"" + fName + "\";\n";
95 fullOut += "}\n";
96
97 std::ofstream ofs;
98 ofs.open(fName + ".gv", std::ofstream::out | std::ofstream::trunc);
99 ofs << fullOut;
100 ofs.close();
101 };
102
103 } // DNN namespace
104
105} //Belle2 namespace
Network of directed nodes of the type EntryType.
namespace for DirectedNodeNetwork-related stuff
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.