- jeromel's home page
- Posts
- 2020
- 2019
- 2018
- 2017
- 2016
- 2015
- December (1)
- November (1)
- October (2)
- September (1)
- July (2)
- June (1)
- March (3)
- February (1)
- January (1)
- 2014
- 2013
- 2012
- 2011
- 2010
- December (2)
- November (1)
- October (4)
- August (3)
- July (3)
- June (2)
- May (1)
- April (4)
- March (1)
- February (1)
- January (2)
- 2009
- December (3)
- October (1)
- September (1)
- July (1)
- June (1)
- April (1)
- March (4)
- February (6)
- January (1)
- 2008
- My blog
- Post new blog entry
- All blogs
Quick PyROOT tests
The ROOT web site has a page How to use Use the Python PyROOT Interpreter, a good start for users of PyROOT.
Steps however are not as described in setting up your environment. The only thing you need to do in STAR is:
setenv PYTHONPATH $ROOTSYS/lib
then do two quick tests to very if the Py/ROOT binding works:
Test 1: Python from ROOT
% root root.exe [0] p = new TPython(); root.exe [1] p->Exec("print 1+1"); 2 root.exe [2] .q
Test 2 (equivalent)
% root root.exe [0] gSystem->Load("libPyROOT"); root.exe [1] TPython::Exec("print 1+1"); 2 root.exe [2] .q
Test 3: ROOT from Python
Simple test
Create a script test.py containing somehting like
#!/usr/bin/env python import sys from ROOT import * def main(): print "hello world \n" return if __name__ == '__main__': main()
This doesn't do much but will test if the import ROOT works. If so, go to a more exciting test such as
% python Python 2.4.6 (#1, Dec 2 2009, 14:44:07) [GCC 4.3.2 20081007 (Red Hat 4.3.2-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from ROOT import gROOT, TCanvas, TF1 >>> gROOT.Reset() >>> c1 = TCanvas( 'c1', 'Example with Formula', 200, 10, 700, 500 ) >>> fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10 ) >>> c1.SetGridx() >>> c1.SetGridy() >>> fun1.Draw() >>> c1.Update() >>>
The result should be a canvas with the function drawn.
If all works, you are set.
Groups:
- jeromel's blog
- Login or register to post comments