Illegal pointer to class object back 0x0 165

Hi every one!
I want to subtract background of spectrum. I use the “TSpectrum.h”, but, I get the error “illegal pointer to class object back”, although I get all library.
Would you mind fixing the problem!
Thank every one too much!
P/s: I attached the file
background.C (1.12 KB)

If you “recreate” your file, there is nothing to “Get” from it.

However, When i use the exist root file in folder, this mistake didn’t fix. So, I don’t understand how to pointer to class although I call all library.
Thank you so much!

Attach your root file.

This is the root file.
khongbia_7200s_03042016.root (306 Bytes)

This seems to be a broken / completely empty file:
root [0] TFile *f = TFile::Open(“khongbia_7200s_03042016.root”);
Warning in TFile::Init: file khongbia_7200s_03042016.root has no keys
Warning in TFile::Init: no StreamerInfo found in khongbia_7200s_03042016.root therefore preventing schema evolution when reading this file.

I use the new .rootfile (attached file). The warning don’t show. However, the mistake don’t be fixed.
AF11225_5_20_20_day5_7200_12042016.root (8.11 KB)

There is just a single “h1” histogram (no “back1”) in your file:
root [0] TFile f = TFile::Open(“AF11225_5_20_20_day5_7200_12042016.root”)
root [1] f->ls()
TFile
* AF11225_5_20_20_day5_7200_12042016.root
TFile* AF11225_5_20_20_day5_7200_12042016.root
KEY: TH1F h1;1 energy vs count

Try the attached macro.
background.C (1.68 KB)

I try!
Thanks !

It done!
Thank you so much!

Hi everyone!
I use the Ubuntu running with VMware. I run the file.cpp and get the mistake
" *** Break *** segmentation violation
#0 0xb77accb0 in ?? ()
Root > Function lamtron() busy flag cleared "

when I want to open the TBrowser b().
Can you fix it?
Thank u too much.

As you can see, the “lamtron()” function (defined and called from “file.cpp”?) breaks -> you need to fix it.

How to fix this fail???

Without any source code … how is anybody here to know “how to fix some bug”?

this is source code
Thank so much!!!
lamtron.cpp (2.74 KB)

Your “Mau AF11225_5x20x20.TKA” and “Khongbia.TKA” data files are also needed in order to run your macro.

The first problem that I see is that you have:
const int n = 2000000;
Double_t y1[n],y[n];
and this uses more than 30MB on “stack” (quite often, the “stack” is limited to something like 8MB).
See, for example: No error when macro crashes

You also try to create two TFile objects with names which end with “.pdf” (which suggests “Adobe PDF” files, not ROOT files).

Notes:

  1. Always try to precompile your macro using ACLiC, in order to find source code problems, e.g. try something like (inspect all reported warnings and errors):
    root [0] .L YourRootMacro.cxx++
  2. You can “debug” many problems using “valgrind”. See, for example: Segmentation Fault depending on linux distribution