An error accord while I am trying to fit

hello!

I am a beginner in ROOT , using this version :


| Welcome to ROOT 6.04/02 root.cern.ch |
| © 1995-2014, The ROOT Team |
| Built for macosx64 |
| From tag v6-04-02, 14 July 2015 |

Try ‘.help’, ‘.demo’, ‘.license’, ‘.credits’, ‘.quit’/’.q’

while I am trying to fit the spectrum using maxwell function this error accord :

root [0] .L Maxwell.cpp
root [1] TF1 * mw = new TF1("maxwell",Maxwell,0,200,3)
(class TF1 *) 0x7fa3a1ca6d90
root [2] mw->SetParNames("const","B","T")
root [3] mw->SetParameters(100,5,10)
root [4] mw->Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [5] TH1F* h1=(TH1F*)gROOT->FindObject("TestMaxwell")
(class TH1F *) 0x0
root [6] h1->Fit("maxwell")

 *** Break *** segmentation violation
 Generating stack trace...
 0x0000000108d4c74a in cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**) (in l
 0x0000000108d4c114 in cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::Value*, cling::Transaction**) (in libCling.so) + 100
 0x0000000108d84284 in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) (in libCling.so) + 436
 0x0000000108c61039 in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (in libCling.so) + 3593
 0x0000000108bb6153 in TRint::ProcessLineNr(char const*, char const*, int*) (in libRint.so) + 211
 0x0000000108bb6cff in TRint::HandleTermInput() (in libRint.so) + 671
 0x0000000108989959 in TUnixSystem::CheckDescriptors() (in libCore.so) + 313
 0x00000001089866cd in TMacOSXSystem::DispatchOneEvent(bool) (in libCore.so) + 429
 0x00000001088d3dca in TSystem::InnerLoop() (in libCore.so) + 26
 0x00000001088d3c1b in TSystem::Run() (in libCore.so) + 203
 0x0000000108877ac4 in TApplication::Run(bool) (in libCore.so) + 36
 0x0000000108bb6012 in TRint::Run(bool) (in libRint.so) + 1394
 0x00000001087eee8f in main (in root.exe) + 79
 0x00007fff8da795c9 in start (in libdyld.dylib) + 1
 0x0000000000000002 in <unknown function>

any help please :slight_smile:

Hi,

the error is clearly here:

root [5] TH1F* h1=(TH1F*)gROOT->FindObject("TestMaxwell")
(class TH1F *) 0x0
root [6] h1->Fit("maxwell")

What are you trying to get with gROOT->FindObject(“TestMaxwell”) ?