Hello all,
So my simulation is a modification of the LXe example, and I am attempting to write to a csv file the position at which the primary particle enters/exits a particular physical volume. To do this, I have added the following code to the UserSteppingAction method in LXeSteppingAction.cc:
if (theTrack->GetParentID() == 0)
{
if (thePostPV->GetName() == "scintillator1")
{
if (thePrePV->GetName() != "scintillator1")
{
CLHEP::Hep3Vector Det1 = theTrack->GetPosition();
std::cout << Det1[0] << std::endl;
analysisManager->FillNtupleDColumn(0, 14, Det1[0]);
}
}
}
While this does successfully print the correct position, after the simulation finishes iterating through the rest of the particles but before the event is visualized, I get a segmentation fault and crash. This happens even if I delete either the print line or the csv write line, but if I remove both leaving only the line which gets the track position, I no longer receive the fault. I am new to C++ so this may be a basic programming error, but I haven’t had luck solving the problem on other forums. Any help would be much appreciated!
Geant4 11.1.1
Windows 10 enterprise
Visual Studio 2022
CMake 3.27.1