2D background subtraction using TSpectrum2 - clipping window probelm!

ROOT Version: 6.17/01
Platform: linuxx8664gcc
Compiler: gcc version 8.3.1 20190223


I have subtracted 2-dimensional background from a symmetric gamma-gamma 2D-histograms using different clipping windows (with values 4, 8, 16 for both the axes).

Now when I take a slice (e.g. on 700 keV gamma ray) using the background subtracted 2D histogram - I get different counts/area under any selected peak in the resulting spectrum.

Now the question is - which clipping window should I trust?

I am attaching a ROOT file. It contains several spectra, for description is given below:

(1) pX700_his2D_M[clipping window] ====> Slice from original 2D-histogram. NOT background subtracted.

(2) pX700_his2DsubRand_M[clipping window]====> Slice from 2D-Histogram from which RANDOM 2D-histogram is subtracted.

(3) pX700_his2Dclean_M[clipping window] ====> Slice from 2D Background subtracted histogram in 2nd description above.

Any help is highly appreciated.



ClippingWindowAnalysis.root (417.2 KB)

Do I understand correctly that you don’t have a technical question on how to use root? We cannot help with methods that we are not familiar with. See also the description of this category of the root forum.

I will leave this post open in case somebody happens to know about subtractions with clipping windows, but please don’t be disappointed if nobody can help.

Hello Stephan,

Thank you for the comment. But, I don’t understand when you say that you are not familiar with the method. I can see that it is nicely documented here: TSpectrum2.

What I don’t understand is the disagreement between the entries/areas/counts in the spectra obtained using different clipping windows.

Oh, so why did you not mention that you were using TSpectrum2? You were only talking about histograms and subtractions.

Now, since I am not familiar with the method, I will first have to read the documentation. You maybe realise that I can only extract the same information that you can extract from it.
So could you maybe point me to the part of the documentation you don’t understand, and I try to study this part in a bit more detail?

I am sorry for the missing information in my first post. Please find below the snippet of the code where I extract the 2-Dimensional background using TSpectrum2::Background() method with different clipping windows.

   UInt_t MatDim = 4096;

   Int_t nbinsx =(Int_t) back->GetNbinsX();  //**back** is the original 2-dimensional histogram
   Int_t nbinsy =(Int_t) back->GetNbinsY();

  TH2F *bckgnd = new TH2F("bckgnd","bckgnd",MatDim,0.,MatDim,MatDim,0.,MatDim);
  TH2F *his2D_wb = new TH2F(TString::Format("%s_2Dbgsub",back->GetName()), TString::Format("2D background subtracted %s",back->GetName()), nbinsx, 0., nbinsx, nbinsy, 0., nbinsy);

   Double_t **source = new Double_t*[nbinsx]; 
   for (i = 0; i < nbinsx; i++) source[i] = new Double_t[nbinsy]; 

   TSpectrum2 *s = new TSpectrum2();
   for (i = 0; i < nbinsx; i++){
      for (j = 0; j < nbinsy; j++){
         source[i][j] = back->GetBinContent(i + 1,j + 1);

// s->Background(source,nbinsx,nbinsy,4,4,TSpectrum2::kBackDecreasingWindow,TSpectrum2::kBackSuccessiveFiltering); //clipping window 4
// s->Background(source,nbinsx,nbinsy,8,8,TSpectrum2::kBackDecreasingWindow,TSpectrum2::kBackSuccessiveFiltering); //clipping window 8
s->Background(source,nbinsx,nbinsy,16,16,TSpectrum2::kBackDecreasingWindow,TSpectrum2::kBackSuccessiveFiltering); // clipping window 16

   for (i = 0; i < nbinsx; i++){
      for (j = 0; j < nbinsy; j++)
         bckgnd->SetBinContent(i + 1,j + 1,(Int_t)source[i][j]);


The question is - which clipping window to use? What is it which determines what value for the clipping window should I use?



Alright, this is a question you would best discuss with your supervisor. It looks like larger windows yield smoother backgrounds because more “smearing” is applied.

However, it seems that the numbers you change is the number of iterations, i.e. how often the algorithm runs. There is no canonical answer other than you should neither run too often (oversmooth) nor undersmooth. You seem to be testing reasonable values, and you should see some kind of optimum where changing the number of iterations doesn’t change much. This is the perfect number of iterations.

If this doesn’t happen, you will have to take this as a source of systematic uncertainties. So use a couple of reasonable values, and re-evaluate the following analysis with all of these. Use this to estimate the systematic uncertainty due to the spectrum analysis.

Hi Stephan,

Thank you very much for you reply.

I have already tested the 2D background estimation with different number of iterations, and it appears that the value of “16” yields optimum result. I will use this value for our further analysis.



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.