Overlapping volumes when re-initializing geometries

Hello everyone,

I am trying to implement Generic Messengers to change my geometry via UI and macro commands.
However, when I try to do so and then reinitialize the geometry afterward, the simulation crashes and gives me an error saying there are overlaps with the mother volume.

Here is a segment of the error:

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
      issued by : G4PVPlacement::CheckOverlaps()
Overlap with mother volume !
          Overlap is detected for volume physDetector:0 (G4Box) with its mother volume logicWorld (G4Box)
          protrusion at mother local point (0.610813,0.0235502,-1.9) by 1.8 mm  (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 -------

Checking overlaps for volume physDetector:1 (G4Box) ... 
-------- 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 logicWorld (G4Box)
          protrusion at mother local point (1.02205,3.588,-1.31121) by 3.488 mm  (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 -------





-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : GeomMgt0002
      issued by : G4SmartVoxelHeader::BuildNodes()
PANIC! - Overlapping daughter with mother volume.
         Daughter physical volume physDetector
         is entirely outside mother logical volume logicWorld !!
*** Fatal Exception *** core dump ***
 **** Track information is not available at this moment
 **** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

And here is the code where I implement the solid sensitive detectors:


	G4Box *solidDetector = new G4Box("solidDetector", xPixel, yPixel, zPixel);  //setting the dimensions for the detectors

	logicDetector = new G4LogicalVolume(solidDetector, worldMat, "logicDetector"); //creating the detectors, with same material as world


	for(G4int i = 0; i < nRows; i++)
	{

		for(G4int j = 0; j < nCols; j++)
		{
		    posX = -xDet+(i*2*xPixel);

		    posY = -yDet+(j*2*yPixel);

		    posZ = zWorld - zPixel;

			G4VPhysicalVolume *physDetector= new G4PVPlacement(0, G4ThreeVector(posX, posY, posZ), logicDetector, "physDetector", logicWorld, false, j+i*nCols, true); //placing detectors into the world

		}
	}







	return physWorld; //returning the world, including everything inside
}

void MyDetectorConstruction::ConstructSDandField()
{
    MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector"); //creating a sensitive detector object

    if(logicDetector != NULL)
    {
       logicDetector->SetSensitiveDetector(sensDet); //assigning the detectors as senstive detectors (it generates a hit when a track traverses its volume)
    }
}

The message an overlap with the mother volume means that the volume, mentioned in the message, extends beyond its mother volume. It your case some volumes are placed entirely outside their mother. Please check the dimensions of the volumes and how the daughter volumes are placed in the World volume.

Hello, thanks for replying to my problem.

I would understand the dimensions being an issue if this message occurred instantly, but my volumes place fine initially. However, when I reinitialise the geometry via the command ‘/run/reinitializeGeometry’, and click run, it provides this error.

Does it perhaps have something to do with the detector volume IDs? maybe upon reinitialization, the same set of IDs is being produced? - but this doesn’t fit with the error saying the reinitialized volumes are being placed entirely outside the mother volume. There is nothing in the dimensions to suggest why that is happening - especially seeing that they place fine upon the first run of the simulation…

1 Like

It’s not clear from the provided code where is the problem. The warnings say that physDetector:0 and physDetector:1 extend beyond the World volume. Try to print out the positions of all physDetector volumes.

Hello, Thanks again for replying so quickly!

Here is the code for my ‘construction.cc’ file:

#include "construction.hh"


MyDetectorConstruction::MyDetectorConstruction()
{
    dMessenger = new G4GenericMessenger(this, "/detector/", "Detector Construction");
    wMessenger = new G4GenericMessenger(this, "/world/", "World Construction");
    aMessenger = new G4GenericMessenger(this, "/aerogel/", "Aerogel Construction");
    mMessenger = new G4GenericMessenger(this, "/materials/", "Materials");

    dMessenger->DeclareProperty("nCols", nCols, "Number of columns");
    dMessenger->DeclareProperty("nRows", nRows, "Number of rows");
    dMessenger->DeclareProperty("xDet", xDet, "X length of detector");
    dMessenger->DeclareProperty("yDet", yDet, "Y length of detector");

    wMessenger->DeclareProperty("xWorld", xWorld, "X length of world");
    wMessenger->DeclareProperty("yWorld", yWorld, "Y length of world");
    wMessenger->DeclareProperty("zWorld", zWorld, "Z length of world");

    aMessenger->DeclareProperty("xAerogel", xAerogel, "X length of aerogel");
    aMessenger->DeclareProperty("yAerogel", yAerogel, "Y length of aerogel");
    aMessenger->DeclareProperty("zAerogel", zAerogel, "Z length of aerogel");
    aMessenger->DeclareProperty("dAerogel", dAerogel, "Distance from aerogel to detectors");
    aMessenger->DeclareProperty("rAerogel", rAerogel, "Refractive index of aerogel");

    mMessenger->DeclareProperty("mRadiator", mRadiator, "Radiator material");
    mMessenger->DeclareProperty("mWorld", mWorld, "World material");


    nCols = 10;
    nRows = 10;

    xWorld = 0.05*m;
    yWorld = 0.05*m;
    zWorld = 0.05*m;

    xAerogel = 0.02*m;
    yAerogel = 0.02*m;
    zAerogel = 0.005*m;
    dAerogel = 0.04*m;
    rAerogel = 1.1;

    xDet = 0.012*m;
    yDet = 0.012*m;

    xPixel = xDet/nCols;
    yPixel = yDet/nRows;
    zPixel = 0.001*m;

    mRadiator = 2; // 1 = water, 2 = aerogel
    mWorld = 3; // 3 = air



    DefineMaterials();

}

MyDetectorConstruction::~MyDetectorConstruction()
{}

void MyDetectorConstruction::DefineMaterials()
{
    G4NistManager *nist = G4NistManager::Instance();  //the geant4 nist material database

	G4Material *SiO2 = new G4Material("SiO2", 2.201*g/cm3, 2); //defining the silicone dioxide material object
	SiO2->AddElement(nist->FindOrBuildElement("Si"), 1);  //adding the silicone element to the object
	SiO2->AddElement(nist->FindOrBuildElement("O"), 2); //adding the oxygen element to the object

	G4Material *H2O = new G4Material("H2O", 1.000*g/cm3, 2); //defining h20 material object
	H2O->AddElement(nist->FindOrBuildElement("H"), 2); //adding the hydrogen element to object
	H2O->AddElement(nist->FindOrBuildElement("O"), 1); //adding the oxygen element to object

	G4Element *C = nist->FindOrBuildElement("C"); //creating the carbon material object

	G4double energy[2] = {1.239841939*eV/0.9, 1.239841939*eV/0.2}; //momentum of photons usng conversion factor *eV / wavlength of red light and blue light

	G4double rindexAerogel[2] = {rAerogel, rAerogel}; //refractive index of aerogel
	G4double rindexAir[2] = {1.0, 1.0}; //refractive index of the world volume (air)
	G4double rindexWater[2] = {1.333, 1.333}; //refractive index of the world volume (water)

    if(mWorld == 3)
    {
        worldMat = nist->FindOrBuildMaterial("G4_AIR"); //createing the world material (air)
	    G4MaterialPropertiesTable *mptWorld = new G4MaterialPropertiesTable(); //creating properites object for air
	    mptWorld->AddProperty("RINDEX", energy, rindexAir, 2); //adding property to object
	    worldMat->SetMaterialPropertiesTable(mptWorld); //assigning properties object to world material object

    }



    if(mRadiator == 2)
    {

        radiatorMat = new G4Material("Aerogel", 0.200*g/cm3, 3); //creating the aerogel material object
	    radiatorMat->AddMaterial(SiO2, 62.5*perCent);  //adding the silione dioxide material to aerogel object
	    radiatorMat->AddMaterial(H2O, 37.4*perCent);  //adding the h20 material to aergoel object
	    radiatorMat->AddElement(C, 0.1*perCent);  //adding the carbon material to aerogel object
	    G4MaterialPropertiesTable *mptAerogel = new G4MaterialPropertiesTable(); //creating aerogel material properties object
	    mptAerogel->AddProperty("RINDEX", energy, rindexAerogel, 2); //adding property to this object
	    radiatorMat->SetMaterialPropertiesTable(mptAerogel); //assigning the Aergoel object the properties from the previous object created

    }
    if(mRadiator == 1)
    {
        radiatorMat = nist->FindOrBuildMaterial("G4_WATER"); //createing the radiator material (water)
	    G4MaterialPropertiesTable *mptRadiator = new G4MaterialPropertiesTable(); //creating properites object for water
	    mptRadiator->AddProperty("RINDEX", energy, rindexWater, 2); //adding property to object
	    radiatorMat->SetMaterialPropertiesTable(mptRadiator); //assigning properties object to radiator material object

    }



}

G4VPhysicalVolume *MyDetectorConstruction::Construct()
{

	G4Box *solidWorld = new G4Box("solidWorld", xWorld, yWorld, zWorld); //setting up world volume as a box

	G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, worldMat, "logicWorld"); //creating the world as dimensions from box and material

	G4VPhysicalVolume *physWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicWorld, "physWorld", 0, false, 0, true); //placing the world into geant 4 sim

	G4Box *solidRadiator = new G4Box("solidRadiator", xAerogel, yAerogel, zAerogel); //setting the dimensions for the radiator

	G4LogicalVolume *logicRadiator = new G4LogicalVolume(solidRadiator, radiatorMat, "logicRadiator"); //creating the aergoel radiator from dimensions

	G4VPhysicalVolume *physRadiator = new G4PVPlacement(0, G4ThreeVector(0., 0., zWorld - dAerogel), logicRadiator, "physRadiator", logicWorld, false, 0, true); //placing radiator into world volume

	G4Box *solidDetector = new G4Box("solidDetector", xPixel, yPixel, zPixel);  //setting the dimensions for the detectors

	logicDetector = new G4LogicalVolume(solidDetector, worldMat, "logicDetector"); //creating the detectors, with same material as world


	for(G4int i = 0; i < nRows; i++)
	{

		for(G4int j = 0; j < nCols; j++)
		{
		    posX = -xDet+(i*2*xPixel);

		    posY = -yDet+(j*2*yPixel);

		    posZ = zWorld - zPixel;

			G4VPhysicalVolume *physDetector= new G4PVPlacement(0, G4ThreeVector(posX, posY, posZ), logicDetector, "physDetector", logicWorld, false, j+i*nCols, true); //placing detectors into the world

			G4cout << posX << " " << posY << " " << posZ << G4endl;

		}
	}







	return physWorld; //returning the world, including everything inside
}

void MyDetectorConstruction::ConstructSDandField()
{
    MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector"); //creating a sensitive detector object

    if(logicDetector != NULL)
    {
       logicDetector->SetSensitiveDetector(sensDet); //assigning the detectors as senstive detectors (it generates a hit when a track traverses its volume)
    }
}

Here is the terminal output of my detector positions upon the first run: (all in mm)

Checking overlaps for volume physRadiator:0 (G4Box) ... OK! 
Checking overlaps for volume physDetector:0 (G4Box) ... OK! 
-12 -12 49
Checking overlaps for volume physDetector:1 (G4Box) ... OK! 
-12 -9.6 49
Checking overlaps for volume physDetector:2 (G4Box) ... OK! 
-12 -7.2 49
Checking overlaps for volume physDetector:3 (G4Box) ... OK! 
-12 -4.8 49
Checking overlaps for volume physDetector:4 (G4Box) ... OK! 
-12 -2.4 49
Checking overlaps for volume physDetector:5 (G4Box) ... OK! 
-12 0 49
Checking overlaps for volume physDetector:6 (G4Box) ... OK! 
-12 2.4 49
Checking overlaps for volume physDetector:7 (G4Box) ... OK! 
-12 4.8 49
Checking overlaps for volume physDetector:8 (G4Box) ... OK! 
-12 7.2 49
Checking overlaps for volume physDetector:9 (G4Box) ... OK! 
-12 9.6 49
Checking overlaps for volume physDetector:10 (G4Box) ... OK! 
-9.6 -12 49
Checking overlaps for volume physDetector:11 (G4Box) ... OK! 
-9.6 -9.6 49
Checking overlaps for volume physDetector:12 (G4Box) ... OK! 
-9.6 -7.2 49
Checking overlaps for volume physDetector:13 (G4Box) ... OK! 
-9.6 -4.8 49
Checking overlaps for volume physDetector:14 (G4Box) ... OK! 
-9.6 -2.4 49
Checking overlaps for volume physDetector:15 (G4Box) ... OK! 
-9.6 0 49
Checking overlaps for volume physDetector:16 (G4Box) ... OK! 
-9.6 2.4 49
Checking overlaps for volume physDetector:17 (G4Box) ... OK! 
-9.6 4.8 49
Checking overlaps for volume physDetector:18 (G4Box) ... OK! 
-9.6 7.2 49
Checking overlaps for volume physDetector:19 (G4Box) ... OK! 
-9.6 9.6 49
Checking overlaps for volume physDetector:20 (G4Box) ... OK! 
-7.2 -12 49
Checking overlaps for volume physDetector:21 (G4Box) ... OK! 
-7.2 -9.6 49
Checking overlaps for volume physDetector:22 (G4Box) ... OK! 
-7.2 -7.2 49
Checking overlaps for volume physDetector:23 (G4Box) ... OK! 
-7.2 -4.8 49
Checking overlaps for volume physDetector:24 (G4Box) ... OK! 
-7.2 -2.4 49
Checking overlaps for volume physDetector:25 (G4Box) ... OK! 
-7.2 0 49
Checking overlaps for volume physDetector:26 (G4Box) ... OK! 
-7.2 2.4 49
Checking overlaps for volume physDetector:27 (G4Box) ... OK! 
-7.2 4.8 49
Checking overlaps for volume physDetector:28 (G4Box) ... OK! 
-7.2 7.2 49
Checking overlaps for volume physDetector:29 (G4Box) ... OK! 
-7.2 9.6 49
Checking overlaps for volume physDetector:30 (G4Box) ... OK! 
-4.8 -12 49
Checking overlaps for volume physDetector:31 (G4Box) ... OK! 
-4.8 -9.6 49
Checking overlaps for volume physDetector:32 (G4Box) ... OK! 
-4.8 -7.2 49
Checking overlaps for volume physDetector:33 (G4Box) ... OK! 
-4.8 -4.8 49
Checking overlaps for volume physDetector:34 (G4Box) ... OK! 
-4.8 -2.4 49
Checking overlaps for volume physDetector:35 (G4Box) ... OK! 
-4.8 0 49
Checking overlaps for volume physDetector:36 (G4Box) ... OK! 
-4.8 2.4 49
Checking overlaps for volume physDetector:37 (G4Box) ... OK! 
-4.8 4.8 49
Checking overlaps for volume physDetector:38 (G4Box) ... OK! 
-4.8 7.2 49
Checking overlaps for volume physDetector:39 (G4Box) ... OK! 
-4.8 9.6 49
Checking overlaps for volume physDetector:40 (G4Box) ... OK! 
-2.4 -12 49
Checking overlaps for volume physDetector:41 (G4Box) ... OK! 
-2.4 -9.6 49
Checking overlaps for volume physDetector:42 (G4Box) ... OK! 
-2.4 -7.2 49
Checking overlaps for volume physDetector:43 (G4Box) ... OK! 
-2.4 -4.8 49
Checking overlaps for volume physDetector:44 (G4Box) ... OK! 
-2.4 -2.4 49
Checking overlaps for volume physDetector:45 (G4Box) ... OK! 
-2.4 0 49
Checking overlaps for volume physDetector:46 (G4Box) ... OK! 
-2.4 2.4 49
Checking overlaps for volume physDetector:47 (G4Box) ... OK! 
-2.4 4.8 49
Checking overlaps for volume physDetector:48 (G4Box) ... OK! 
-2.4 7.2 49
Checking overlaps for volume physDetector:49 (G4Box) ... OK! 
-2.4 9.6 49
Checking overlaps for volume physDetector:50 (G4Box) ... OK! 
0 -12 49
Checking overlaps for volume physDetector:51 (G4Box) ... OK! 
0 -9.6 49
Checking overlaps for volume physDetector:52 (G4Box) ... OK! 
0 -7.2 49
Checking overlaps for volume physDetector:53 (G4Box) ... OK! 
0 -4.8 49
Checking overlaps for volume physDetector:54 (G4Box) ... OK! 
0 -2.4 49
Checking overlaps for volume physDetector:55 (G4Box) ... OK! 
0 0 49
Checking overlaps for volume physDetector:56 (G4Box) ... OK! 
0 2.4 49
Checking overlaps for volume physDetector:57 (G4Box) ... OK! 
0 4.8 49
Checking overlaps for volume physDetector:58 (G4Box) ... OK! 
0 7.2 49
Checking overlaps for volume physDetector:59 (G4Box) ... OK! 
0 9.6 49
Checking overlaps for volume physDetector:60 (G4Box) ... OK! 
2.4 -12 49
Checking overlaps for volume physDetector:61 (G4Box) ... OK! 
2.4 -9.6 49
Checking overlaps for volume physDetector:62 (G4Box) ... OK! 
2.4 -7.2 49
Checking overlaps for volume physDetector:63 (G4Box) ... OK! 
2.4 -4.8 49
Checking overlaps for volume physDetector:64 (G4Box) ... OK! 
2.4 -2.4 49
Checking overlaps for volume physDetector:65 (G4Box) ... OK! 
2.4 0 49
Checking overlaps for volume physDetector:66 (G4Box) ... OK! 
2.4 2.4 49
Checking overlaps for volume physDetector:67 (G4Box) ... OK! 
2.4 4.8 49
Checking overlaps for volume physDetector:68 (G4Box) ... OK! 
2.4 7.2 49
Checking overlaps for volume physDetector:69 (G4Box) ... OK! 
2.4 9.6 49
Checking overlaps for volume physDetector:70 (G4Box) ... OK! 
4.8 -12 49
Checking overlaps for volume physDetector:71 (G4Box) ... OK! 
4.8 -9.6 49
Checking overlaps for volume physDetector:72 (G4Box) ... OK! 
4.8 -7.2 49
Checking overlaps for volume physDetector:73 (G4Box) ... OK! 
4.8 -4.8 49
Checking overlaps for volume physDetector:74 (G4Box) ... OK! 
4.8 -2.4 49
Checking overlaps for volume physDetector:75 (G4Box) ... OK! 
4.8 0 49
Checking overlaps for volume physDetector:76 (G4Box) ... OK! 
4.8 2.4 49
Checking overlaps for volume physDetector:77 (G4Box) ... OK! 
4.8 4.8 49
Checking overlaps for volume physDetector:78 (G4Box) ... OK! 
4.8 7.2 49
Checking overlaps for volume physDetector:79 (G4Box) ... OK! 
4.8 9.6 49
Checking overlaps for volume physDetector:80 (G4Box) ... OK! 
7.2 -12 49
Checking overlaps for volume physDetector:81 (G4Box) ... OK! 
7.2 -9.6 49
Checking overlaps for volume physDetector:82 (G4Box) ... OK! 
7.2 -7.2 49
Checking overlaps for volume physDetector:83 (G4Box) ... OK! 
7.2 -4.8 49
Checking overlaps for volume physDetector:84 (G4Box) ... OK! 
7.2 -2.4 49
Checking overlaps for volume physDetector:85 (G4Box) ... OK! 
7.2 0 49
Checking overlaps for volume physDetector:86 (G4Box) ... OK! 
7.2 2.4 49
Checking overlaps for volume physDetector:87 (G4Box) ... OK! 
7.2 4.8 49
Checking overlaps for volume physDetector:88 (G4Box) ... OK! 
7.2 7.2 49
Checking overlaps for volume physDetector:89 (G4Box) ... OK! 
7.2 9.6 49
Checking overlaps for volume physDetector:90 (G4Box) ... OK! 
9.6 -12 49
Checking overlaps for volume physDetector:91 (G4Box) ... OK! 
9.6 -9.6 49
Checking overlaps for volume physDetector:92 (G4Box) ... OK! 
9.6 -7.2 49
Checking overlaps for volume physDetector:93 (G4Box) ... OK! 
9.6 -4.8 49
Checking overlaps for volume physDetector:94 (G4Box) ... OK! 
9.6 -2.4 49
Checking overlaps for volume physDetector:95 (G4Box) ... OK! 
9.6 0 49
Checking overlaps for volume physDetector:96 (G4Box) ... OK! 
9.6 2.4 49
Checking overlaps for volume physDetector:97 (G4Box) ... OK! 
9.6 4.8 49
Checking overlaps for volume physDetector:98 (G4Box) ... OK! 
9.6 7.2 49
Checking overlaps for volume physDetector:99 (G4Box) ... OK! 
9.6 9.6 49

Based on the positions given by the errors, it seems as if none of the positions is correct. I am not sure why this is the case…

Initial geometry looks good:

If you want to change the geometry via UI commands then you will have to explicitly “open/close” the geometry, please see the following chapter:

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomDynamic.html

I don’t think I understand what this is asking me to do, or where in my code to implement this.

Apparently, when you run the command ‘/run/reinitializeGeomety’ it automatically runs the command ‘/run/geometryModified’

so the UI commands are meant to be opening and closing the geometry for you.

image

My issue seems that it is placing the geometry in the wrong place, and not showing the new placements upon reinitialization.

And I know its nothing wrong with my placement in the ‘construction.cc’ file, as when I manually change the parameterization variables it places the volumes fine.
So it just seems to be a problem with my messengers.

1 Like