ROOT logo
ROOT » BINDINGS » PYROOT » TPySelector

class TPySelector: public TSelector

                      Python equivalent PROOF base class


 The problem with deriving a python class from a PyROOT bound class and then
 handing it back to a C++ framework, is that the virtual function dispatching
 of C++ is completely oblivious to the methods overridden in python. To work
 within the PROOF (C++) framework, a python class should derive from the class
 TPySelector. This class provides the proper overrides on the C++ side, and
 then forwards them, as apropriate, to python.

 This is an example set of scripts:

 ### PROOF running script, very close to equivalent .C (prooftest.py)
 import time
 from ROOT import *

 dataset = TDSet( 'TTree', 'h42' )
 dataset.Add( 'root:// .... myfile.root' )

 proof = TProof.Open('')
 time.sleep(1)                     # needed for GUI to settle
 print dataset.Process( 'TPySelector', 'aapje' )
 ### EOF

 ### selector module (aapje.py, name has to match as per above)
 from ROOT import TPySelector

 class MyPySelector( TPySelector ):
    def Begin( self ):
       print 'py: beginning'

    def SlaveBegin( self, tree ):
       print 'py: slave beginning'

    def Process( self, entry ):
       if self.fChain.GetEntry( entry ) <= 0:
          return 0
       print 'py: processing', self.fChain.MyVar
       return 1

   def SlaveTerminate( self ):
       print 'py: slave terminating'

   def Terminate( self ):
       print 'py: terminating'
 ### EOF

Function Members (Methods)

public:
TPySelector(TTree* = 0, PyObject* self = 0)
virtual~TPySelector()
virtual voidAbort(const char* why, TSelector::EAbort what = kAbortProcess)
virtual voidTSelector::Abort(const char* why, TSelector::EAbort what = kAbortProcess)
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidBegin(TTree* tree = 0)
virtual voidTSelector::Begin(TTree*)
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
static TClass*TSelector::Class()
static TClass*TObject::Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual TSelector::EAbortTSelector::GetAbort() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tGetEntry(Long64_t entry, Int_t getall = 0)
virtual Int_tTSelector::GetEntry(Long64_t, Int_t = 0)
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual const char*TSelector::GetOption() const
virtual Option_t*TObject::GetOption() const
virtual TList*TSelector::GetOutputList() const
static TSelector*TSelector::GetSelector(const char* filename)
virtual Long64_tTSelector::GetStatus() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidInit(TTree* tree)
virtual voidTSelector::Init(TTree*)
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual TClass*TSelector::IsA() const
virtual TClass*TObject::IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
static Bool_tTSelector::IsStandardDraw(const char* selec)
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tNotify()
virtual Bool_tTSelector::Notify()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject&TObject::operator=(const TObject& rhs)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Bool_tProcess(Long64_t entry)
virtual Bool_tTSelector::Process(Long64_t)
virtual Bool_tTSelector::ProcessCut(Long64_t)
virtual voidTSelector::ProcessFill(Long64_t)
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidTSelector::SetInputList(TList* input)
virtual voidTSelector::SetObject(TObject* obj)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTSelector::SetOption(const char* option)
virtual voidTSelector::SetStatus(Long64_t status)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidTSelector::ShowMembers(TMemberInspector& insp, char* parent)
virtual voidTObject::ShowMembers(TMemberInspector& insp, char* parent)
virtual voidSlaveBegin(TTree* tree)
virtual voidTSelector::SlaveBegin(TTree*)
virtual voidSlaveTerminate()
virtual voidTSelector::SlaveTerminate()
virtual voidStreamer(TBuffer& b)
virtual voidTSelector::Streamer(TBuffer& b)
virtual voidTObject::Streamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
voidTSelector::StreamerNVirtual(TBuffer& b)
voidTObject::StreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
virtual voidTerminate()
virtual voidTSelector::Terminate()
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual Int_tVersion() const
virtual intTSelector::Version() const
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
PyObject*CallSelf(const char* method, PyObject* pyobject = 0)
voidSetupPySelf()

Data Members

public:
TTree*fChain
protected:
TSelector::EAbortTSelector::fAbortabort status
TList*TSelector::fInputlist of objects available during processing
TObject*TSelector::fObjectcurrent object if processing object (vs. TTree)
TStringTSelector::fOptionoption given to TTree::Process
TSelectorList*TSelector::fOutputlist of objects created during processing
Long64_tTSelector::fStatusselector status
private:
PyObject*fPySelf! actual python object

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

void SetupPySelf()
PyObject* CallSelf(const char* method, PyObject* pyobject = 0)
 Forward <method> to python.
TPySelector(TTree* = 0, PyObject* self = 0)
 Construct a TSelector derived with <self> as the underlying, which is
 generally 0 to start out with in the current PROOF framework.
~TPySelector()
 Destructor. Reference counting for the held python object is in effect.
Int_t Version() const
 Return version number of this selector. First forward; if not overridden, then
 yield an obvious "undefined" number,
Int_t GetEntry(Long64_t entry, Int_t getall = 0)
 Boilerplate get entry; same as for generated code; not forwarded.
void Init(TTree* tree)
 Initialize with the current tree to be used; not forwarded (may be called
 multiple times, and is called from Begin() and SlaveBegin() ).
Bool_t Notify()
 Forward call to derived Notify() if available.
void Begin(TTree* tree = 0)
 First function called, and used to setup the python self; forward call.
void SlaveBegin(TTree* tree)
 First function called on worker node, needs to make sure python self is setup,
 then store the tree to be used, initialize client, and forward call.
Bool_t Process(Long64_t entry)
 Actual processing; call is forwarded to python self.
void SlaveTerminate()
 End of client; call is forwarded to python self.
void Terminate()
 End of job; call is forwarded to python self.
void Abort(const char* why, TSelector::EAbort what = kAbortProcess)
 If no 'why' given, read from python error