Script runs with root but fails after compilation with g++

Hey guys,

my original problem is that I have hundreds of histograms and each one of them should be fitted with a different function. However, they share a common parameter and I would like to obtain the best value for it during a global fit.
Luckily, I found a nice example here in the RootTalk. To match my requirements I changed it a little bit to see if it still works.
The original version I could compile and run it without any problems with g++ as well as root.

After including my changes it still compiles with g++ and root, however with root it also runs but the standalone programs crashes with a segmentation violation.

I have narrowed it down to the last lines in the code when I try to access (draw and/or write) the created TH1D.

Regarding the version numbers: root 5.32 and g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)

Any help is grealy appreciated.

Cheers,
Stephan
testcombinedFit_LL.C (5.9 KB)

愛情萬歲
testcombinedFit_LL.C (6.3 KB)

Thanks, it works now!

But can you also tell me what the problem was?