How to convert this ROOT.PyIntBuffer class to an integer or array object that can be handled by python? (PyROOT and Marley related)

Hello everyone!

I am trying to plot energies of deexcitation products of nue-Ar40 reactions. Per page 58 of this document (toward the end of the page): https://arxiv.org/pdf/2101.11867.pdf, the pdg codes of the deexcitation products (pdgp) are given in a int[np] data type while the energies (Ep) are given in a double[np] data type. From my understanding (which may be incredibly incorrect) these are arrays of size np, though I do not know what np is.

My code currently looks like this:

import ROOT
from ROOT import TFile, TDirectory, TTree, TH1F, TCanvas, TF1, TH2F, TBranch, TBranchElement
import math

f5 = ROOT.TFile.Open("/home/.../En_dist_10_50_1_flat.root")
mst = f5.mst

for e in mst:
    print(type(e.pdgp))
output:   <class 'ROOT.PyIntBuffer'>

How do I convert the e.pdgp type to an integer or array data type or a data type that python can convert to an integer or array?

Specifically, I want to convert the pdg code to an object, like an integer, that can be iterated with to find the energies of the deexcitation particles. I want these energies to be integers that can be used to fill a histogram.

I have uploaded the root file used in my code here

It was too big to upload on the forums.

Any help would be greatly appreciated!


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.19/01
Platform: Ubuntu Linux version 5.4.0-107-generic
Compiler: Not Provided


Hello,

Have you tried iterating on e.pdgp? That should give you the integers in that buffer.

You can also try to do import numpy as np; arr = np.asarray(e.pdgp) to convert it to a numpy array and work with that. I know this is supported in more recent versions of ROOT (>= 6.24), but not sure for 6.19.

Cheers,

Enric