How to overlap volumes?

I have a partially coaxial HPGe detector. Where I have a cylindrical germanium crystal with a cylindrical hole at the center, like this:

When I try to draw a cylinder of HPGe (inner radius = 0) and then draw another cylinder of vaccum (height is less than HPGe cylinder height), it shows me the warning like this for every:

In file included from /home/subhrod/G4_project/Examples_G4/zzHPGe_design/src/
/home/subhrod/G4_project/Examples_G4/zzHPGe_design/include/hpgeDetectorConstruction.hh:33:24: note: shadowed declaration is here
   33 |     G4VPhysicalVolume* physiWorld;
      |                        ^~~~~~~~~~

Will the vaccum be placed at there, even if it’s giving me the warning? And how to remove this warning?

I have set checkOverlap to true and false both but it is still showing.

The error you are showing only says that you are shadowing the physiWorld definition.

In my opinion, the best solution is to subtract two volumes from each other. This is what the G4SubtractionSolid class is for.

1 Like

Hi @MKasztelan,
It was on my mind. I have tried to do the cutting of the material for ease of coding using G4SubtractionSolid. I have written the code like:

G4double hpgeRi = 0. * cm;
    G4double hpgeRo = 3.05 * cm;
    G4double hpgeHz = 1.6 * cm;
    G4double hpgeAo = 0. * deg;
    G4double hpgeAs = 360. * deg;

    G4VSolid *hpgeTube = new G4Tubs("hpgeTube",

    //Bore Hole========
    G4double boreRi = 0. * mm;
    G4double boreRo = 7.072 * mm;
    G4double boreHz = 6.337 * mm;
    G4double boreAo = 0. * deg;
    G4double boreAs = 360. * deg;

    G4VSolid *boreTube = new G4Tubs("boreTube",
    //position of the hole wrt hpge....
    G4double boreposx = 0. * cm;
    G4double boreposy = 0. * cm;
    G4double boreposz = -(hpgeHz - boreHz);
    G4VSolid* hpgeWithBore = new G4SubtractionSolid("hpgeWithBore",                              //name of the solid
                                                    hpgeTube,                                    //parent volume
                                                    boreTube,                                    //substractor volume
                                                    0,                                           // spin of subtractor w.r.t parent
                                                    G4ThreeVector(boreposx, boreposy, boreposz)); //position w.r.t. parent

But now I am getting the error:

$ make
Scanning dependencies of target hpge
[ 12%] Building CXX object CMakeFiles/hpge.dir/
[ 25%] Building CXX object CMakeFiles/hpge.dir/src/
[ 37%] Building CXX object CMakeFiles/hpge.dir/src/
/home/subhrod/G4_project/zzHPGe_design/src/ In member function ‘virtual G4VPhysicalVolume* hpgeDetectorConstruction::Construct()’:
/home/subhrod/G4_project/zzHPGe_design/src/ error: ‘G4SubtractionSolid’ was not declared in this scope
  217 |     G4VSolid* hpgeWithBore = G4SubtractionSolid("hpgeWithBore",                              //name of the solid
      |                              ^~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/hpge.dir/build.make:89: CMakeFiles/hpge.dir/src/] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/hpge.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Can you please advise me on how to solve this issue?
Thank you.

#include "G4SubtractionSolid.hh". C++ is (or was :frowning: ) a strongly typed language. You need explicitly declare a class before attempting to use it.


Thank you @mkelsey and @MKasztelan
I thought G4SubtractionSolid is already included in G4Solid.hh header file.

1 Like

Each class has its own .hh file. G4VSolid.hh is the abstract base class for all of the concrete solids.


Yes sir,
Now I understand it fully.
Thank you so much for your support.

1 Like