Filling Branches Individually

I am trying to fill branches in a TTree at different times and with a different number of entries. I will state up front that my knowledge of root is very, very minimal. When I run the code below as a test, I get a large root file that indicates the data is actually being stored. However, I cannot see a histogram of the data in the object browser when I click on a leaf.

So my questions are:

  1. Am I filling the branches correctly? Is it okay to create and fill branches at different times and with different numbers of entries?

  2. Is there something else I need to be doing to fill these branches individually since the information in the tree isn’t behaving like it typically does (i.e. no histogram)?

  3. If I’m doing things correctly, how can I generate a histogram of the data when looking at the root tree in the object browser (or in my C++ program if that is easier to do)?

Thank you
–John

        // make TFile and TTree
	TFile f1("tester.root","RECREATE");
	TTree t1("t1","Tree mmmm");

	// first branch
	Int_t dog;
	TBranch* b1 = t1.Branch("dog",&dog,"I");

	//second branch
	Double_t cat;
	TBranch* b2 = t1.Branch("cat",&cat,"D");

	// fill the first branch a bunch of times
	for(int i = 0; i < 1E7; ++i)
	{
		++dog;
		b1->Fill();
	}

	// fill the second branch once later
	b2->Fill();

	// write the file.
	f1.Write();

Hi John,

See for example this post

Cheers, Bertrand.