Example B3 output as Dataset

Hi! I’m working on PET using Geant4 and it’s working but I need to make a dataset that includes informations like detector id, particle detect time to use for reconstruction. How do I do that?

To write stuff out you have to do something like this.

If you are using multithreading you will need

#ifdef G4MULTITHREADED
#include “G4Threading.hh”
#include “G4AutoLock.hh”
#endif

In, say, your stepping action

G4double eDep = step->GetTotalEnergyDeposit();

#ifdef G4MULTITHREADED
static G4Mutex stuffMutex = G4MUTEX_INITIALIZER;
G4AutoLock al(&stuffMutex);
#endif
static std::ofstream stuff(“stuff.csv”);
static bool first = true;
if (first) {
first = false;
stuff << “#,eDep/keV,…” << std::endl;
}
stuff << ‘,’ << eDep/keV /* … */ << std::endl;

Yes, i am using multithreading but the example doesn’t have a stepping action. Would run or event action be okey to write that in?

Yes, anywhere you pick up information.