Pass TPySelector Object to tree.Process

Hi Wim,

I’ve only been able to find examples of this form:

tree.Process( 'TPySelector', 'aapje' )

What I would like to be able to do is

from aapje import MyPySelector
pySelector = MyPySelector()
#play with pySelector
dataset.Process(pySelector)
#leaving out information where I've defined dataset and so on...

I read somewhere that the workers need to be made aware of the module name, how do I do this?
Basically I need a quick example how to pass TPySelector instance to TTree::Process.

Thanks for all your help over the last year!

Cheers,

Peter

Peter,

instances don’t get passed: each worker creates its own. The second argument to the TPySelector constructor (“aapje” in the example) is the name of a python module that is to contain the TPySelector derived class. It should be locatable through the normal means (PYTHONPATH, most like) on the worker nodes.

Cheers,
Wim

Hi Wim,

Thanks for your reply.

I came across this thread which made me think passing an instance would be possible:

But, rereading I probably misinterpreted. However, I am in a situation where it would be very beneficial to be able to configure a very general TPySelector instance on the fly and then use this in TTree::Process. Is there some way to configure the TPySelector object without hard coding it into the module?

Thanks,

Peter

Peter,

well, what I’m missing is the connection between use of TTree::Process(pySelector) and the use of workers. If you call TTree::Process by handing it an instance of a TSelector derived class, what happens is that the tree is run through that local selector only (that is, if I’m not misreading the code; haven’t tried). So, no workers involved in that case.

Which one are you trying to accomplish? Run locally with a local instance, or on multiple (non-local) workers?

Cheers,
Wim