TPySelector.h is missing?

I have a ROOT/PyROOT based project. It successfully rungs for ROOT 6.20, and I wanted to update it for a more recent version of ROOT, namely to 6.23.01 from ROOT (LCG)-nightlies.
And I’ve observed that the file TPySelector.h is missing. Also it is not mentioned in the ROOT documentation for 6.22 and master versions.
Is it obsolete? If so , what is the recommended replacement?

% pwd
% find . -name ‘‘Selector.’

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

PyROOT has seen a major update in 6.22. I’m not surprised things are different, but I am surprised if things disappear without notice or replacement.

@etejedor, can you give a comment on what happened?


Citing some text in TPySelector.cxx in the old PyROOT:

// 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.

In the new PyROOT (more precisely in cppyy), during cross-inheritance Python-C++, there is an automatic creation of a C++ wrapper class which inherits from the C++ base class and forwards the call to Python for those methods that have been overridden in Python. Therefore, the functionality offered by TPySelector should be covered by cppyy.

I would be happy to guide you through this migration, which would start by simply making your Python class inherit directly from ROOT.TSelector, instead of using the middle man TPySelector.At the moment we don’t have any PROOF tutorial that makes use of this functionality, so I would be happy to include this as a tutorial too, if you agree, so that other users can benefit from it.


Hi Eric,
Indeed I am not using PROOF.
My typical usage of python-based selector is a loop over the TTree-entries and fill RooDataSet for some entries of interest. This is no-PROOF operation.

I will make a try to bypass the TPySelector class and inherit directly from TSelector. Unfortunately it cold take some time, since I need to build my project, and currently there are several problems, which I am trying to solve (missing TPySelector.h is not the only one issue).


I see, well let me know how it goes and if I can help. It would be useful anyway, even if not related to PROOF, if we could make some kind of tutorial out of your code.

I’ve got some progress and the simplest configuration work, however there are some a bit strange. features…
first, I’ve introduced some intermediate C++ class with non-default constructor, and it seems that I can not call it:
class Selector2 ( Ostap.Selector ) :
“”“Useful intermediate class for implementation of (py)selectors
## constructor
def init ( self , tree = 0 ) :
“”“Standart constructor
## initialize the base
if root_version < 62200 : Ostap.Selector.init ( self , self , tree )
else : Ostap.Selector.init ( self , tree )

where C++ class Ostap::Selector has a constructor from TTree*
and I get an error “no constructor available”

File “/afs/”, line 141, in init
else : Ostap.Selector.init ( self , tree )
TypeError: no constructor available for ‘Ostap::Selector’

Am I doing something wrong or it is a “feature”? What is the correct soltuion for this problem?


We detected a problem in the inheritance Python-C++ that this PR is trying to solve:

Inheriting from TSelector is also affected:

But I’m not sure you are hitting the same issue here. Do you think you can come up with a standalone reproducer? I understand Ostap.Selector is a C++ class that inherits from TSelector?

Yes, Ostap::Selector is very simple C++ class that inherits form TSelector.
I can make “simple” reproducer tomorrow.

I’ve prepared very simple reproducer:

That is great, thanks a lot!

I will have a look and get back to you.


Your issue is related to:

We are working on it.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.