Problems with TGeoArb8

Dear all,

I am facing some problems with the TGeoArb8 shape in ROOT. I can reproduce the problem with the following script


void tetratest()
{
   gSystem->Load("libGeom");
   TGeoManager *geom = new TGeoManager("world","IES geometry");
   
   //--- define some materials
   TGeoMaterial *matUHV = new TGeoMaterial("UHV", 0,0,0);
   TGeoMaterial *matPMMA = new TGeoMaterial("PMMA", 207.2,82,2.7);
   
   
//   //--- define some media
   TGeoMedium *UHV = new TGeoMedium("UHV",1, matUHV);
   TGeoMedium *PMMA = new TGeoMedium("PMMA",1, matPMMA);

   Double_t list_of_vertices[8][2];
    list_of_vertices[0][0] = 0.;
	list_of_vertices[0][1] = 0.;
	list_of_vertices[1][0] = 0.;
	list_of_vertices[1][1] = 40.;
	list_of_vertices[2][0] = 40.;
	list_of_vertices[2][1] = 0.;
	list_of_vertices[3][0] = 0.;
	list_of_vertices[3][1] = 0.;

	list_of_vertices[4][0] = 0;
	list_of_vertices[4][1] = 0;
	list_of_vertices[5][0] = 0;
	list_of_vertices[5][1] = 0;
	list_of_vertices[6][0] = 0;
	list_of_vertices[6][1] = 0;
	list_of_vertices[7][0] = 0;
	list_of_vertices[7][1] = 0;

   //define the detector(s)
   TGeoVolume *tetrahedron = new TGeoVolume("tetrahedron",new TGeoArb8(10.,(Double_t*) list_of_vertices),PMMA);


   //--- make the top container volume
   TGeoVolume *world = new TGeoVolume("World", new TGeoBBox( 50., 50., 50.), UHV);
   world->SetVisibility(kFALSE);
   geom->SetTopVolume(world);
   
  //add the tetrahedron
  world->AddNode(tetrahedron, 1, new TGeoTranslation(0.,0.,10.));

  TGeoVolume *substrate = new TGeoVolume("World", new TGeoBBox( 50., 50., 25.), PMMA);
  //world->AddNode(substrate, 2, new TGeoTranslation(0.,0.,-25.));

   //--- close the geometry
   geom->CloseGeometry();
   
   
   geom->SetVisLevel(4);
   world->Draw("ogle");
   
   //geom->Export("threelines_PMMA.root");
}   

After executing this script in ROOT by means of .x tetratest.C I do a raytracing of the top volume topVolume->Raytrace() and I get a strange result. On the top of the tetrahedron a kind of roof appears which seems to be of the size of the bounding box. This artefact does not appear when I use OpenGl. However, this artefact seems to have a major impact on the tracking in my geometry which consists of an assembly of TGeoArb8. Do you have any suggestions ?

Sincerely,

Aniello Esposito

Hi,

Indeed, there are numerical errors in the TGeoArb8 when one the top or bottom face is a single point. I will look into it for a fix. Meanwhile you can change:
list_of_vertices[5][1] = 1.e-8;
to make it work.

Cheers,

… or better use the root trunk that is now fixed with this respect.

Cheers,

Dear Andrei,

Thank you for the rapid fix. Now my geometry looks good when I do a Raytrace.
However, with the current trunk version there is a problem with importing *.root
files. When I export a geometry to *.root I am not able to import it anymore. The
Import causes a warning and a consecutive segfault :


root [0] TGeoManager *geom = TGeoManager::Import("threelines_PMMA.root")
Info in <TGeoManager::Import>: Reading geometry from file: threelines_PMMA.root
Warning in <TStreamerInfo::BuildCheck>: 
   The StreamerInfo of class TGeoManager read from file threelines_PMMA.root
   has the same version (=12) as the active class but a different checksum.
   You should update the version to ClassDef(TGeoManager,13).
   Do not try to write objects with the current class definition,
   the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the on-file layout version 12 of class 'TGeoManager' differs from 
the in-memory layout version 12:
   map<long,TGeoNavigatorArray*> fNavigators; //
vs
   TGeoManager::NavigatorsMap_t fNavigators; //

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

Thread 1 (process 90058):
#0  0x00007fff800b1f6c in wait4 ()
#1  0x00007fff800c6526 in system ()
#2  0x000000010011350c in TUnixSystem::StackTrace ()
#3  0x00000001001106b1 in TUnixSystem::DispatchSignals ()
#4  <signal handler called>
#5  0x000000010257c489 in TGeoNavigator::BuildCache ()
#6  0x000000010257cf12 in TGeoNavigatorArray::AddNavigator ()
#7  0x000000010256711d in TGeoManager::AddNavigator ()
#8  0x0000000102568c9f in TGeoManager::CloseGeometry ()
#9  0x0000000102568f83 in TGeoManager::Streamer ()
#10 0x000000010233fa5c in TKey::ReadObj ()
#11 0x000000010256b43d in TGeoManager::Import ()
#12 0x0000000102672410 in G__G__Geom1_185_0_232 ()
#13 0x0000000100bc7326 in Cint::G__ExceptionWrapper ()
#14 0x0000000100c8a12c in G__execute_call ()
#15 0x0000000100c8b94b in G__call_cppfunc ()
#16 0x0000000100c5f425 in G__interpret_func ()
#17 0x0000000100c4e420 in G__getfunction ()
#18 0x0000000100c1ffaa in G__getitem ()
#19 0x0000000100c2465f in G__getexpr ()
#20 0x0000000100c10a2c in G__define_var ()
#21 0x0000000100cb481b in G__exec_statement ()
#22 0x0000000100c0b69f in G__exec_tempfile_core ()
#23 0x0000000100c0b9a6 in G__exec_tempfile_fp ()
#24 0x0000000100cc2038 in G__process_cmd ()
#25 0x0000000100020e6e in TCint::ProcessLine ()
#26 0x000000010005d1f0 in TApplication::ProcessLine ()
#27 0x0000000100b2addc in TRint::HandleTermInput ()
#28 0x0000000100b29647 in TTermInputHandler::Notify ()
#29 0x0000000100b2b8bd in TTermInputHandler::ReadNotify ()
#30 0x0000000100110372 in TUnixSystem::CheckDescriptors ()
#31 0x0000000100110886 in TUnixSystem::DispatchOneEvent ()
#32 0x000000010009fd3d in TSystem::InnerLoop ()
#33 0x00000001000a2233 in TSystem::Run ()
#34 0x000000010005b747 in TApplication::Run ()
#35 0x0000000100b2b4ab in TRint::Run ()
#36 0x0000000100000990 in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x000000010257c489 in TGeoNavigator::BuildCache ()
#6  0x000000010257cf12 in TGeoNavigatorArray::AddNavigator ()
#7  0x000000010256711d in TGeoManager::AddNavigator ()
#8  0x0000000102568c9f in TGeoManager::CloseGeometry ()
#9  0x0000000102568f83 in TGeoManager::Streamer ()
#10 0x000000010233fa5c in TKey::ReadObj ()
#11 0x000000010256b43d in TGeoManager::Import ()
===========================================================

This problem did not appear in the version I used previously.

Aniello

Hi,

Looks that while upgrading the root version you still have some the old TGeoManager.h in $ROOTSYS/include. Try make distclean; make

Cheers,

I tried to compile the trunk version on several other machines from scratch but I encountered always the same problem. I checked out the latest version in /tags and I applied the changes to the TGeoArb8 class. Like this everything seems to work. I do not know why the trunk version does not work in my case.

Aniello

Hi,

Do you try to load a geometry file produced before ? What is the sequence of code that you try ?

Cheers,

Hello,

I produced and tried to import the geometries exclusively with the compiled version in the trunk.
It is also quite interesting that I was able to load old *.root files but no one generated with the
newly compiled library. However, the workaround I mentioned before works for the moment.

Another problem that I encountered also before the fix to the TGeoArb8 class is that I get an error
from TGeoArb8 saying the following:


Error in <TGeoArb8::ComputeTwist>: Shape TGeoArb8 type Arb8: Malformed polygon with crossing opposite segments
*** Shape TGeoArb8: TGeoArb8 ***
    point #0 : x=  259.30546 y=  894.80606 z= -143.29270
    point #1 : x=  259.30547 y=  894.80605 z= -143.29270
    point #2 : x=  259.30545 y=  894.80605 z= -143.29270
    point #3 : x=  259.30546 y=  894.80606 z= -143.29270
    point #4 : x=  259.30546 y=  894.80606 z=  143.29270
    point #5 : x=  796.50143 y= -444.09858 z=  143.29270
    point #6 : x=-1055.80688 y= -450.70746 z=  143.29270
    point #7 : x=  259.30546 y=  894.80606 z=  143.29270
 Bounding box:
*** Shape TGeoArb8: TGeoBBox ***
    dX =     0.00000
    dY =     0.00000
    dZ =     0.00000
    origin: x=    0.00000 y=    0.00000 z=    0.00000
Error in <TGeoArb8::ComputeTwist>: Shape TGeoArb8 type Arb8: Malformed polygon with crossing opposite segments
*** Shape TGeoArb8: TGeoArb8 ***
    point #0 : x=  619.20384 y=   -2.20296 z= -143.29270
    point #1 : x=  619.20384 y=   -2.20296 z= -143.29270
    point #2 : x=   79.35626 y= 1343.31056 z= -143.29270
    point #3 : x=   79.35626 y= 1343.31056 z= -143.29270
    point #4 : x=  619.20384 y=   -2.20296 z=  143.29270
    point #5 : x=-1235.75607 y=   -2.20296 z=  143.29270
    point #6 : x=-1235.75607 y=   -2.20296 z=  143.29270
    point #7 : x=  616.55223 y=    4.40592 z=  143.29270
 Bounding box:
*** Shape TGeoArb8: TGeoBBox ***
    dX =     0.00000
    dY =     0.00000
    dZ =     0.00000
    origin: x=    0.00000 y=    0.00000 z=    0.00000
Error in <TGeoArb8::ComputeTwist>: Shape TGeoArb8 type Arb8: Malformed polygon with crossing opposite segments
*** Shape TGeoArb8: TGeoArb8 ***
    point #0 : x=  619.20384 y=   -2.20296 z=   -0.70730
    point #1 : x=-1235.75607 y=   -2.20296 z=   -0.70730
    point #2 : x=-1235.75607 y=   -2.20296 z=   -0.70730
    point #3 : x=  616.55223 y=    4.40592 z=   -0.70730
    point #4 : x=  619.20385 y=   -2.20296 z=    0.70730
    point #5 : x=  619.20383 y=   -2.20296 z=    0.70730
    point #6 : x=  619.20383 y=   -2.20296 z=    0.70730
    point #7 : x=  619.20385 y=   -2.20296 z=    0.70730
 Bounding box:
*** Shape TGeoArb8: TGeoBBox ***
    dX =     0.00000
    dY =     0.00000
    dZ =     0.00000
    origin: x=    0.00000 y=    0.00000 z=    0.00000

I really do not understand what is wrong with the polygons. In opengl the geometry looks fine.

Aniello

Hi,
Cannot reproduce that, can you attach a small piece of code showing-up the problem. Both for the I/O and the crossing issue.

Regards,