Python macro and histogram with variable bin width

Hi
I tried to make a histogram with variable bin width in python, but was
not successful.

Somehow this constructor seems not to be recognized…

Here is the code:


from ROOT import *

binLowE = [2,4,9,15,20,22]

uniformTau = TH1D(“uniformTau”,"",5,binLowE)

uniformTau.FillN(5,10)

uniformTau.Draw()


TypeError: none of the 6 overloaded methods succeeded.

Please help.
Cheers Angi

Angi,

the TH1::FillN() isn’t going to work with just two arguments, but to show how to pass a list through a double* pointer:[code]from ROOT import *
from array import array

binLowE = [2,4,9,15,20,22]
uniformTau = TH1D(“uniformTau”,"",5,array(‘d’,binLowE))
#uniformTau.FillN(5,10)
uniformTau.Draw()[/code]
I.e. just use an array from module array. The buffer interface does the rest.

HTH,
Wim

3 Likes