Wim Lavrijsen, LBNL1PyROOT, LBNL May 2004 PyROOT Reference Talk presented at: ROOT 2004 Users Workshop, SLAC LBNL, February 2004 (updated, May 2004) Wim.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

Copyright 2001, ActiveState. XSLT and Scripting Languages or…XSLT: what is everyone so hot and bothered about?
Physicist Interfaces Project an overview Physicist Interfaces Project an overview Jakub T. Moscicki CERN June 2003.
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Bruce Beckles University of Cambridge Computing Service
Kit Chan ATS Lua Plugin Kit Chan Hi, My name is kit.
ROOT Root Commands and CINT Functions and Fitting (The Tree Viewer)
Lecture 4: Embedded Application Framework Qt Tutorial Cheng-Liang (Paul) Hsieh ECE 424 Embedded Systems Design.
A Crash Course Python. Python? Isn’t that a snake? Yes, but it is also a...
Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
Status and Future of CINT Reflex as Reflection Database Object-Oriented CINT Multi-Threading Masaharu Goto, Agilent Philippe Canal, Fermilab Stefan Roiser,
Principles of Object-Oriented Software Development The language Java.
Doxygen: Source Code Documentation Generator John Tully.
SEAL V1 Status 12 February 2003 P. Mato / CERN Shared Environment for Applications at LHC.
Sept 11, 2003ROOT Day1, Suzanne Panacek39 ROOT An object oriented HEP analysis framework. Day 1.
ROOT An object oriented HEP analysis framework.. Computing in Physics Physics = experimental science =>Experiments (e.g. at CERN) Planning phase Physics.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Bertrand Bellenot ROOT Users Workshop Mar ROOT GUI Builder Status & Plans ROOT & External GUI World MFC, FOX, Qt, PVSS… Snapshot of the Future.
Using ROOT classes from Python ROOT Workshop October 2002 P. Mato / CERN.
Putting What We Learned Into Context – WSGI and Web Frameworks A290/A590, Fall /16/2014.
Python: Classes By Matt Wufsus. Scopes and Namespaces A namespace is a mapping from names to objects. ◦Examples: the set of built-in names, such as the.
21-Apr-2005J. Adamczewski1 DVEE C++ course 2005 The ROOT framework 1: Introduction.
K. Harrison CERN, 20th April 2004 AJDL interface and LCG submission - Overview of AJDL - Using AJDL from Python - LCG submission.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
SEAL Project Status and Plans LHCC Comprehensive Review of LCG-AA November 2003 P. Mato / CERN.
LC Software Workshop, May 2009, CERN P. Mato /CERN.
CINT & Reflex: New Reflection Data Structures Masa(haru) Goto Agilent Philippe Canal Fermilab/CD Stefan Roiser, Axel Naumann PH/SFT.
An Introduction to Python Blake Brogdon. What is Python?  Python is an interpreted, interactive, object-oriented programming language. (from python.org)
SEAL: Core Libraries and Services Project CERN/IT After-C5 Meeting 6 June 2003 P. Mato / CERN.
March 27, 2007HPC 07 - Norfolk, VA1 C++ Reflection for High Performance Problem Solving Environments Tharaka Devadithya 1, Kenneth Chiu 2, Wei Lu 1 1.
SEAL Project Overview Lorenzo Moneta/ CERN-EP on behalf of the SEAL team ACAT03 IX International Workshop on Advanced Computing and Analysis Techniques.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
SEAL: Common Core Libraries and Services for LHC Applications CHEP’03, March 24-28, 2003 La Jolla, California J. Generowicz/CERN, M. Marino/LBNL, P. Mato/CERN,
SEAL Core Libraries and Services CLHEP Workshop 28 January 2003 P. Mato / CERN Shared Environment for Applications at LHC.
THtml  THtml will generate >=1 doc.root file .html pages generated from doc.root files by April (Feb doesn't exist)  Bertrand: extract doc for online.
SEAL Project Core Libraries and Services 18 December 2002 P. Mato / CERN Shared Environment for Applications at LHC.
LC Software Workshop, May 2009, CERN P. Mato /CERN.
LHCb-ATLAS GANGA Workshop, 21 April 2004, CERN 1 DIRAC Software distribution A.Tsaregorodtsev, CPPM, Marseille LHCb-ATLAS GANGA Workshop, 21 April 2004.
SEAL Framework & Services LCG AA Internal Review 20 October, 2003 Radovan Chytracek / CERN on behalf of SEAL team.
Feedback from LHC Experiments on using CLHEP Lorenzo Moneta CLHEP workshop 28 January 2003.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Getting Started with SIDL using the ANL SIDL Environment (ASE) ANL SIDL Team MCS Division, ANL April 2003 The ANL SIDL compilers are based on the Scientific.
PHP vs. Python. Similarities are interpreted, high level languages with dynamic typing are Open Source are supported by large developer communities are.
Gaudi Framework Tutorial, Interfacing Gaudi with Python.
SEAL Project Overview LCG-AA Internal Review October 2003 P. Mato / CERN.
- LCG Blueprint (19dec02 - Caltech Pasadena, CA) LCG BluePrint: PI and SEAL Craig E. Tull Trillium Analysis Environment for the.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Sebastian Böser HepMC Visual - an interactive browser for HepMC records 1st Annual ARTEMIS Meeting 27 th September, 2007.
ROOT Team Meeting Axel Naumann CERN PH/SFT Crienftlex Extended Version. And also Director’s Cut. Crienftlex.
CINT & Reflex – The Future CINT’s Future Layout Reflex API Work In Progress: Use Reflex to store dictionary data Smaller memory footprint First step to.
The SEAL Component Model Radovan Chytracek CERN IT/DB, LCG AA On behalf of LCG/SEAL team This work received support from Particle Physics and Astronomy.
SEAL Project Status SC2 Meeting 16th April 2003 P. Mato / CERN.
LECTURE 2 Python Basics. MODULES So, we just put together our first real Python program. Let’s say we store this program in a file called fib.py. We have.
Project Work Plan SEAL: Core Libraries and Services 7 January 2003 P. Mato / CERN Shared Environment for Applications at LHC.
Status of SEAL LCG Applications Area Meeting 22 July 2003 P. Mato / CERN Contents Overview Work Packages Status Summary.
2001 ROOT Workshop The Summary. Content Most Requested Request already satisfied Build and Distribution Web Page Information and Documentation.
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
T. Meyer ROD Software Workshop July 2002 Scripting and Interpreted Languages Tom Meyer Iowa State University
ACAT 2008 Axel Naumann (CERN), Philippe Canal (Fermilab) The Role of Interpreters in High Performance Computing.
Optimization of Python-bindings Wim T.L.P. Lavrijsen, LBNL ROOT Meeting, CERN; 01/15/10 C O M P U T A T I O N A L R E S E A R C H D I V I S I O N.
September 24th 2006, aKademy The Design and Implementation of KJSEmbed Richard Moore,
How to Get Started With Python
SEAL: Common Core Libraries and Services for LHC Applications
SEAL Project Overview Lorenzo Moneta/ CERN-EP ACAT03
Principles of programming languages 4: Parameter passing, Scope rules
Dirk Düllmann CERN Openlab storage workshop 17th March 2003
National Energy Research Scientific Computing Center (NERSC)
SEAL Project Core Libraries and Services
The ROOT framework 1: Introduction
Presentation transcript:

Wim Lavrijsen, LBNL1PyROOT, LBNL May 2004 PyROOT Reference Talk presented at: ROOT 2004 Users Workshop, SLAC LBNL, February 2004 (updated, May 2004) Wim Lavrijsen, LBNL

2PyROOT, LBNL May 2004 Outline Motivation, history, and context Goal Overview User-level and examples Design and implementation Status, future development Resources

Wim Lavrijsen, LBNL3PyROOT, LBNL May 2004 Motivation The case for Python: Used for scientific programming ( Including high performance and distributed parallel code 2 nd most popular scripting language Wide-spread use as a “glue language” The case for PyROOT: Access ROOT from non-ROOT applications Utilize pre-existing Python bindings from ROOT

Wim Lavrijsen, LBNL4PyROOT, LBNL May 2004 Example: pyQt import sys, ROOT from qt import * theApp = QApplication( sys.argv ) box = QVBox() box.resize( QSize(40,10).expandedTo(box.minimumSizeHint()) ) class myButton ( QPushButton ): def __init__( self, label, master ): QPushButton.__init__( self, label, master ) self.setFont( QFont( "Times", 18, QFont.Bold ) ) def browse( self ): self.b = ROOT.TBrowser() bb = myButton( "browser", box ) QObject.connect( bb, SIGNAL( "clicked()" ), bb.browse ) theApp.setMainWidget( box ) box.show() theApp.exec_loop()

Wim Lavrijsen, LBNL5PyROOT, LBNL May 2004 History PyROOT saw light as “RootPython” Developed by Pere Mato Resides in the Gaudi (the LHCb framework) repository PyROOT inherited ideas, but all code rewritten: Use Python C-API only Closer in style to Python, more generic towards ROOT Large improvement in performance Was part of SEAL, now released with ROOT 4

Wim Lavrijsen, LBNL6PyROOT, LBNL May 2004 SEAL Shared Environment for Applications at LHC Provide LHC common core and services libraries Foundation class libraries (system, utility, etc. libs) Framework services (includes scripting) Improve coherency of LCG apps Strategy of pluggable components One such component is PyROOT

Wim Lavrijsen, LBNL7PyROOT, LBNL May 2004 Goal A “bridge” between ROOT and Python Main library loadable in both CINT and Python Objects can cross interpreters' boundary Note: work in progress... see later in this presentation Allow Python callbacks from CINT and vv. Completely reflection-based No code generation necessary Run-time binding generated as needed

Wim Lavrijsen, LBNL8PyROOT, LBNL May 2004 ROOT Features ROOT basically uses only ROOT classes Almost all derive from TObject and have a TClass Rather consistent in class, variable naming Simple C++ (no cov. return, templates, fct hiding, etc.) None of the above is needed, but makes life real easy! Extensive reflection information CINT dictionary Includes signatures, scopes, default arguments, etc.

Wim Lavrijsen, LBNL9PyROOT, LBNL May 2004 Ex.: ROOT from Python >>> from ROOT import gRandom, TCanvas, TH1F >>> c1 = TCanvas('c1','Example',200,10,700,500) >>> hpx = TH1F('hpx','px',100,-4,4) >>> for i in xrange(25000):... px = gRandom.Gaus()... hpx.Fill(px)... >>> hpx.Draw() >>> c1.Update()

Wim Lavrijsen, LBNL10PyROOT, LBNL May 2004 Ex.: Python from ROOT root[0] gSystem->Load( “libPyROOT” ) root[1] TPython::Exec( “print 1 + 1” ) 2 root[2] Tbrowser* b = (Tbrowser*) TPython::Eval( “ROOT.TBrowser()” ) (class TBrowser*)0x8d1daa0 root[3] TPython::Prompt() >>> i = 2; ^D root[4] TPython::Prompt() >>> print i 2

Wim Lavrijsen, LBNL11PyROOT, LBNL May 2004 PyROOT Conceptual Design - 1 Python interpreter Lookup in ROOT namespace ROOT libraries ROOT class?TClass PyClass PyClass = PyClass_New( TClass::GetName() ) PyDict = PyClass.__dict__ for all TMethods from TClass : name = TMethod::GetName() if not name in PyDict : PyDict[ name ] = MethodDispatcher( TMethod* ) else : PyDict[ name ].addMethod( TMethod* ) return PyClass CINT PyClass method call

Wim Lavrijsen, LBNL12PyROOT, LBNL May 2004 Example in Detail... >>> from ROOT import TCanvas [ import ROOT.py, attempts to retrieve TCanvas ] >>> c1 = TCanvas('c1','Example',200,10,700,500) [ object construction in both Python and ROOT ] >>> c1.Update() [ member call into ROOT from Python ]

Wim Lavrijsen, LBNL13PyROOT, LBNL May 2004 ROOT.py Loads PyROOT.so module Exc. hook and module facade to capture names Lookup names by cache or by ROOT Instantiated/bound if correctable Re-execute code in the proper stack frame Transparent to the end-user Fires up a thread to feed system events to ROOT

Wim Lavrijsen, LBNL14PyROOT, LBNL May 2004 Example in Detail... >>> from ROOT import TCanvas [ import ROOT.py, attempts to retrieve TCanvas ] >>> c1 = TCanvas('c1','Example',200,10,700,500) [ object construction in both Python and ROOT ] >>> c1.Update() [ member call into ROOT from Python ]

Wim Lavrijsen, LBNL15PyROOT, LBNL May 2004 ConstructorDispatcher PythonCINT TCanvas.__init__( *args )execute selected G__CallFunc hash args and select overload wrap result (ObjectHolder) c1 = TCanvas( 'c1', 'Example',.... new TCanvas( arg1, arg2,... ) setup G__CallFunc (MethodHolder) PyROOT

Wim Lavrijsen, LBNL16PyROOT, LBNL May 2004 Example in Detail... >>> from ROOT import TCanvas [ import ROOT.py, attempts to retrieve TCanvas ] >>> c1 = TCanvas('c1','Example',200,10,700,500) [ object construction in both Python and ROOT ] >>> c1.Update() [ member call into ROOT from Python ]

Wim Lavrijsen, LBNL17PyROOT, LBNL May 2004 MethodDispatcher Python TCanvas.Update( c1 )execute selected G__CallFunc setup G__CallFunc (MethodHolder) wrap result if necessary c1.Update() TCanvas_object -> Update() None PyObject or ObjectHolder CINTPyROOT extract TObject* (from PyObject)

Wim Lavrijsen, LBNL18PyROOT, LBNL May 2004 PyROOT Conceptual Design - 2 Python interpreter ROOT libraries root [0] Python::eval( “expression” ) python, context = GetInterpreter(), GetContext() result = python.evaluate( “expresion”, context ) if result : TObject* robj = convertToROOT( result ) else: reportError() TObject* robj = 0 return robj CINT TPython.h + rootcint Run string TObject*

Wim Lavrijsen, LBNL19PyROOT, LBNL May 2004 TPython.h Use rootcint and appropriate LinkDef.h: class TPython { public: void Exec( char* statement ); TPyReturn& Eval( char* expression ); bool Bind( TObject* obj, char* label ); void Prompt(); //... }

Wim Lavrijsen, LBNL20PyROOT, LBNL May 2004 Callbacks >>> from ROOT import TControlBar, TBrowser >>> bar = TControlBar('vertical','Demo') >>> bar.AddButton('browser',...r'TPython::Exec("b = TBrowser()”);',...'The ROOT browser')... >>> bar.Show()

Wim Lavrijsen, LBNL21PyROOT, LBNL May 2004 Interpreter Crossing For now, only for objects w/ CINT dictionary: root [1] TBrowser* b = new TBrowser() root [2] TPython::Bind( b, “b” ) (bool)1 root [3] Tbrowser* b1 = (Tbrowser*) Python::Eval( “b” ) (class TBrowser*)0x894d3d8 root [4] b == b1 (int)1

Wim Lavrijsen, LBNL22PyROOT, LBNL May 2004 Status ROOT tutorial examples all work Performance is good enough Python from ROOT is minimal so far Little (natural) support for basic ROOT classes TString, TArrayF, etc. Some functionality got lost in the move to C-API

Wim Lavrijsen, LBNL23PyROOT, LBNL May 2004 PyROOT Resources Released as part of SEAL /afs/cern.ch/sw/lcg/app/releases/SEAL SEAL repository: Scripting/PyROOT Documentation: Examples provided with PyROOT installation

Wim Lavrijsen, LBNL24PyROOT, LBNL May 2004 Other Resources Python, boost.python bindings ROOT SEAL project portal