 |
Belle II Software
release-05-02-19
|
13 #include <unordered_map>
15 #include <framework/logging/Logger.h>
17 #include <tracking/trackFindingVXD/segmentNetwork/DirectedNode.h>
29 template<
typename EntryType,
typename MetaInfoType>
30 class DirectedNodeNetwork {
33 using Node = DirectedNode<EntryType, MetaInfoType>;
35 using NodeID = std::int64_t;
55 delete nodePointer.second;
81 B2WARNING(
"Last OuterNode is not yet in this network! CurrentNetworkSize is: " <<
size());
86 B2WARNING(
"LastOuterNode and innerEntry are identical! Aborting linking-process");
93 B2WARNING(
"Last OuterNode and innerEntry were already in the network and were already connected."
94 "This is a sign for unintended behavior!");
104 B2WARNING(
"Last InnerNode is not yet in this network! CurrentNetworkSize is: " <<
size());
109 B2WARNING(
"OuterEntry and lastInnerNode are identical! Aborting linking-process");
117 B2WARNING(
"Last InnerNode and outerEntry were already in the network and were already connected."
118 "This is a sign for unintended behavior!");
128 if (outerNodeID == innerNodeID) {
129 B2WARNING(
"OuterNodeID and innerNodeID are identical! Aborting linking-process");
133 B2WARNING(
"Trying to link Nodes that are not present yet");
161 delete nodePointer.second;
201 typename std::vector<Node* >::iterator
begin()
209 typename std::vector<Node* >::iterator
end()
226 if (std::find(outerNode.getInnerNodes().begin(), outerNode.getInnerNodes().end(), &innerNode) != outerNode.getInnerNodes().end()) {
229 if (std::find(innerNode.getOuterNodes().begin(), innerNode.getOuterNodes().end(), &outerNode) != innerNode.getOuterNodes().end()) {
233 outerNode.addInnerNode(innerNode);
234 innerNode.addOuterNode(outerNode);
248 if (item.second->getInnerNodes().empty())
m_innerEnds.push_back(item.second);
249 if (item.second->getOuterNodes().empty())
m_outerEnds.push_back(item.second);
256 std::unordered_map<NodeID, Node*>
m_nodeMap;
void finalize()
Finalizing the NodeNetwork.
DirectedNode< EntryType, MetaInfoType > Node
Defining abbreviation for the used directed node type pack.
std::int64_t NodeID
NodeID should be some unique integer.
std::vector< Node * > m_nodes
After the network is finalized this vector will also carry all nodes to be able to keep the old inter...
std::vector< Node * > getOuterEnds()
getters:
bool isNodeInNetwork(const NodeID nodeID) const
Check if a given entry is already in the network.
std::vector< Node * > m_outerEnds
keeps track of current outerEnds (nodes which have no outerNodes) entries are the NodeIDs of the node...
~DirectedNodeNetwork()
destructor taking care of cleaning up the pointer-mess WARNING only needed when using classic pointer...
unsigned int size() const
Returns number of nodes to be found in the network.
NodeID m_lastInnerNodeID
temporal storage for last inner node added, used for speed-up
std::vector< Node * >::iterator begin()
Returns iterator for container: begin.
void clear()
Clear directed node network Called to clear the directed node network if its size grows to large.
bool m_isFinalized
keeps track of the state of the network to fill the vectors m_nodes, m_outerEnds, m_innerEnds only if...
std::vector< Node * > m_innerEnds
keeps track of current innerEnds (nodes which have no innerNodes) entries are the NodeIds of the node...
bool addOuterToLastInnerNode(NodeID outerNodeID)
to the last innerNode added, another outerNode will be attached
bool linkNodes(NodeID outerNodeID, NodeID innerNodeID)
takes two entry IDs and weaves them into the network
Abstract base class for different kinds of events.
Node * getNode(NodeID toBeFound)
Returns pointer to the node carrying the entry which is equal to given parameter.
NodeID m_lastOuterNodeID
temporal storage for last outer node added, used for speed-up
std::vector< Node * > getInnerEnds()
returns all nodes which have no inner nodes (but outer ones) and therefore are inner ends of the netw...
std::vector< Node * > & getNodes()
Returns all nodes of the network.
std::unordered_map< NodeID, Node * > m_nodeMap
************************* DATA MEMBERS *************************
DirectedNodeNetwork()
************************* CONSTRUCTOR/DESTRUCTOR *************************
static bool createLink(Node &outerNode, Node &innerNode)
************************* INTERNAL MEMBER FUNCTIONS *************************
std::vector< Node * >::iterator end()
Returns iterator for container: end.
bool addNode(NodeID nodeID, EntryType &newEntry)
************************* PUBLIC MEMBER FUNCTIONS *************************
bool addInnerToLastOuterNode(NodeID innerNodeID)
to the last outerNode added, another innerNode will be attached