# Fit data is empty despite presence of histogram

**URL:** <https://root-forum.cern.ch/t/fit-data-is-empty-despite-presence-of-histogram/38069>\
**Category:** Newbie\
**Created:** [February 20, 2020, 4:04pm UTC](https://root-forum.cern.ch/t/fit-data-is-empty-despite-presence-of-histogram/38069 "2020-02-20T16:04:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk231](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@tk231](https://root-forum.cern.ch/u/tk231)\
**Post date:** [February 20, 2020, 4:04pm UTC](https://root-forum.cern.ch/t/fit-data-is-empty-despite-presence-of-histogram/38069/1 "2020-02-20T16:04:36Z")

</div>

Hi!

I’m attempting to modify the example code, `langaus.c` found [on this page](https://root.cern.ch/root/html/tutorials/fit/langaus.C.html), so it may use the histogram that I have on hand (not filling it out bin by bin). So far, the only parts of the code that I have modified are adding an additional line at the beginning,

> void langaus(const char \*file = “durchflug\_messung\_100.root”)

which contains the `.root` file containing the TH1F histogram, and the parts between `// Fill histogram` and `Fitting SNR histo`, in addition to the names `hSNR` to `hFlythrough`. Here’s how it looks like right now:

> void langaus(const char \*file = “durchflug\_messung\_100.root”) {  
> // Fill Histogram  
> TFile f(file);  
> TCanvas _c\_work = (TCanvas_) f.Get(“c1”);  
> TH1F \*hFlythrough\_100 = (TH1F \*) c\_work-\>GetPrimitive(“h”);  
> // Fitting SNR histo  
> printf(“Fitting…\n”);

However, when I run this macro, I get the following error:

> Warning in : Fit data is empty

Could anyone give any pointers as to why this is so? Attached is the file that I hope to fit.  
[durchflug\_messung\_100.root](https://root-forum.cern.ch/uploads/short-url/bkdJ7bxQEdotwQ37uBILdrbvFsW.root) (22.9 KB)

* * *

_ROOT Version_: 6.09/01  
_Platform:_ Linux Mint 19.1  
_Compiler_: Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [February 20, 2020, 4:30pm UTC](https://root-forum.cern.ch/t/fit-data-is-empty-despite-presence-of-histogram/38069/2 "2020-02-20T16:30:55Z")

</div>

Your “h” histogram has all errors 0.  
Either execute “`h->Sumw2(kFALSE);`” or try to use [the “W” or “WW” fit options](https://root.cern.ch/doc/master/classTH1.html#a7e7d34c91d5ebab4fc9bba3ca47dabdd).

---

<div class="post-metadata">

**Author:** ![tk231](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@tk231](https://root-forum.cern.ch/u/tk231)\
**Post date:** [February 20, 2020, 5:35pm UTC](https://root-forum.cern.ch/t/fit-data-is-empty-despite-presence-of-histogram/38069/3 "2020-02-20T17:35:40Z")

</div>

Thanks for noticing that! I wasn’t aware that it’d have an affect on me trying to fit a curve onto it!
