faca87
December 28, 2022, 2:21pm
1
Hello
I wrote a macro to calculate the ratio between data and MC following the ratioplot example.
To be sure that it works fine, I tried to define the ratio dividing an histogram by itself i.e.
TH1F *ratio0 = (TH1F *)hExp0->Clone("ratio");
ratio0->Divide(hExp0);
I expect the ratio is 1 , but I get this plot… (i.e. the ratio is not 1)
Am I missing something?
detratio.c (4.7 KB)
Similarly I wrote a macro to plot the difference between the histograms I wrote a second macro and to test it I tried to subtract a histogram by itself i.e.
TH1F *diff0 = (TH1F *)hExp0->Clone("diff0");
diff0->Add(hExp0, -1.);
I expected the difference is 0, but I get
detdiff.c (4.7 KB)
Thanks
You must not call “Sumw2(kFALSE)
” for both scalled histograms.
faca87
December 28, 2022, 3:01pm
3
Hi @Wile_E_Coyote , if I don’t call
“Sumw2(kFALSE)
”
I still get a ratio that isn’t 1, and I also get a bad upper plot. Indeed, 2 days ago, you said me to use “Sumw2(kFALSE)
” to preserve the quality of plots
This plot is fine (the “green band” are the errors of the “ratio”).
You may try to add:
hSim0->SetOption("HIST"); hExp0->SetOption("HIST"); c01->Modified(); c01->Update();
faca87
December 28, 2022, 3:13pm
5
Ah ok @Wile_E_Coyote , if the green are the errors the ratio is fine!
Anyway,
hSim0->SetOption("HIST"); hExp0->SetOption("HIST"); c01->Modified(); c01->Update();
improved the quality just of the MC plot
detratio.c (4.8 KB)
Instead of “hExp0->Draw("SAME");
”, you need “hExp0->Draw("HIST SAME");
”.
faca87
December 28, 2022, 3:43pm
7
Thank you @Wile_E_Coyote
now I applied it to the real macro (i.e. the data/MC ratio) and I get this plot
it looks like to me that it isn’t dividing the data plot by the MC one, but in the ratio pad it is plotting just the data plot…
maybe is not really dividing when I use 2 different histos?
detratio.c (4.8 KB)
If they have different x-axis binnings, then it will not work.
faca87
December 29, 2022, 6:45am
9
Thank you @Wile_E_Coyote , it solved !
system
Closed
January 12, 2023, 6:46am
10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.