Home | News | Documentation | Download

Dividing Histograms - Output seems wrong

I’m trying to divide two histograms, “top” by “bottom”, to produce a third histogram, “Forward-Backward Asymmetry…”. However, checking individual bins shows a discrepancy between the third histogram and what the division output should be. For example, in the images provided, dividing bin 8 in “top” by bin 8 in “bottom” should result in about 0.15, however, the value of bin 8 in “Forward…” is about 0.6. Furthermore, this only seems to be an issue when inputting particle event data, and not Monte Carlo simulations.

I have included some of my code below.

bottom->Add(h_lep_cos_decang_pos,h_lep_cos_decang_neg);
flip->Add(h_lep_cos_decang_neg,-1);
top->Add(h_lep_cos_decang_pos,flip);
TH1F clone = (TH1F)top->Clone(“clone”);
top->Divide(bottom);
h_lep_cos_w->Add(top);

h_lep_cos_decang_pos and h_lep_cos_decang_neg are both TH1F* objects. Am I perhaps misunderstanding the Add/Divide functions, or is there an error in the code that I am missing?

Edit: Posted the running code
Analysis.C (7.0 KB) Analysis.h (575 Bytes) CLoop.C (2.6 KB) CLoop.h (17.4 KB)



There is a mistake in the code. There should be an asterisk after each of the TH1Fs.

Please post the running code and attach to the post or included in pre-formatted text

I have attached it to the post, please let me know if you have trouble accessing the files.