Runs finishing before they are supposed to and outputting a corrupt TTree

Hello. I’m a beginner in GEANT4 and I’m trying to make an application that writes information about particle and hit positions to a TTree on a ROOT file. However, it seems as though when I run this program (I use electron.mac from my macro folder) it crashes after a single event or so.

Here is the link to my git:

I have created some G4cout lines to pinpoint where the error is occurring and apparently, it is happening when the method Write() on line 220 of is being called. I’m not sure where I’m supposed to be looking or what my error might be. Any assistance is appreciated :slight_smile: