benchmark/code/dataset/preprocess.py
def traverse_tree_rec(
    root, parent_id, is_left, tree, content, charge, abs_charge, muon,
    extra_info=True
):
    """Recursive function to access fastjet clustering history and make the
    tree.

    Parameters
    ----------
    root: should be a fj.PseudoJet
    """
    id = int(len(tree)/2)
    if parent_id >= 0:
        if is_left:
            # We set the location of the lef child in the content array of the
            # 4-vector stored in content[parent_id]. So the left child will be
            # content[tree[2 * parent_id]].
            tree[2 * parent_id] = id
        else:
            # We set the location of the right child in the content array of
            # the 4-vector stored in content[parent_id]. So the right child
            # will be content[tree[2 * parent_id+1]]. This is correct because
            # with each 4-vector we increase the content array by one element
            # and the tree array by 2 elements. But then we take
            # id=tree.size()//2, so the id increases by 1. The left and right
            # children are added one after the other.
            tree[2 * parent_id + 1] = id
    # We insert 2 new nodes to the vector that constitutes the tree. In the
    # next iteration we will replace this 2 values with the location of the
    # parent of the new nodes
    tree.append(-1)
    tree.append(-1)
    # We fill the content vector with the values of the node
    content.append(root.px())
    content.append(root.py())
    content.append(root.pz())
    content.append(root.e())
    # We move from the root down until we get to the leaves. We do this
    # recursively
    if root.has_pieces():
        if extra_info:
            charge.append('inner')
            abs_charge.append('inner')
            muon.append('inner')
        # Call the function recursively
        pieces = root.pieces()
        # pieces[0] is the left child
        traverse_tree_rec(
            root=pieces[0],
            parent_id=id,
            is_left=True,
            tree=tree,
            content=content,
            charge=charge,
            abs_charge=abs_charge,
            muon=muon,
            extra_info=extra_info
        )
        # pieces[1] is the right child
        traverse_tree_rec(
            root=pieces[1],
            parent_id=id,
            is_left=False,
            tree=tree,
            content=content,
            charge=charge,
            abs_charge=abs_charge,
            muon=muon,
            extra_info=extra_info
        )
    else:
        if extra_info:
            charge.append(root.python_info().Charge)
            abs_charge.append(np.absolute(root.python_info().Charge))
            muon.append(root.python_info().Muon)
Recursive function to access fastjet clustering history and make the
    tree.

    Parameters
    ----------
    root: should be a fj.PseudoJet
    
Recursive function to access fastjet clustering history and make the
tree.

Parameters


Recursive function to access fastjet clustering history and make the tree . Parameters
def traverse_tree_rec(
    root, parent_id, is_left, tree, content, charge, abs_charge, muon,
    extra_info=True
):
    id = int(len(tree)/2)
    if parent_id >= 0:
        if is_left:
            tree[2 * parent_id] = id
        else:
            tree[2 * parent_id + 1] = id
    tree.append(-1)
    tree.append(-1)
    content.append(root.px())
    content.append(root.py())
    content.append(root.pz())
    content.append(root.e())
    if root.has_pieces():
        if extra_info:
            charge.append('inner')
            abs_charge.append('inner')
            muon.append('inner')
        pieces = root.pieces()
        traverse_tree_rec(
            root=pieces[0],
            parent_id=id,
            is_left=True,
            tree=tree,
            content=content,
            charge=charge,
            abs_charge=abs_charge,
            muon=muon,
            extra_info=extra_info
        )
        traverse_tree_rec(
            root=pieces[1],
            parent_id=id,
            is_left=False,
            tree=tree,
            content=content,
            charge=charge,
            abs_charge=abs_charge,
            muon=muon,
            extra_info=extra_info
        )
    else:
        if extra_info:
            charge.append(root.python_info().Charge)
            abs_charge.append(np.absolute(root.python_info().Charge))
            muon.append(root.python_info().Muon)
def traverse_tree_rec ( root , parent_id , is_left , tree , content , charge , abs_charge , muon , extra_info = True ) : id = int ( len ( tree ) / 2 ) if parent_id >= 0 : if is_left : tree [ 2 * parent_id ] = id else : tree [ 2 * parent_id + 1 ] = id tree . append ( - 1 ) tree . append ( - 1 ) content . append ( root . px ( ) ) content . append ( root . py ( ) ) content . append ( root . pz ( ) ) content . append ( root . e ( ) ) if root . has_pieces ( ) : if extra_info : charge . append ( 'inner' ) abs_charge . append ( 'inner' ) muon . append ( 'inner' ) pieces = root . pieces ( ) traverse_tree_rec ( root = pieces [ 0 ] , parent_id = id , is_left = True , tree = tree , content = content , charge = charge , abs_charge = abs_charge , muon = muon , extra_info = extra_info ) traverse_tree_rec ( root = pieces [ 1 ] , parent_id = id , is_left = False , tree = tree , content = content , charge = charge , abs_charge = abs_charge , muon = muon , extra_info = extra_info ) else : if extra_info : charge . append ( root . python_info ( ) . Charge ) abs_charge . append ( np . absolute ( root . python_info ( ) . Charge ) ) muon . append ( root . python_info ( ) . Muon )
Recursive function to access fastjet clustering history and make the
tree.
Recursive function to access fastjet clustering history and make the tree .
"""Recursive function to access fastjet clustering history and make the
    tree.

    Parameters
    ----------
    root: should be a fj.PseudoJet
    """ # We set the location of the lef child in the content array of the # 4-vector stored in content[parent_id]. So the left child will be # content[tree[2 * parent_id]]. # We set the location of the right child in the content array of # the 4-vector stored in content[parent_id]. So the right child # will be content[tree[2 * parent_id+1]]. This is correct because # with each 4-vector we increase the content array by one element # and the tree array by 2 elements. But then we take # id=tree.size()//2, so the id increases by 1. The left and right # children are added one after the other. # We insert 2 new nodes to the vector that constitutes the tree. In the # next iteration we will replace this 2 values with the location of the # parent of the new nodes # We fill the content vector with the values of the node # We move from the root down until we get to the leaves. We do this # recursively # Call the function recursively # pieces[0] is the left child # pieces[1] is the right child
root
parent_id
is_left
tree
content
charge
abs_charge
muon
extra_info