Deleting Logical Volumes in Loop

Hi! I am trying to iterate my x-ray target thickness through 1um-30um. I am trying to do this by iterating through a file called Thickness.txt using a while loop in detectorConstruction.cc. In my while loop, I have the below code to ensure the target volume is replaced on each iteration to prevent overlaps. However, I am still getting error messages related to geometry overlap of TargetPhysical with TargetPhysical (the associated physical volume here). Is there something wrong with the way I am deleting the logical volume? Am I missing something here?

if (TargetLogic) {
    delete TargetLogic->GetSolid();
    delete TargetLogic;
    }

there is documentation on this topic here:
https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomDynamic.html

perfect! Thank you :slight_smile:

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