Ruby extension

Dear Root developers and users,

How is the current status of the Ruby extension module described at http://root.cern.ch/root/HowtoRuby.html?
Is it possible to create a new Root file and write histograms and trees on it from a Ruby script ?
I could not find any examples doing this.

Kame

Hi Kame,

There are several examples in $ROOTSYS/tutorials - the ntuple1.rb and hsimple.rb show how to save/read objects in/from a root file.

Cheers, Ilka

Hi Ilka,
Thank you for the prompt reply.

What about making tree?
I’d like to write a variable as an integer…

Kame

Hi Kame,

There is no example for making a tree. Some info can be found on pages 30, 33 of ftp://root.cern.ch/root/RubyRoot.pdf file. For more details you might contact Elias Athanasopoulos who developped the Ruby extension module.

Cheers, Ilka

Hi Ilka,

Thank you for the information. I found the example.
Fiiling a tree from Ruby seems rather awkward as compared to from Python.
I’d like to expect it will be more refined in the near future.

Kame

Hi Kame,
My knowledge about the documentation of Ruby interface comes from my responsibilities for the ROOT User’s Guide. As I have already mentioned, this interface was developed by Elias Athanasopoulos and might be useful if you send your comments/wishes to him.
Thank you, Ilka

Hello!

You should use the TTree#via method to fill a TTree, but use it with caution, since the TTree support was a little bit hard to implement, completely transparently.

Please, see: csd.uoc.gr/~elathan/rr/docs/userguide.php

for how the TTree#via method works.

Regards,
Elias

Hi, Elias.
Glad to hear from you.

I tried to fill a tree following the example http://raa.ruby-lang.org/gonzui/markup/ruby-root/test/treerr.rb.
But the following script fails…
(Root 5.08 + Ruby 1.8.2 on Linux)

require 'libRuby'

f = TFile.new("tree1.root","recreate")
t1 = TTree.new("t1","a simple Tree with simple variables")
t1.Branch("px", 0, "px/D")
t1.Branch("py", 0, "py/D")
t1.Branch("pz", 0, "pz/D")

# fill the tree
r = TRandom.new
10000.times do |i|
  px = r.Gaus
  py = r.Gaus
  t1.via :SetBranchAddress, :Fill, { "px" => px, "py" => py, "pz" => px*px + py*py }
end

t1.Write
f.Close

Kame

Hello!

My apologies. As I saw in my sources, I found out that I have implemented TTree#via only in the static ruby-root, and not in the dynamic version which is included in the official ROOT distribution.

I can recall, that it is not hard enough to activate TTree#via in ROOT’s Ruby module. I just didn’t have the time to submit the patches (the code is actually in the CVS tree, but not enabled).

I will try to give it a shot, but I can’t promise a lot, since I have a deadline for a call for papers on 15 January; that is I’m quite busy these days.

Regards,
Elias

Hi, Elias
Thank you for the reply.

Okay, I’ll wait until you have spare time.
I started to use scripting language recently, and wavering between Ruby and Python.
I’d rather choose Ruby if I its Root interface is enough usable.
Its japanese-friendliness is one reason:)
I am willing to help if you need manpower.

Kame

Hello!

Yes. That will be certainly great, since I have very limited time for further development of this project, although, IMHO, it is very interesting and it can certainly catch up the Python module, if people show some interest.

Regards,
Elias