Hi,
I would need to create either a TArrayF and/or a TH2F in python and would need to have access to it within ROOT.
I tried to apply to TArrayF and TH2F the example in the User’s Guide, namely:
// create a TBrowser on the Python side, and transfer it back and forth
root[] TBrowser* b = (void*)Python::Eval(“ROOT.TBrowser()”);
(class TObject*)0x8d1daa0
root[] TPython::Bind(b,“b”);
Now, if I want to do the same thing it doesn’t work for TArrayF - or at least there are some things that I don’t understand or I can’t handle.
Here is what I have for TH2F:
root [0] gSystem->Load(“libPyROOT”)
(int)0
root [1] TH2F * h = (void*)TPython::Eval(“ROOT.TH2F()”);
root [2] TPython::Bind(h, “h”);
now, going further along the lines of the User’s Guide :
root [3] TPython::Exec(“h.SetName(‘histo’)”);
root [4] TPython::Exec(“print h.GetName()”);
histo
root [5] TPython::Exec(“h.SetBins(50, 0.0, 25.0, 50, 0.0, 25.0)”);
root [6] TPython::Exec(“h.SetBinContent(25, 25, 12.34)”);
root [7] TPython::Exec(“print h.GetBinContent(25, 25)”);
12.3400001526
Now, lets see wether we have it in ROOT:
root [8] h->GetBinContent(25,25)
(const Double_t)1.23400001525878910e+001
Great. Now comes the challange: can we do the same for a TArrayF?
root [0] gSystem->Load(“libPyROOT”)
(int)0
root [1] TArrayF * a = (void*)TPython::Eval(“ROOT.TArrayF()”);
root [2] TPython::Bind(a, “a”);
Error: Function Bind(a,“a”) is not defined in current scope (tmpfile)(1)
*** Interpreter error recovered ***
No. Why doesn’t it work for TArrayF? Maybe I missed the point…
Another question: which one do you excpect to be faster: working with TArray (and TMatrix) or TH2F? E.g. loading and playing with 2D arrays.
(note: I need PyROOT just for using the Python Image Library to load multiimage TIF files.)
Thanks!
Balint