T_man
April 21, 2021, 12:52pm
1
Hello everyone,
I have made a 2D histogram like so
TH2D* h = new TH2D("h","h",20,-10,10,20,-10,10);
and I have added some point
h->SetBinContent(10,10,1);
h->SetBinContent(10,10,1);
h->SetBinContent(10,10,2);
I am expecting to see that the histogram to have 4 hits, however it is only taking the last entry of “2”, why is it not adding the hits? is there a way to do that?
couet
April 21, 2021, 1:01pm
2
SetBinContent
, as its name says, replaces the content of the bin by the given value. What you are looking for is Fill
T_man
April 21, 2021, 1:26pm
3
How do I use Fill
in this situation, when I have the x bin and y bin and the content?
couet
April 21, 2021, 1:34pm
4
This is quite clearly explained in the reference guide in the ROOT Manual in the ROOT Primer and in the many histograms’ tutorials . Basically you should do:
h->Fill(10,10,1);
h->Fill(10,10,1);
h->Fill(10,10,2);
system
Closed
May 5, 2021, 2:52pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.