Re: [ROOT] Import geometry file

From: Andrei Gheata (Andrei.Gheata@cern.ch)
Date: Wed Apr 14 2004 - 13:33:14 MEST


Hi Paolo,

If you look carefully to the output you get when running your 5 lines, 
you will notice the following 2:

| Warning in <TGeoManager::dtor>: deleting previous geometry: /
| ===> ,  created

This means that when you read the geometry from file, your:
 > TGeoManager *geo=new TGeoManager();
is deleted and a new TGeoManager class is created. Since you rely on 
your geo object later to fetch some volume, you naturally get a crash.

So, either do as I adviced in my previous mail:
  gSystem->Load("libGeom")
  TGeoManager::Import("geomfile.root"); // this is static so you don't 

                                        //need an object to call it
  TGeoManager *geo = gGeoManager
  ...

OR:
  replace geo->GetVolume("EXPH") with gGeoManager->GetVolume("EXPH");

Regards,
Andrei

paolo maestro wrote:
> Hi ,
> I have regenerated the geometry file with the latest version of ROOT.
> The geometry file has been generated in the context of a VMC application
> using the TGeoMCGeometry class.
> Then in a new ROOT session I tried to re-open  the file  with
> 
> gSystem->Load("libGeom")
> TGeoManager *geo=new TGeoManager();
> geo->Import("geomfile.root")
> TGeoVolume* EXPH=geo->GetVolume("EXPH");
> EXPH->Draw();
> 
> But I still got a crash when trying to get the EXPH volume.
> I send you in attachment the geometry file.
> I would like to stress the fact that the same procedure works fine
> with ROOT 3.10.01 and in that case it's possible to draw the geometry
> with those 5 lines of code.
> Thanks
>                 Paolo
> 
> Andrei Gheata wrote:
> 
>> Hi Paolo,
>>
>> I have no idea why you get a segv, but the way to import the geometry is:
>> root[0]   gSystem->Load("libGeom");
>> root[1]   TGeoManager::Import("geomfile.root");
>> ...
>>
>> Try it this way. If you still get a crash, send me your geometry file.
>> It is possible that TGeo have some backward incompatibility related to
>> I/O. Otherwise, regenerate (if you still can) the geomfile.root with a
>> more recent version.
>>
>> Regards,
>> Andrei
>>
>> paolo maestro wrote:
>> > Hi  rooters,
>> > I created a detector geometry in a world wolume called EXPH using the
>> > TGeo classes and exported it
>> > to a file geomfile.root.
>> > Using Root version 3.10.01 with the following code ,  I  can draw the
>> > geometry
>> > previously saved in the file
>> >
>> > TGeoManager *geo=new TGeoManager();
>> > geo->Import("geomfile.root")
>> > TGeoVolume* EXPH=geo->GetVolume("EXPH");
>> > EXPH->Draw();
>> >
>> > I noticed that with version 3.10.02 and 4.xx , this simple code does 
>> not
>> > work anymore
>> > and gives seg. violation at the third line (of course for all the Root
>> > version, I created a related  geomfile.root )
>> > when I'm trying to get the world volume.
>> > What I'm doing  wrong ? Which changes do I have to apply?
>> > Thanks
>> >
>> >         Paolo
>> >
>> >
>> > --
>> > Paolo Maestro
>> > Universita' di Siena-INFN
>> > Phone ++39-050-2214349
>> >       ++39-050-2214356
>> > Fax   ++39-050-2214317
>> >
>> >
>>
> -- 
> Paolo Maestro 
> Universita' di Siena-INFN
> Phone ++39-050-2214349
>       ++39-050-2214356
> Fax   ++39-050-2214317
> 
>  



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET