Python array in TH2 construction

Dear experts,

I got an error when using Python array in TH2 construction. Could you please help me?

import ROOT
import array
my_array = array.array('f', [0,1,2])
test_th1 = ROOT.TH1F("","",2,my_array) #this works
test_th2 = ROOT.TH2F("","",2,my_array,2,my_array) #also works
test2_th2 = ROOT.TH2F("","",2,my_array,2,0,2) #doesn't work

The error message is

TH2F::TH2F(const char* name, const char* title, int nbinsx, const double* xbins, int nbinsy, double ylow, double yup) =>
    could not convert argument 4

Thank you and looking forward to your reply

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.12/07
Platform: SLF 7.8 (Nitrogen)
Compiler: Not Provided


The overload expects a const double*, so you need to create an array of doubles my_array = array.array('d', [0,1,2]).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.