How to create a hollow box?

I want to make a hollow box and then place another small box of different material in the hollow region. I used the following code.

G4Box *outerBox = new G4Box("Outer Box",5*mm,5*mm,5*mm);
G4LogicalVolume *outerBoxlogic = new G4LogicalVolume (outerBox, lead, "Outer Box Logic",0,0,0);
new G4PVPlacement (0, G4ThreeVector(0,0,0), outerBoxlogic,"Outer Box Phys", fpWorldLogical, false, 0);
G4VisAttributes *outerBoxVis = new G4VisAttributes (G4Colour(1,0,0));
outerBoxlogic -> SetVisAttributes (outerBoxVis);

G4Box *innerBox = new G4Box("Inner Box",2*mm,2*mm,5*mm);
G4LogicalVolume *innerBoxlogic = new G4LogicalVolume (innerBox, vacuum, "Inner Box Logic",0,0,0);
new G4PVPlacement (0, G4ThreeVector(0,0,0), innerBoxlogic,"Inner Box Phys", fpWorldLogical, false, 0);
G4VisAttributes *innerBoxVis = new G4VisAttributes (G4Colour(1,0,1));
innerBoxlogic -> SetVisAttributes (innerBoxVis);

G4SubtractionSolid *hollowBoxmaking = new G4SubtractionSolid("Hollow Box making",outerBox,innerBox);

G4Box *insidehollow_region = new G4Box("Inside Hollow region",1*mm,1*mm,1*mm);
G4LogicalVolume *insidehollow_region_logic = new G4LogicalVolume (insidehollow_region, water, "Inside Hollow region logic",0,0,0);
new G4PVPlacement (0, G4ThreeVector(0,0,0), insidehollow_region_logic,"Inside Hollow region Phys", fpWorldLogical, false, 0);
G4VisAttributes *hollowBoxVis = new G4VisAttributes (G4Colour(1,1,1));
insidehollow_region_logic -> SetVisAttributes (hollowBoxVis);

The above code doesn’t work for some reason. To check if my code has worked or not, i tried passing beam through it and hits the outer box, even though I have made hollow region inside it by using G4SubtractionSolid. Can someone help me this.

Once this is done successfully, I need to make another hollow box but with cylindrical hollow region.

Thank you very much!

No need to do all that. Just place the smaller box inside the larger one. In Geant4 the daughter’s material replaces that of the mother.

1 Like

@Aqsa-physics: What you wanted to do is the following:

  1. Create Box A
  2. Create Box B
  3. Subtract Box B from A → Obtain the subtraction solid, which is your new solid here that you want to go on with
  4. Create the logical volume from the subtraction solid and place the subtraction solid

Your problem is that you do not handle further the subtraction solid as the “new” solid to progress with.

What you also can do is to the other described way:

  1. Create Box A + logical
  2. Create Box B + logical
  3. Place Box B in Box A (as mother volume)

If you would like to have other shapes like the cylindrical hollow region inside you just do the same, but with the other shape subtracted or placed from/in the Box A.

1 Like

I am using this lines of code and it is working fine.

auto worldBox = new G4Box(“worldBox”, 0.5m, 0.5m, 0.5m);
auto logicalWorld = new G4LogicalVolume(worldBox, vaccum, “LogicalWorld”);
auto physicalWorld = new G4PVPlacement(0, {0,0,0}, logicalWorld, “World”, 0, false, 0);
double length = 50.0
cm, width = 10.0cm, skin = 3.0mm;
auto detectorExterior = new G4Box(“detectorBoxE”, length/2, width/2, width/2);
auto detectorInterior = new G4Box(“detectorBoxI”, length/2-skin, width/2-skin, width/2-skin);
auto detectorWall = new G4SubtractionSolid(“detectorBox”,detectorExterior,detectorInterior);
auto logDetectorWall = new G4LogicalVolume(detectorWall, ssteel, “logDetectorWall”);
auto physDetectorWall = new G4PVPlacement(0, {0,0,0}, logDetectorWall, “DetectorWall”, logicalWorld, false, 0);

1 Like