# Error on FitResult::Scan

**URL:** <https://root-forum.cern.ch/t/error-on-fitresult-scan/51014>\
**Category:** Newbie\
**Created:** [July 29, 2022, 7:30pm UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014 "2022-07-29T19:30:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lilina](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lilina/32/28468_2.png) [@lilina](https://root-forum.cern.ch/u/lilina)\
**Post date:** [July 29, 2022, 7:30pm UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/1 "2022-07-29T19:30:34Z")

</div>

Hi,  
I am trying to perform a Chi2 scan using the fitter.Result().Scan function but I get a segmentation error when implementing it. I have attached the testing example. Can anyone help me to construct the function correctly?

Many thanks!

[ParamScan.C](https://root-forum.cern.ch/uploads/short-url/cnTlLfl38t0qG10Mb8lPgHQjLZS.C) (1.7 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 1, 2022, 9:13am UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/2 "2022-08-01T09:13:02Z")

</div>

May be @moneta can help.

---

<div class="post-metadata">

**Author:** ![lilina](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lilina/32/28468_2.png) [@lilina](https://root-forum.cern.ch/u/lilina)\
**Post date:** [August 8, 2022, 6:45pm UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/3 "2022-08-08T18:45:20Z")

</div>

In this simplified example code reproducing the problem, I am able to perform the fit and do the Scan with the TFitResult.Scan() but I get an empty graph. Is there any reason why this would not work? Thank you so much.  
[FitParScan.C](https://root-forum.cern.ch/uploads/short-url/mKJCehFfEte2yLzjsRaj8d0bZ5p.C) (1.7 KB)

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 9, 2022, 8:55am UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/4 "2022-08-09T08:55:08Z")

</div>

Hi,  
There is a problem in calling `Scan` after the Fitter class is deleted and the `FitResult` is copied. I will open an issue for this.  
For the time being, I attach you a working script performing the Scan which is done whithin the same C++ scope of the Fitter class.

[FitParScan.C](https://root-forum.cern.ch/uploads/short-url/A2Uz3pLyHgyPmvfY3Ay8jFGKbMC.C) (1.8 KB)

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![lilina](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lilina/32/28468_2.png) [@lilina](https://root-forum.cern.ch/u/lilina)\
**Post date:** [August 9, 2022, 3:23pm UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/5 "2022-08-09T15:23:25Z")

</div>

Dear Lorenzo,

Thank you so much for clarifying this. The working script uploaded was not the modified one but I changed the Scan to the scope of the Fitter class as you mentioned and it worked. Thanks a lot!

Best,

Lily

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 9, 2022, 4:05pm UTC](https://root-forum.cern.ch/t/error-on-fitresult-scan/51014/6 "2022-08-09T16:05:24Z")

</div>

I have corrected the post and uploaded the correct file. Sorry for this !
