Re: Node Parents

Rene Brun (Rene.Brun@cern.ch)
Fri, 09 Apr 1999 11:21:13 +0000


Frederic MACHEFERT wrote:
>
> Hi rooters,
>
> I define many different nodes whom the hierarchy is not defined from the
> beginning. After the initialisation of the nodes, I wish to sort them
> according to a certain hierarchy. I thought that the goud way was to use
> the SetParent function. But what I plot doesn't seem to produce what I
> expect and if I have a look at the browser and at the node hierarchy
> nothing is modified.
>
> I think I missed something with respect to SetParent. I would like to know
> how I can change the hierarchy without deleting and creating again my
> nodes.
>

Salut Frederic,
I suggest you look at the logic in the TNode constructor to understand
the current logic. In your case, if you want to set the hierarchy only
once you have defined all the nodes, I suggest;
//disable current node in geometry
gGeometry->setCurrentNode(0);

//define your nodes
TNode *node = new TNode(...)
......

//clear the list of nodes in the geometry
gGeometry->GetListOfNodes()->Clear();

//now start creating your hierarchy
//if a node has descendants, do:
node->BuildListOfNodes();

//to insert a node in its parent node, do
node->SetParent(parentNode);
parentNode->GetListOfNodes()->Add(node);

Let me know if you still have problems.
I am curious to know why you can only build the hierarchy at the end.
This is may be an interesting case.

Rene Brun