Message: Re: Import Logical Volume from GDML File fails for many Files Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Import Logical Volume from GDML File fails for many Files 

Forum: Geometry
Re: Question Import Logical Volume from GDML File fails for many Files (JanW)
Date: 19 Aug, 2016
From: Witek Pokorski <Witek Pokorski>


indeed, the GDML parser hasn't been really designed to be used to read several GDML files one after the other. Normally, you assume that you read your GDML geometry and then you are done. I am not sure now in what state the reader is when you try to read the second file, and it could be that some things are not properly reset. I would need to look into it to see if some sort of 'flush' function would be possible.

Having said that, I am very surprised that it doesn't work for you if you have 2 instances of the parser. Have you really tried to do

G4GDMLParser parser1; G4GDMLParser parser2;;;

and then get the world volumes from parser1 and parser2 respectively? In my opinion, it should work and give you the two different world volumes from the two files. Please let me know.

Finally, let me also mention that you can split your GDML files into several parts using the 'entity' concept. You can read about it in the user manual It's not exactly the same use case as you describe but maybe it can help.

Cheers, Witek

 On Tue, 16 Aug 2016 07:55:14 GMT, JanW wrote:
> I want to import a Logical Volume from a GDML file and add it to my
> World, which I already have. So I have written a Function:
>     G4LogicalVolume* DetectorConstruction::GetGDMLFileAsLV(G4String fileName, 
>     G4Material* material) {
>         G4GDMLParser parser;
>         parser.Read(fileName);
>         G4LogicalVolume LogVol = *(parser.GetWorldVolume()->GetLogicalVolume());
>         LogVol->SetMaterial(material);
>         return LogVol;
>     }
> It returns me a pointer to the Logical Volume I want to include in my
> World. This works all quite fine, up to the point where I want to add a
> second volume from a second file. At this point, I get two times the
> same Logical Volume, even if the files I load them from differ. I am not
> really sure, why it is that way, I suspect that there are not really
> different instances of what happens, when I call "GetWorldVolume" for
> the two files, but rather a single point of reference, event for a new
> instance of a G4GDMLparser. Also, as I always get the first Logical
> Volume shown two times, I suspect,that after the first parser.Read(...),
> the second time I call the function (even in a new instance) I don't
> really overwrite the old data.
> So I tried copying the Logical Volume, which doesn't work, as the
> function for copying Logical Volumes is private. So I wanted to copy the
> G4VSolid, which I get when I call GetSolid() on the Logical Volume. This
> also doesn't work, as G4VSolid is abstract. Cloning it doesn't work and
> now I am stuck. It would considerably ease my work if I could import
> several Objects from several GDML files. I also don't see, why doing so
> should do any harm (where, of course, I could be very wrong there).
> Could you give any advise on this problem or do you have any idea on how
> to get around this?
> Thank you very much.

 Add Message Add Message
to: "Re: Import Logical Volume from GDML File fails for many Files"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]