Re: Branches w/ different number of events

From: Hovhannes Khandanyan <khandan_at_cern.ch>
Date: Thu, 2 Sep 2010 09:23:52 +0200

   Hi Philippe,

I see your point. Thanks for useful comments.

Hovhannes

On Sep 1, 2010, at 10:03 PM, Philippe Canal wrote:

>
> > I want to create a root tree with 2 branches corresponding to 2
> different
> > analysis i.e. having different number of entries per branch. Is
> this possible?
>
> Yes it is possible (just add tree->SetEntries(); before tree->Write
> ()),
> __However__ It is strongly discouraged. Semantically your 2 branches
> have very little to do with each other and none of the
> automatically tools
> (TTree::Draw, TTree::Selector, browser, etc.) will be able to make
> good use of your TTree.
>
> Instead we recommend that you simply create 2 different TTrees.
>
> Cheers,
> Philippe.
>
> If there is a semantic link (like an event number) you can add this
> event number to
> each of the 2 trees and properly correlated them by making them
> friends (and creating
> an index on one of the two). An other alternative might be to use
> a collection of value
> (std::vector<float>) is 'bunches' of value from both analysis
> 'belongs' together.
>
>
> On 9/1/10 2:42 PM, Hovhannes Khandanyan wrote:
>> Dear ROOTers,
>>
>> I want to create a root tree with 2 branches corresponding to 2
>> different analysis i.e. having different number of entries per
>> branch. Is this possible? The test macro below creates the
>> required TTree structure, without filling the leaves though. What
>> am I doing wrong?
>>
>> Thanks for any help,
>> Hovhannes
>>
>> int test(){
>> TFile* file = new TFile("myfile.root","recreate");
>> TTree* tree = new TTree("T", "T");
>>
>> double var1, var2;
>>
>> tree->Branch("Ana1", &var1, "var1/F");
>> tree->Branch("Ana2", &var2, "var2/F");
>>
>> for (int i = 10; i < 25; i++){
>> var1 = i*2.45;
>> TBranch* br1 = tree->GetBranch("Ana2");
>> br1->Fill();
>> }
>>
>>
>>
>> for (int i = 0; i < 5; i++){
>> var2 = i*1.17;
>> TBranch* br2 = tree->GetBranch("Ana2");
>> br2->Fill();
>> }
>> tree->Write();
>> file->Close();
>>
>> return 0;
>> }
>>
Received on Thu Sep 02 2010 - 09:24:17 CEST

This archive was generated by hypermail 2.2.0 : Thu Sep 02 2010 - 11:50:01 CEST