Geometry overlap

Hi,
I’m facing an overlap and I’m not sure how to deal with it or even if I have to. I’m creating a hollow box:

	G4Box *box_dects_out = new G4Box("box_dects_out", 353/2*mm, 25/2*mm, 250/2*mm);
	G4LogicalVolume *box_detectors_out = new G4LogicalVolume(box_dects_out, worldMat, "box_detectors_out");
	// Inner box
	G4Box *box_dects_in = new G4Box("box_dects_in", 350/2*mm, 22/2*mm, 247/2*mm);
	G4LogicalVolume *box_detectors_in = new G4LogicalVolume(box_dects_in, worldMat, "box_detectors_in");
	// Subtract the inner one from the outer one
	G4SubtractionSolid* real_box = new G4SubtractionSolid("box_detectors_out-box_detectors_in", box_dects_out, box_dects_in);
	G4LogicalVolume *real_box_log = new G4LogicalVolume(real_box, worldMat, "real_box_log");
	G4VPhysicalVolume *real_box_phys = new G4PVPlacement(0, G4ThreeVector(0.*m, -304*mm, 0.*m), real_box_log, "real_box", logicWorld, false, 1, true);

in which I’m placing a detector

// Set up detectors
G4Box solidDetector = new G4Box(“solidDetector”, 26mm, 4.5mm, 11mm);
logicDetector = new G4LogicalVolume(solidDetector, BeO, “logicDetector”);
G4VPhysicalVolume *physDetector1 = new G4PVPlacement(0, G4ThreeVector(0.mm, 0mm, 0.*mm) , logicDetector, “physDetector”, real_box_log, false, 1, true);

and when starting the app I see the following information in the terminal:

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
      issued by : G4PVPlacement::CheckOverlaps()
Overlap with mother volume !
          Overlap is detected for volume physDetector:1 (G4Box) with its mother volume real_box_log (G4SubtractionSolid)
          protrusion at mother local point (20.6714,0.00687278,-11) by 1.09931 cm  (max of 1000 cases)
NOTE: Reached maximum fixed number -1- of overlaps reports for this volume !
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

does it raise any flag or can I just move on?

When I check the situation visually, I can’t see an overlapping issue? I mean despite that the detector is within the mother volume which should be hollow, so there shouldn’t be an overlap?

alternatively, you could also fill the inner box with your world material, then place the detector as a daughter volume inside the inner box, and place the inner box as a daughter into the outer box. that should give you no uncertainties about intersecting volumes at all.

edit, as this is the marked solution: place the detector in the world volume instead of into real_box_log, as the hollow part does not belong to the hollow box anymore. then the overlap warning does not appear.

1 Like

thanks for the interesting input, will try this out!

works perfectly, thank you!
Nevertheless, out of curiosity, any idea why there is an issue with the boolean subtraction?
And also another question: When I assign a color to the outer box, the detector inside will get the same color. Is there a way to avoid this?

hm, maybe define the color for the detector after you define the color for the mother volume, or define it at all :slight_smile:

could also be that it only appears as if the detector had a color, because you have to look through your hollow box?

I figured out it takes the color of the “lowest” object it is in, in this case the inner box.

This could be true but how do I avoid this then?
Here in this gamma knife example it is possible to look through and see different colors:

gammaknife_3

l_Box->SetVisAttributes(G4Color(1., 1., 0., alpha));

thanks, but I got this already:

G4VisAttributes * red = new G4VisAttributes(G4Colour(0.8 ,0.3 ,0.5, 0.1));
red → SetVisibility(true);|
red → SetForceSolid(true);|

in the gamma knife example they even do not set this specific parameter.

what do the extra options (visibility and solid) do?

edit: check if the viewer that you use supports transparency

From changing the code SetVisibility makes an object visible or invisible and SetForceSolid shows the surfaces of an object or not.
I’d say transparency is working as I can look through the surfaces and see the objects within this volume but something is odd though.
I’m using OGL, couldn’t find information about transparency.

hm, then I don’t know. this code works for me (windows, ogl):

G4VisAttributes * red = new G4VisAttributes(G4Colour(0.8 ,0.3 ,0.5, 0.1));
    red->SetVisibility(true);
    red->SetForceSolid(true);
    G4VisAttributes * blue = new G4VisAttributes(G4Colour(0.1 ,0.3 ,0.8, 0.1));
    blue->SetVisibility(true);
    blue->SetForceSolid(true);

    G4Box *box_dects_out = new G4Box("box_dects_out", 353/2*mm, 25/2*mm, 250/2*mm);
    G4Box *box_dects_in = new G4Box("box_dects_in", 350/2*mm, 22/2*mm, 247/2*mm);
    // Subtract the inner one from the outer one
    G4SubtractionSolid* real_box = new G4SubtractionSolid("box_detectors_out-box_detectors_in", box_dects_out, box_dects_in);
    G4LogicalVolume *real_box_log = new G4LogicalVolume(real_box, worldMaterial, "real_box_log");
    new G4PVPlacement(0, G4ThreeVector(0.*m, -304*mm, 0.*m), real_box_log, "real_box", fWorldVolume, false, 0, true);
    real_box_log->SetVisAttributes(red);
    // Set up detectors
    G4Box *solidDetector = new G4Box("solidDetector", 26*mm, 4.5*mm, 11*mm);
    G4LogicalVolume *logicDetector = new G4LogicalVolume(solidDetector, worldMaterial, "logicDetector");
    new G4PVPlacement(0, G4ThreeVector(0.*mm, 0.*mm, 0.*mm) , logicDetector, "physDetector", fWorldVolume, false, 1, true);
    logicDetector->SetVisAttributes(blue);

fyi, you don’t need those:
G4LogicalVolume *box_detectors_out = ...
G4LogicalVolume *box_detectors_in = ...

did you by chance set the vis attributes for those?

edit: ok, forget about everything, I found your bug from the opening post:
you just need to place the detector into the world, and not into the hollow box :smiley:

2 Likes

Thanks for your input! But when I don’t put them into the hollow box, they won’t refer to this box anymore, or?
The background of this hollow box is that I when I move this box, the three detectors inside will automatically move with it together. This won’t work when I don’t put them inside this box?

in this case: Creating an Assembly of Volumes — Book For Application Developers 11.0 documentation

or again as in my first post :slight_smile:

Thanks for the link, will look into it!

I followed your advice already regarding the hollow box :stuck_out_tongue:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.