# Unwanted portion removal and choosing best Gaussian fit

**URL:** <https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038>\
**Category:** Newbie\
**Created:** [March 5, 2019, 9:33pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038 "2019-03-05T21:33:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prya13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ea666f/32.png) [@Prya13](https://root-forum.cern.ch/u/Prya13)\
**Post date:** [March 5, 2019, 9:33pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/1 "2019-03-05T21:33:30Z")

</div>

Dear All,

I am having two issues, I would like to write a macro to solve:

1. To remove initial unwanted area from a mass plot region 2 - 2.8.
2. I want to fit a Gaussian function, I tried this [0]_exp(-0.5_pow((x-[1])/[2],2)), but not so appropriate. I would  
like to find the yield from the [0] value.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/8/9/899e78fb43168c9014cc6e07401a8faf93857643.png)

Thank you for all your help.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 6, 2019, 8:40am UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/2 "2019-03-06T08:40:27Z")

</div>

You could try to use the fit panel…

---

<div class="post-metadata">

**Author:** ![Prya13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ea666f/32.png) [@Prya13](https://root-forum.cern.ch/u/Prya13)\
**Post date:** [March 6, 2019, 2:15pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/3 "2019-03-06T14:15:05Z")

</div>

Hey Bellenot,

Thank you.

Could I use a macro instead of the fit panel?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 6, 2019, 2:16pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/4 "2019-03-06T14:16:23Z")

</div>

Sure, but using the fit panel allows to first estimate the fit parameters in an interactive way…

---

<div class="post-metadata">

**Author:** ![Prya13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ea666f/32.png) [@Prya13](https://root-forum.cern.ch/u/Prya13)\
**Post date:** [March 6, 2019, 3:45pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/5 "2019-03-06T15:45:32Z")

</div>

wonderful. Thank you.

---

<div class="post-metadata">

**Author:** ![Prya13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/ea666f/32.png) [@Prya13](https://root-forum.cern.ch/u/Prya13)\
**Post date:** [March 6, 2019, 3:46pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/6 "2019-03-06T15:46:33Z")

</div>

How about choosing a good fit function?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 6, 2019, 3:48pm UTC](https://root-forum.cern.ch/t/unwanted-portion-removal-and-choosing-best-gaussian-fit/33038/7 "2019-03-06T15:48:20Z")

</div>

Same here. The fit panel has several pre-defined fit functions
