# User defined fit function

**URL:** <https://root-forum.cern.ch/t/user-defined-fit-function/4565>\
**Category:** ROOT\
**Created:** [March 22, 2007, 5:20pm UTC](https://root-forum.cern.ch/t/user-defined-fit-function/4565 "2007-03-22T17:20:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nppatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nppatt](https://root-forum.cern.ch/u/nppatt)\
**Post date:** [March 22, 2007, 5:20pm UTC](https://root-forum.cern.ch/t/user-defined-fit-function/4565/1 "2007-03-22T17:20:34Z")

</div>

Hi,  
How would someone go about defining a user function such as “gaus+gaus+pol2” then being able to use the “user” button on the FitPanel to fit a histogram using the slider bar (i.e is there a way to fit a user defined function between given points using the GUI interface rather than setting the parameters in the code each time?)

Thanks,  
Nick

---

<div class="post-metadata">

**Author:** ![volpig](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/b5a626/32.png) [@volpig](https://root-forum.cern.ch/u/volpig)\
**Post date:** [March 22, 2007, 5:45pm UTC](https://root-forum.cern.ch/t/user-defined-fit-function/4565/2 "2007-03-22T17:45:08Z")

</div>

There are several methods, if you not need to take care of the normalization you can define the function as:

```auto
 TF1 *user = new TF1("user","gaus(0)+gaus(3)+pol12(6)")
```

The most important part is to name the function “user”, so when in the fit panel you chose the user defined function this function is called.

Before run the fit I think you need to set the initial parameters to value different by 0.
