Clonetree in TSelector with Proof

Hi,
I am trying to solve a problem I am having with TSelector and PROOF (together). The purpose of the code I am currently running is to perform a preselection on a very large chain of ntuples. I would like to have the final output of the program be an root file with selected events being written out to the new file (but with the same tree structure). I have this working in a single CPU program not using the TSelector class, but would like to have this working using PROOF.

In my single CPU program I essentially do the following:

TTree *newtree;
newtree = chain.CloneTree(0);

loop over events
if(selected_event) {
newtree->Fill()
}
end loop
newtree->Write();

I’m having trouble doing the same using TSelector, when I try to use CloneTree(0) on the fChain object the program segfaults. Removing this the program runs fine, and the few test outputs that I have produce sensible events.

Does anyone know a simple way to create the output file that I wish to make?

note
Root version 5.22
SL3, SL4

Thank,
Trevor

I seemed to have solved my problem by moving

newtree = fChain->CloneTree(0);
fOutput->Add(newtree);

To the Init function of the TSelector class.