# Error when trying to plot chi square contour

**URL:** <https://root-forum.cern.ch/t/error-when-trying-to-plot-chi-square-contour/32795>\
**Category:** Newbie\
**Created:** [February 18, 2019, 8:27pm UTC](https://root-forum.cern.ch/t/error-when-trying-to-plot-chi-square-contour/32795 "2019-02-18T20:27:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugo\_leung](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hugo_leung/32/20426_2.png) [@hugo\_leung](https://root-forum.cern.ch/u/hugo_leung)\
**Post date:** [February 18, 2019, 8:27pm UTC](https://root-forum.cern.ch/t/error-when-trying-to-plot-chi-square-contour/32795/1 "2019-02-18T20:27:31Z")

</div>

I am trying to plot the chi square contour but I got the following error

```auto
 0x00007fc1ed6987e7 in <unknown> from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed698c3f in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 0x1df from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed7502a2 in cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) + 0x592 from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed75ff17 in cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) + 0x177 from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed761186 in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) + 0xa6 from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed74976b in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 0x10b from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed5edc7e in <unknown> from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed603512 in <unknown> from /home/hugo/bin/lib/libCling.so
 0x00007fc1ed5f4ff7 in <unknown> from /home/hugo/bin/lib/libCling.so
 0x00007fc1f2d19318 in TApplication::ExecuteFile(char const*, int*, bool) at /home/hugo/root-6.14.02/core/base/src/TApplication.cxx:1151 from /home/hugo/bin/lib/libCore.so
 0x00007fc1f2d18ad5 in TApplication::ProcessLine(char const*, bool, int*) at /home/hugo/root-6.14.02/core/base/src/TApplication.cxx:1002 from /home/hugo/bin/lib/libCore.so
 0x00007fc1f31e06b2 in TRint::ProcessLineNr(char const*, char const*, int*) at /home/hugo/root-6.14.02/core/rint/src/TRint.cxx:757 from /home/hugo/bin/lib/libRint.so
 0x00007fc1f31e1f58 in TRint::Run(bool) at /home/hugo/root-6.14.02/core/rint/src/TRint.cxx:416 from /home/hugo/bin/lib/libRint.so
 0x00007fc1f38009fc in <unknown> from /home/hugo/bin/bin/root.exe
 0x00007fc1f2191b97 in __libc_start_main + 0xe7 from /lib/x86_64-linux-gnu/libc.so.6
 0x00007fc1f3800a5a in _start + 0x2a from /home/hugo/bin/bin/root.exe
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_10:1:
/home/hugo/trial_fit.c:37:25: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
        TGraph *gr1 = (TGraph*)gMinuit->Contour(40,0,1);
                               ^ ~~~~~~

```

I should I fix it?

[trial\_fit.c](https://root-forum.cern.ch/uploads/default/original/3X/4/8/4821a496f74bd63b5d3faaae7f7313c9218d6226.c) (889 Bytes)

---

<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:** [February 19, 2019, 9:36am UTC](https://root-forum.cern.ch/t/error-when-trying-to-plot-chi-square-contour/32795/2 "2019-02-19T09:36:02Z")

</div>

Hi,

You should just use option “F”, when calling TH1::Fit. You are fitting a polynomial function and by default in this case you are using a linear fitter and in that case gMinuit is not created.  
If you change line 31 to be:  
`h1->Fit("pol1","F");`

your macro will work fine

Lorenzo
