Copying Selection of Trees

Hi,

I was wondering if there is a simple way of copying some selection from a tree to another.

The problem is:

I want to get all events from a tree where the brach “Trig” is equal to one. Example:

v1 v2 v3 trig 0 1 2 0 1 1 3 1 1 3 6 2 2 1 7 1 ...................

the new tree would be:v1 v2 v3 trig 1 1 3 1 2 1 7 1 ...................

Finally, this should be copied to another tree.
Please, how can i get it done?

thank in advance.

Yes do:TFile *orig = new TFile("orig.root"); TTree *origtree; orig->GetObject("mytree",origtree); TFile *output = new TFile("output.root); TTree *outputtree = origtree->CopyTree("trig==1"); outputtree->GetFile()->Write();

Cheers,
Philippe