How to add histograms into Ntuple

Hi, I am running Pol01 example, and I need the histograms to be saved as branches inside a root tree. I made some adjustments in RunAction.cc and RunAction.hh (see attached).
I can see the tree and the branches I’ve created, but no data stored.

Any ideas?

_Geant4 Version:10.6
_Operating System: MacOs

[
RunAction.cc (13.3 KB)
](https://)
RunAction.hh (4.0 KB)


Hej,

without knowing the example by heart. Are you sure, you are putting anything into those tuples?

Also, it is unclear whether the histograms are saved but they have no entries. They are two completely different issues. If they are empty maybe you are not filling them correctly either. In case they don’t even show up… I don’t know. The “Write()” method should take care of that.

/Pico

Hello,

In your RunAction::BookHisto(), you inactivate all histograms on the line #186:

    fAnalysisManager->SetH1Activation(ih, false);

If you want to get your histograms filled, you need to set their activation to true. In Geant4 examples, this is usually done in a run macro.

Best regards,