How could I get copy of histogram from the tree?

Please provide the following information:


ROOT Version (e.g. 6.12/02):
Platform, compiler (e.g. CentOS 7.3, gcc6.2):


I’m sorry to ask this question, but I really hard to find information about the question though lost my way for 4 hours.

Actually, I have been found some informations looks like related to the problem but I could not apply to my system…

My plan is make a same histogram from the tree and obtain sum of bins through Integration(), but I cannot copy the histogram. I tried to make same histrogram by using Fill() and setbranch~ but it has problem. There are bins to make accruate same quantities of the one of histogram from the tree… because I always used constant bins like TH1F *h1 = new TH1F(“a”, “b”, 100, 0, 10). Well… there are ‘getbincontent’ and ‘setbincontent’ but it require same histogram that I have to make… So it is nonsense.

I truly looking for Solution… Please Help…

I am not sur I fully understood your question but let me try to give some answer. Imagine you have a tree named “T” and inside this tree a variable (column) called “V” you want to use to fill the histogram “h1” you describes in your post. You can just do:

TH1F *h1 = new TH1F("h1", "h1", 100, 0, 10);
T->Draw("V>>h1");

Wow thx. I actually follow this answer in next week because my home computer is window 7 So I can use root at my school…

If I apply that statements, h1 possess all of property of V or just draw following initial condition bins = 100, [0, 10] ? And if the former is right, h1->Integral() means sum of bins?

My English skill is so poor… Maybe that’s reason why hard to understand my writings

You can also let ROOT book the histogram for you. Simply do:

T->Draw("V");

After this command the resulting histogram will be htemp.

Fwiw, you can use Go and Go-HEP/rootio - now - on Linux, Darwin (macOS) and Windows to read TTrees and TH1x,TH2x.

See:

In my experience, Go is easier to learn and work with than C++ (and faster that pure Python)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.