Package Ganga :: Package Lib :: Package Root :: Module Root' :: Class Root :: Class _proxyClass
[hide private]
[frames] | no frames]

Class _proxyClass

source code

    object --+    
             |    
GPIProxyObject --+
                 |
                Lib.Root.Root'.Root._proxyClass


    Root application -- running ROOT
    
    To run a job in ROOT you need to specify the CINT script to be
    executed. Additional files required at run time (shared libraries,
    source files, other scripts, Ntuples) should be placed in the
    inputsandbox of the job. Arguments can be passed onto the script using
    the 'args' field of the application.

    Defining a Simple Job:

    As an example the script analysis.C in the directory ~/abc might
    contain:

    void analysis(const char* type, int events) {
      std::cout << type << "  " << events << std::endl;
    }

    To define an LCG job on the Ganga command line with this script, 
    running in ROOT version 5.14.00b with the arguments 'MinBias' 
    and 10, you would do the following:

    r = Root()
    r.version = '5.14.00b'
    r.script = '~/abc/analysis.C'
    r.args = ['Minbias', 10]

    j = Job(application=r, backend=LCG())
    
    Using Shared Libraries:

    If you have private shared libraries that should be loaded you need to
    include them in the inputsandbox. Files you want back as a result of
    running your job should be placed in your outputsandbox. 
    
    The shared library mechanism is particularly useful in order to create 
    a thin wrapper around code that uses precompiled libraries, or
    that has not been designed to work in the CINT environment.
    
    **For more detailed instructions, see the following Wiki page:**
    
    https://twiki.cern.ch/twiki/bin/view/ArdaGrid/HowToRootJobsSharedObject
    
    A summary of this page is given below:
    
    Consider the follow in CINT script, runMain.C, that makes use of a ROOT 
    compatible shared library:
    
    void runMain(){
      //set up main, eg command line opts
      char* argv[] = {"runMain.C","--muons","100"};
      int argc = 3;
  
      //load the shared library
      gSystem->Load("libMain");

      //run the code
      Main m(argv,argc);
      int returnCode = m.run();
    }
    
    The class Main is as follows and has been compiled into a shared
    library, libMain.so. 
    
    Main.h:
    
    #ifndef MAIN_H
    #define MAIN_H
    #include "TObject.h"

    class Main : public TObject {

        public:
          Main(){}//needed by Root IO
          Main(char* argv[], int argc);
          int run();
  
          ClassDef(Main,1)//Needed for CINT
    };
    #endif
    
    Main.cpp:
    
    #include <iostream>
    using std::cout;
    using std::endl;
    #include "Main.h"

    ClassImp(Main)//needed for CINT
    Main::Main(char* arvv[], int argc){
      //do some setup, command line opts etc
    }

    int Main::run(){
      cout << "Running Main..." << endl;
      return 0;
    }

    To run this on LCG, a Job could be created as follows:
    
    r = Root()
    r.version = '5.12.00' #version must be on LCG external site
    r.script = 'runMain.C'
    
    j = Job(application=r,backend=LCG())
    j.inputsandbox = ['libMain.so']

    It is a requirement that your script contains a function with the same
    name as the script itself and that the shared library file is built to
    be binary compatible with the Grid environment (e.g. same architecture 
    and version of gcc). As shown above, the wrapper class must be made CINT 
    compatible. This restriction does not, however, apply to classes used by 
    the wrapper class. When running remote (e.g. LCG) jobs, the architecture
    used is 'slc3_ia32_gcc323' if the Root version is 5.16 or earlier and
    'slc4_ia32_gcc34' otherwise. This reflects the availability of builds
    on the SPI server:
    
    http://service-spi.web.cern.ch/service-spi/external/distribution/
         
     
    For backends that use a local installation of ROOT the location should
    be set correctly in the [Root] section of the configuration.
    
    Using Python and Root:
    
    The Root project provides bindings for Python, the language supported by 
    the Ganga command line interface. These bindings are referred to as PyRoot.
    A job is run using PyRoot if the script has the '.py' extension or the 
    usepython flag is set to True.
    
    There are many example PyRoot scripts available in the Root tutorials. 
    A short example is given below:
    
    gengaus.py:
    
    if __name__ == '__main__':
        from ROOT import gRandom
        
        output = file('gaus.txt','w')
        try:
            for i in range(100):
                print >>output, gRandom.Gaus()
        finally:
            output.close()
            
    The above script could be run in Ganga as follows:
            
    r = Root()
    r.version = '5.14.00'
    r.script = '~/gengaus.py'
    r.usepython = True #set automatically for '.py' scripts
    
    j = Job(application=r,backend=Local())
    j.outputsandbox = ['gaus.txt']
    j.submit()

    When running locally, the python interpreter used for running PyRoot jobs
    will default to the one being used in the current Ganga session.
    The Root binaries selected must be binary compatible with this version.

    The pythonhome variable in the [Root] section of .gangarc controls which
    interpreter will be used for PyRoot jobs.
        
    When using PyRoot on a remote backend, e.g. LCG, the python version that
    is used will depend on that used to build the Root version requested.
    
    

Properties:

     args      List of arguments for the script. Accepted types are numerics and
               strings. (simple property, list, default=[],comparable)

     version   The version of Root to run. (simple property,
               default='5.18.00',comparable)

     usepython Execute 'script' using Python. The PyRoot libraries are added to
               the PYTHONPATH.. (simple property, default=False,comparable)

     script    A File object specifying the script to execute when Root starts.
               ('files' object, default=File(name='',subdir='.'),comparable)

Nested Classes [hide private]
  _impl
This is a Ganga.GPI.Root implementation class.
Instance Methods [hide private]
 
__eq__(self, x)
Equality operator (==), compare the Root properties which are declared as [comparable].
source code
 
__init__(self, *args, **kwds)
GPI Root object constructor: Root() : create root with default settings; Root(r) : make a copy of r; Root(r,x=a,...): make a copy of r and set property 'x' to a, etc..
source code
 
__ne__(self, x)
Non-equality operator (!=).
source code
 
__repr__(self)
Return an short representation of Root object.
source code
 
__setattr__(self, x, v)
Set a property of Root with consistency and safety checks.
source code
 
__str__(self)
Return a printable string representing Root object as a tree of properties.
source code
 
copy(self)
Make an identical copy of self.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
  args = <Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object at ...
  script = <Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object a...
  usepython = <Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor objec...
  version = <Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwds)
(Constructor)

source code 

GPI Root object constructor: Root() : create root with default settings; Root(r) : make a copy of r; Root(r,x=a,...): make a copy of r and set property 'x' to a, etc..

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

Return an short representation of Root object.

Overrides: object.__repr__

__setattr__(self, x, v)

source code 

Set a property of Root with consistency and safety checks. Setting a [protected] or a unexisting property raises AttributeError.

Overrides: object.__setattr__

__str__(self)
(Informal representation operator)

source code 

Return a printable string representing Root object as a tree of properties.

Overrides: object.__str__

Class Variable Details [hide private]

args

Value:
<Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object at 0x2fe2450>

script

Value:
<Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object at 0x2fe25d0>

usepython

Value:
<Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object at 0x2fe2550>

version

Value:
<Ganga.GPIDev.Base.Proxy.ProxyDataDescriptor object at 0x2fe24d0>