Re: nested geomtries

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 29 1997 - 18:32:20 MET


Daniel Levin 313 764 4385 wrote:
> 
> Dear ROOT Priests:
> 
> As a C++/ROOT novice I am flummoxed by the following problem:
> 
> I would like to construct a detector geometry in ROOT
> from the bottom up alla GEANT. The examples harvested
> from the tutorials (and from the na49.C file
> created automatically from GEANT)
> suggest only top down assembly. I.e.
> first define a mother node:
> 
> mama  = new TNode("MAMA","MAMA","MVOL");
> 
> //MVOL is the mother box...
> 
> place in it daughters: eg,
> 
> // PPLN point to BRIK shapes
> 
>       mama->cd();
>       plx = new TNode("PLX","PLX","PPLN",0,0,zpos,"ROT1);
>       zpos += deltaZ;
>       mama->cd();
>       ply = new TNode("PLY","PLY","PPLN",0,0,zpos,"ROT2");
> 
> and then locate subsequent components as successive
> generations in each of these exisiting first generation daughters.
> 
> How can I define some multielement fundamental detector subsystem
> and then locate this system multiple times in a parent volume, then
> place this parent multiple times in a higher generation node, etc?
> 
>                         thanx, Daniel Levin

The current geometry package in Root is designed to build
a geometry top->down. The idea is that you will typically call
a function to create super modules. This function, in turn, calling
other functions to create substructures.
Creating a clone of a node in this model is simply by calling
the same function with a different set of parameters corresponding
to the names of the nodes, their position and rotation matrix.
The advantage is that when going down in the tree, the list to
support lower level nodes has already been created in the parent node
and the insertion of subnodes in this list is automatic when
creating these subnodes.

You can also take the bottom->up approach. This requires however
to be careful when building the hierarchy.
You can start creating all the nodes at the top level and never
do node->cd().
At any time, you can do:
  parentnode->GetListOfNodes()->Add(thisnode)

In the development version 1.03/07 I have added a few additional
member functions in the TNode class to permit more flexibility,
  virtual void  SetMatrix(TRotMatrix *matrix=0);
  virtual void  SetName(const Text_t *name);
  virtual void  SetParent(TNode *parent);
  virtual void  SetPosition( Double_t x, Double_t y, Double_t z);

Using these new functions in combination with the powerful 
TObject::Clone() function, you can create a new node, a clone
of an existing node with its complete hierarchy, then modify
the parameters of the clone as illustrated by the example below:

Rene Brun


{

TMaterial *mat;
TMixture  *mix;
TRotMatrix *rot;
TNode *Node, *Node1;

TGeometry *na49 = new TGeometry("na49","na49.C");


//-----------List of Materials and Mixtures--------------

mat = new TMaterial("mat1","HYDROGEN",1.01,1,.0708);
mat = new TMaterial("mat2","DEUTERIUM",2.01,1,.162);
mat = new TMaterial("mat3","HELIUM",4,2,.125);
mat = new TMaterial("mat4","LITHIUM",6.94,3,.534);
mat = new TMaterial("mat5","BERILLIUM",9.01,4,1.848);
mat = new TMaterial("mat6","CARBON",12.01,6,2.265);
mat = new TMaterial("mat7","NITROGEN",14.01,7,.808);
mat = new TMaterial("mat8","NEON",20.18,10,1.207);
mat = new TMaterial("mat9","ALUMINIUM",26.97999,13,2.7);
mat = new TMaterial("mat10","IRON",55.84999,26,7.869999);
mat = new TMaterial("mat11","COPPER",63.54,29,8.96);
mat = new TMaterial("mat12","TUNGSTEN",183.85,74,19.29999);
mat = new TMaterial("mat13","LEAD",207.19,82,11.35);
mat = new TMaterial("mat14","URANIUM",238.0299,92,18.95);
mat = new TMaterial("mat15","AIR",14.60999,7.3,.001205);
mat = new TMaterial("mat16","VACUUM",0,0,0);
mat = new TMaterial("mat17","JUNK",28.09,14,2.329999);
//-----------List of Rotation matrices--------------

rot = new TRotMatrix("rot1","rot1",90,0,90,90,0,0);

//-----------List of Volumes--------------

TBRIK *CAVE = new TBRIK("CAVE","CAVE","mat15",600,200,2000);
  CAVE->SetVisibility(0);
TTUBE *TGT1 = new TTUBE("TGT1","TGT1","mat13",0,.5,.0098678);
TBRIK *VETO = new TBRIK("VETO","VETO","mix31",200,200,.5);
TBRIK *VT1_ = new TBRIK("VT1_","VT1_","mix31",98.75,46.04999,128.75);
TBRIK *HV1_ = new TBRIK("HV1_","HV1_","mix29",97.25,2.8,127.25);
TBRIK *HV1I = new TBRIK("HV1I","HV1I","mat15",97,2.55,127);
//-----------List of Nodes--------------

Node1 = new TNode("CAVE1","CAVE1","CAVE");
Node1->cd();
 Node = new TNode("TGT11","TGT11","TGT1",0,0,-580.27,"");
 Node = new TNode("VETO1","VETO1","VETO",0,0,1545,"");
 TNode *Node2;
 Node2 = new TNode("VT1_1","VT1_1","VT1_",0,-1.05,-381.399,"rot1");

 Node2->cd();
  TNode *Node3;
  Node3 = new TNode("HV1_1","HV1_1","HV1_",0,-43.25,0,"");
  Node3->cd();
   Node = new TNode("HV1I1","HV1I1","HV1I",0,0,0,"");
 Node2->cd();
Node1->cd();

// Now makes a clone of Node2 and insert it in master node
// Setting node parameters implemented only in 1.03/07
TNode *Node2Copy = (TNode*)Node2->Clone();
Node1->GetListOfNodes()->Add(Node2Copy);
Node2Copy->SetName("Node2Copy");
Node2Copy->SetPosition(0,1.05,1000);
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET