How to handle sensitive detector on UI geometry change

Hello,

I am having trouble resolving an error/warning, related to the sensitive detector, I get when I redefine my detector geometry via UI commands. The redefinition involves a volume change, so as far as I can tell, I have to delete and re-instantiate the logical volume. If I don’t delete the attached sensitive detector (even after using ->Activate("/Detector",false):wink: I get the following warning:

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : DET1010
issued by : G4SDStructure::AddNewDetector()
Cathode had already been stored in /. Object pointer is overwitten.
It’s users’ responsibility to delete the old sensitive detector object.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

However, if I try and delete the sensitive detector object, the simulation crashes on exit when the run manager is deleted.

I looked at the documentation but couldn’t find any information there on the proper handling of sensitive detectors in this case. It seems wrong to me to just produce a dangling object in memory and not properly delete it.

Any help is appreciated.

Thanks,

Michael

Hello!

I’m having the same problem. I was wondering, have you figured out a solution?

Thank you!

Genevieve

I think so / maybe. I no longer try to delete the logical volume. When I change the geometry, I de-register the solids, delete them, redefine the geometry and then set the new solids with the same logical volumes as before. For example:

  G4SolidStore::GetInstance()->DeRegister(InnerSolid);
  delete InnerSolid;
  DefineGeometry();  
  GuideCoreLogical->SetSolid(InnerSolid);

In this case the sensitive detector stays the same, since it is associated with the logical volume, which does not get deleted.

Perhaps if you must delete everything, you may need put up with a dangling instance of the sensitive detector. Or the warning message is old and the instance is deleted automatically anyway. I am not sure.