Background

Hi.
I am trying to subtract background.
When I do so everything else works but I do not understand why I have something in the negative of y-axis? Can someone please help me out?

Here is the attached code- - SwissTransfer.com - Envoi sécurisé et gratuit de gros fichiers


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


If you do this:

  test->Draw();   
  TH1F* Background = (TH1F*)test->ShowBackground(20,"same");
  Background->Draw("same");
  Background->SetLineColor(4);
  return;

and zoom in at the first bins you see that the second bin in Background has ~2500 entries, which is then subtracted from test, which is already near zero.

Try adding the option “nosmoothing” to ShowBackground:

TH1F* Background = (TH1F*)test->ShowBackground(20,"same,nosmoothing");

https://root.cern/doc/master/classTH1.html#a6b4e3d028a33b963d7ce6669794e1e27

1 Like

Thanks a lot, can you please let me know if there is also a way to automate this using a peak finder function?

I would like the program to find the peaks, fit them and get the area under the fit.

Check out:
https://root.cern/doc/master/peaks_8C.html