TSpectrum and ROOT.PyBuffers

Hello!

So I’ve been trying to search the forum and web for solutions to this (without any luck).
I can’t figure out how to convert what’s returned by TSpectrum.GetPositionX(), which is a ROOT.PyFloatBuffer type object, how exactly do I go about converting that to a list of floats?

I presuuuume I have to use struct, numpy or array or some combination of these, or maybe even some function built into (Py)ROOT, but I have tried everything I could think of doing and nothing so far has worked.

Using ROOT5.34/32 and python2.7.6

1 Like

So…can’t say that I really like it, but just saw that I could iterate through it by doing:

buf = TSpectrum.GetPositionX()
buf[0]
buf[1]
… etc

Is that how you’re supposed to go about it or is there a more elegant way of doing it?

buf.SetSize(spec.GetNPeaks()) l = list(buf)
-Dom

1 Like