Ruby/CERNLIB

Japanese page is here.

Ruby/CERNLIB is a collection of Ruby extension libraries to access various CERN Program Library, such as HBOOK, HIGZ, MATHLIB and so on.

What's new

Ruby/CERNLIB ver.0.3 release. (2003/12/13)

Why Ruby/CERNLIB?

CERNLIB and PAW are still widely used, although there are several projects with the aim to replace them, for example, LHC++, ROOT, AIDA. In order to use CERNLIB routines, however, a user have to spend long compiling and linking time. Althogh PAW has its own macro language, KUMAC, it has only very limited features as a programing language (consider to read variously-formatted text files and to fill a N-tuple).

Ruby/CERNLIB provides much more conveinient way to use CERNLIB routines with the power of Ruby. This is quite useful for small programs and prototyping. For example, you can calculate Clebsch-Gordan coefficient <j1,j2,m1,m2|j1,j2,J,M> = <3/2,1,3/2,-1|3/2,1,5/2,1/2> even with one-liner on command line:

% ruby -r cern/mathlib -e 'p CERN::Mathlib.dtclgn(3,2,5,3,-2,1)'

Features

Currently, this package contains following modules.

Fortran
Fortran-style file I/O.
HBook
Histograms and N-tuples.
HIGZ
Graphics.
HPlot
Histogram plotting.
Mathlib
Mathematical routines.
PHTools
Phase-space calculation
GEANT
Detector description and simulation tools
HBook2
More Object-Oriented Histogram and N-tuple classes.

Here is a very simple script to create a histogram.

  require 'cern/hbook'
  include CERN::HBook
  
  hlimit NWPAWC
  hbook1 10, 'test histogram', 10, 0.0, 10.0, 0.0
  1000.times do
    x = rand * 10
    hfill 10, x, 0.0, 1.0
  end
  hrput 10, 'testhist.rz', 'N'
This code using HBook2 module is equivalent to above:
  require 'cern/hbook2'
  include CERN::HBook2
  
  hist = Hist1.new(10, 'test histogram', 10, 0.0, 10.0)
  1000.times do
    x = rand * 10
    hist << x
  end
  hist.write 'testhist.rz'

Download

current version: ruby-cernlib-0.3.tar.gz

My development environment:

License

Ruby's term.

History

ver 0.3 (2003/12/13)
Now Ruby/CERNLIB can be built with Ruby 1.8. (Thanks to Juan Alcaraz.)
Use packlib_noshift if it exists. Ruby/CERNLIB seems not to work with "shift" libraries after year 2001. (Thanks to Juan Alcaraz.)
New modules: PHTools, GEANT.
Add some new methods and new examples.
Fix some bugs.
Now subclasses can be made for each class in HBook2.
ver 0.2 (2002/5/5)
Add HBook2 module.
Now complex number is an instance of Complex class.
Add routines for random number generation to Mathlib.
ver 0.1 (2002/4/15)
Initial release.

ToDo

Link

CERN IT Department
The newest version of CERNLIB can be downloaded from here.
RubyRoot
ROOT-Ruby binding using SWIG.
ruby-root
Another ROOT-Ruby binding.


back to my Ruby page(Japanese)


back to my home page(Japanese)


TAKAHASHI Hitoshi (hitoshi.takahashi@kek.jp)