From 37c5376a999838daaaf3d3cf38e2b6d88ae286dc Mon Sep 17 00:00:00 2001 From: Shishlo Date: Tue, 24 Feb 2026 13:24:28 -0500 Subject: [PATCH] The transport matrix nodes were added to the end of the child nodes list of the parent node. It means, at the entrance they did not account for presiding child nodes. It is fixed. --- py/orbit/lattice/AccNode.py | 7 +++++-- py/orbit/py_linac/lattice/LinacTransportMatrixGenNodes.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/py/orbit/lattice/AccNode.py b/py/orbit/lattice/AccNode.py index 1a29276f..fdc145dc 100644 --- a/py/orbit/lattice/AccNode.py +++ b/py/orbit/lattice/AccNode.py @@ -168,7 +168,7 @@ def getNumberOfBodyChildren(self): nChildren = nChildren + len(arr[0]) + len(arr[1]) return nChildren - def addChildNode(self, node, place, part_index=0, place_in_part=AccActionsContainer.BEFORE): + def addChildNode(self, node, place, part_index=0, place_in_part=AccActionsContainer.AFTER): """ Method. Adds a child node to the list defined by place and (maybe) part index and place in the part (before or after). @@ -192,7 +192,10 @@ def addChildNode(self, node, place, part_index=0, place_in_part=AccActionsContai msg = msg + os.linesep orbitFinalize(msg) nodes = self.__childNodesArr[place][part_index][place_in_part] - nodes.append(node) + if(place_in_part == AccActionsContainer.AFTER): + nodes.append(node) + else: + nodes.insert(0, node) def getChildNodes(self, place, part_index=0, place_in_part=AccActionsContainer.BEFORE): """ diff --git a/py/orbit/py_linac/lattice/LinacTransportMatrixGenNodes.py b/py/orbit/py_linac/lattice/LinacTransportMatrixGenNodes.py index e66468fe..531a4355 100755 --- a/py/orbit/py_linac/lattice/LinacTransportMatrixGenNodes.py +++ b/py/orbit/py_linac/lattice/LinacTransportMatrixGenNodes.py @@ -228,7 +228,10 @@ def addTrMatrixGenNodes(self, accLattice, node_or_nodes, place=MarkerLinacNode.E # ----------------------------- for node in nodes: trMatrxGenNode = LinacTrMatrixGenNode(self, node.getName() + ":trMatrx") - node.addChildNode(trMatrxGenNode, place) + if(place == MarkerLinacNode.ENTRANCE): + node.addChildNode(trMatrxGenNode, place, place_in_part = AccActionsContainer.BEFORE) + else: + node.addChildNode(trMatrxGenNode, place, place_in_part = AccActionsContainer.AFTER) # ----- set up the position of the TrMatrix nodes actions = AccActionsContainer()