TH1 Weighted Fill Questions

Hi ROOT family,

I got a question on the TH1 Weighted Fill. A previous question was asked here: TH1 Weighted Fill. Problem with errors and draw And: "You can use [TH1::Fill(Double_t x, Double_t weight) ](where “x” would be the “channel number” and “weight” would be the “number of counts”) " this TH1::Fill function is the one I looked for. I want to populate my weight i.e. the number of counts, but I do not know how. Could anyone show me an simple example on how to call this function TH1::Fill and also make some populate of the second variable weight? I was using the TH1F to fill my histogram, but the bins could not changed. I could only do some populate on the horizontal axis which is the channel number. Thanks so much for your time!

It seems you want to fill your histogram along X and Y axis. In that case you should use a TH2F (or TH2D).

1 Like

Good point! I never thought I can also make the vertical axis (data) as another histogram! Thank you so much!

1 Like

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