How to run proof on more than one TTree?

Hello,

My input root files have two TTree-s and I need to use branches from both of them when processing events. I am able to use PROOF on one of the trees in the usual way : ttree1->Process(“myTSelector.C+”). I would like to know whether there is some smart ways how to pass the second tree to ‘myTSelector’? I don’t really want to make it hardcoded in myTSelector.C file rather to have it configurable in a main script (where lives the above ‘ttree1->Process(“myTSelector.C+”)’ ). Thank you very much in advance.

BTW, is it foreseen to implement TChain::Process(TSelector*, char*) method in the next ROOT release? I believe It would be very useful.

Best regards,
Gia Khoriauli

[quote]BTW, is it foreseen to implement TChain::Process(TSelector*, char*) method in the next ROOT release? I believe It would be very useful.
[/quote]Humm … this function has existed for as long as the TTree equivalent …

[quote]I would like to know whether there is some smart ways how to pass the second tree to ‘myTSelector’?[/quote]This is done by using a TChain instead of a TTree.

Cheers,
Philippe.

Hi Philippe,

Thanks much for the reply. Sorry, I was incorrect. I meant another class method, TProofChain::Process(TSelector*,…). I see that it’s not implemented yet: http://root.cern.ch/viewvc/trunk/tree/src/TProofChain.cxx?view=markup&pathrev=11359

Therefore, when I am doing the following:

myChain->SetProof(); myChain->Process(mySelectorObj);

I am getting the following message:

So, if running analysis with proof the only option is to use myChain->Process("mySelector.C+")

which makes mySelector hard to configure in a supervisor routine.

As to your second comment I didn’t mean the same TTree from the different files but the different TTrees in each file of a data set. If the method above was working it would be very easy to handle this case. The way I am doing it now is quite ugly. That’s why I asked if somebody already knew some intelligent solution.

Cheers, Gia

[quote=“pcanal”][quote]BTW, is it foreseen to implement TChain::Process(TSelector*, char*) method in the next ROOT release? I believe It would be very useful.
[/quote]Humm … this function has existed for as long as the TTree equivalent …

[quote]I would like to know whether there is some smart ways how to pass the second tree to ‘myTSelector’?[/quote]This is done by using a TChain instead of a TTree.

Cheers,
Philippe.[/quote][/url][/code]

Hi Gia,

I’m afraid that there is not simple solution. But if you’re willing to do it in a bit more complicated fashion, it can be done.

You have two very handy functions in TSelector: Init(TTree*) and Notify(). I don’t really remember why I chose to do it like that, but what I do right now is that in Init(TTree*) I save the pointer to the input tree (this is the TTree that I give to PROOF), and then in Notify() I do something like this (pseudo code!):

[code]TFile* file = 0;
if( I_run_on_PROOF ) {
file = main_tree->GetCurrentFile();
} else {
TChain* chain = dynamic_cast< TChain* >( main_tree );
if( ! chain ) {
// Write something bad to the output.
throw SomeError();
}
file = chain->GetFile();
}

TTree* my_other_ttree = dynamic_cast< TTree* >( file->Get( “MyOtherTree” ) );[/code]

Then in Process(Long64_t) I load the entries from all the input trees myself. This worked very well for me so far.

Cheers,
Attila

Hi Attila,

Thanks lot for the comments and the code.
I do more-or-less the same in my code. For that I use Init()-method. The only thing I don’t like is that hard-coded “MyOtherTree”. Instead I pass it as an option to the Process() -method and retrieve in the Init() by calling the GetOption()-method.

Cheers, Gia

[quote=“krasznaa”]Hi Gia,

I’m afraid that there is not simple solution. But if you’re willing to do it in a bit more complicated fashion, it can be done.

You have two very handy functions in TSelector: Init(TTree*) and Notify(). I don’t really remember why I chose to do it like that, but what I do right now is that in Init(TTree*) I save the pointer to the input tree (this is the TTree that I give to PROOF), and then in Notify() I do something like this (pseudo code!):

[code]TFile* file = 0;
if( I_run_on_PROOF ) {
file = main_tree->GetCurrentFile();
} else {
TChain* chain = dynamic_cast< TChain* >( main_tree );
if( ! chain ) {
// Write something bad to the output.
throw SomeError();
}
file = chain->GetFile();
}

TTree* my_other_ttree = dynamic_cast< TTree* >( file->Get( “MyOtherTree” ) );[/code]

Then in Process(Long64_t) I load the entries from all the input trees myself. This worked very well for me so far.

Cheers,
Attila[/quote]