[ROOT] Registering matrices with TGeoManager

From: Sue Kasahara (schubert@hep.umn.edu)
Date: Tue Dec 02 2003 - 23:53:07 MET


Hi roottalk,
I've noticed that the self-registering behavior of TGeoMatrix objects is different than
other TGeo objects (e.g. shapes, volumes, materials, mixtures, mediums), in that the construction
of a TGeoMatrix or derived object does not automatically result in its registration
with the TGeoManager.   Instead the registration of the TGeoMatrix objects seems to occur
only when the matrix is used as part of the definition of a TGeoNode.
   This means that in the following example:
{ ...
// geomanager, top volume, vacuum medium previously defined
TGeoRotation* r1 = new TGeoRotation("R1",90,0,90,270,0,0);
TGeoCombiTrans *c1 = new TGeoCombiTrans("C1",20,0,0,r1);
TGeoVolume *tub = geomgr -> MakeTube("tub1",vacuum,25.,25.,5.);
topVol -> AddNode(tub1,1,c1);
}

the "C1" matrix is in the end owned by the gGeoManager, but the "R1" matrix is not.

  Another example where this issue surfaces is in the
TGeoCompositeShape description:
//      TGeoTranslation *t1 = new TGeoTranslation("T1",0,0,-20);
//      TGeoTranslation *t2 = new TGeoTranslation("T2",0,0, 20);
//      TGeoRotation *r1 = new TGeoRotation("R1"); // transformations need names
//      r1->SetAngles(90,30,90,120,0,0); // rotation with 30 degrees about Z
//      TGeoTube *a = new TGeoTube(0, 10,20);
//      a->SetName("A");                 // shapes need names too
//      TGeoTube *b = new TGeoTube(0, 20,20);
//      b->SetName("B");
//      TGeoBBox *c = new TGeoBBox(10,10,50);
//      c->SetName("C");
//      TGeoBBox *d = new TGeoBBox(50,10,10);
//      d->SetName("D");
//
//      TGeoCompositeShape *cs;
//      cs = new TGeoCompositeShape("CS", "(A:t1+B:t2)\(C+D:r1)");

Running this example results in a segv, unless it's modified to include explicit
registeration of the rotation and translation matrices:
t1 -> RegisterYourself();  t2 -> RegisterYourSelf();  r1 -> RegisterYourself();
before constructing the TGeoCompositeShape.
(and also the typo's to raise "t1" to "T1", etc. in the construction of the TGeoCompositeShape need
to be fixed.)

I point this out because I think the different behavior of the transformation matrices from
the other types of objects that the TGeoManager manages is confusing and should either be made
more clear in the examples and class descriptions (e.g. in the TGeoManager class it
states:
//   TGeoManager is the owner of all geometry objects defined in a session,
// therefore users must not try to control their deletion. It contains lists of
// media, materials, transformations, shapes and volumes.
)
or it should be changed to follow the behavior of the other types.
Thanks for your consideration.
-Sue Kasahara



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