Re: [ROOT] Drawing TGeoNodes

From: Andrei Gheata (Andrei.Gheata@cern.ch)
Date: Wed Aug 20 2003 - 09:08:58 MEST


Hi Ilektra,

The hierarchy of nodes has a tree structure and a branch corresponds to 
a given path in this tree, e.g. /TOP_1/A_3/B_1/.../CurrentNode. When 
navigating the geometry, the modeller always keeps track of the current 
branch in order to be able to compute the global transformation matrix 
of the current node with respect to the TOP node.
  You can set this to point to a given node with:
    gGeoManager->cd(const char *path)

Once your interesting node becomes current, you can visualize the 
content of the corresponding volume with:
    gGeoManager->GetCurrentVolume()->Draw();
and if you want also to see the node itself, use:
    gGeoManager->SetTopVisible()

You have to know that during drawing, the drawn volume becomes always 
TOP in the geometry (master reference), so you will not be able to use
cd() any more if you do not restore before initial TOP of your geometry 
(imagine that the tree is seen just from your current node down). You 
can do this with:
   gGeoManager->RestoreMasterVolume()

  As far as visualizing only a set of interesting nodes in the global 
reference frame, this is not so easy to implement, but I will think how 
it could be done. Meanwhile, you can see just the current selected 
branch down to some hit node with:
    gGeoManager->DrawPath()

  Best regards,
Andrei

Ilektra-atha Christidi wrote:
> Hi, Andrei
> Thank you for your prompt reply.
> I failed to mention in my previous email that I actually have the whole 
> path (volume names and copy numbers) to the hit node in my hit structure. 
> Well, apart from the redundant levels, that only have 1 node placed inside 
> them, but that's straightforward to disentagle. So, is it possible with 
> this information to draw the one node? Would it be easy for you to 
> implement?
> And another thing: what is the current branch and how can I set it?
> 
> Thanks
> 
> 					Ilektra Christidi
> 
> On Tue, 19 Aug 2003, Andrei Gheata wrote:
> 
> 
>>Hi Ilektra,
>>
>>  The feature you are asking for is not yet implemented in TGeo, due to 
>>the following reason:
>>  Suppose that you have a volume C positioned 2 times into a volume B - 
>>this creates two different nodes C_1 and C_2. If B at its turn is 
>>positioned 2 times into a mother volume A, you will also get B_1 and 
>>B_2. Therefore you will get the following hierarchy:
>>
>>         A        - volumes
>>       /   \
>>    B_1     B_2   - nodes
>>       \   /
>>         B
>>       /  \
>>    C_1     C_2
>>       \   /
>>         C
>>
>>  This means that for instance the node C_1 does not represent a unique 
>>object, but two, corresponding to the paths:
>>   A/B_1/C_1  and A/B_2/C_1
>>  These have different transformations w.r.t the coordinate frame of A. 
>>Which one to draw having a pointer to C_1... ? This is why visualization 
>>is implemented only at the level of volumes.
>>
>>   About the question of retreiving a node pointer by name - I suppose 
>>you have a hit structure having a node name attached. A node name is 
>>made by: volumeName_copyNumber. I can implement a method :
>>   TGeoNode *TGeoManager::GetNode(const char* nodename)
>>The gGeoManager->GetListOfNodes() list does not contain all nodes in the 
>>geometry, but just the current branch. If your hits have volumeName + 
>>copyNumber information, you can retreive yourself the node like:
>>    gGeoManager->GetVolume(volName)->GetNode(copyNumber);
>>
>>You can also use FindNode() with the x,y,z information of hits to 
>>retreive not only the logical node, but also the full path to it 
>>(corresponding unique physical object) :
>>    TGeoNode* hitNode = gGeoManager->FindNode(x,y,z);
>>    cout << gGeoManager->GetPath() << endl;
>>    // now hitNode is known as the current node by the manager class
>>
>>I hope this helps. Let me know if you have other questions.
>>
>>Best regards,
>>Andrei
>>
>>
>>Ilektra-atha Christidi wrote:
>>
>>>Hello
>>>I'm trying to draw objects from a GEANT3 geometry, which I have 
>>>successfully read into ROOT. I managed to get a pointer to a certain 
>>>volume and then draw it, using (name is a character string variable 
>>>containing the name of the volume I want to draw)
>>>
>>>TGeoVolume *volu = gGeoManager->GetListOfVolumes()->FindObject(name);
>>>name->Draw();
>>>
>>>but I need to do the same for TGeoNodes, because I want to draw only the 
>>>parts of the detector that saw a hit. The same recipe to get the pointer 
>>>doesn't work, though, (I mean 
>>>TGeoNode *node = gGeoManager->GetListOfNodes()->FindObject(name); 
>>>node->Draw();   )
>>>giving the message
>>>
>>>Error: illegal pointer to class object node 0x0 803  FILE:(tmpfile) LINE:1
>>>*** Interpreter error recovered ***
>>>
>>>and neither does GetNode(), GetNodes() and FindNode(). The message I get
>>>is
>>>
>>>Error: Can't call TObjArray::GetNode("SDSC") in current scope 
>>>FILE:(tmpfile) LINE:1
>>>Possible candidates are...
>>>filename       line:size busy function type and name  (in TObjArray)
>>>filename       line:size busy function type and name  (in TSeqCollection)
>>>filename       line:size busy function type and name  (in TCollection)
>>>filename       line:size busy function type and name  (in TObject)
>>>Error: non class,struct,union object GetListOfNodes() used with . or -> 
>>>FILE:(tmpfile) LINE:1
>>>*** Interpreter error recovered ***
>>>
>>>I guess I have to set the node I want to retrieve as current node, but how 
>>>do I do that? Or do I also need to specify the copy number when I call 
>>>TGeoNode functions?
>>>
>>>In the next step, when I'll draw the nodes, is it possible to draw only 
>>>the ones that saw a hit but in global coordinates (if the node appears 
>>>always in the middle of the screen, as it happens for volumes, it's not 
>>>very helpful...)? Maybe if I overlay them with a basic drawing of the 
>>>whole detector?
>>>
>>>Thanks
>>>
>>>						Ilektra Christidi
>>>
>>>
>>
>>
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET