TSpectrum::Background


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


I am trying to use TSpectrum to calculate the background for my data. I followed the tutorial but my code cannot compile.

Here is my code


//some ROOT includes
#include "TSpectrum.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TH1F.h"
#include "TH1D.h"
#include "TH2S.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TMath.h"
#include "TLine.h"
#include "TStyle.h"
#include "TExec.h"
#include "TLegend.h"
#include "TGraph.h"
#include "TProfile.h"
#include "TH2D.h"
#include "TGraph.h"
#include "TMath.h
///////
////(part of the code where i create flips_histU)
/////////
    c1->cd();
    flips_histU.Draw();
    c1->Update();
    for (int i = 0; i < 13; i++)
    {
        TLine *l=new TLine(pow(2,i),c1->GetUymin(),pow(2,i),c1->GetUymax());
        l->Draw("same");
    }
    c1->cd();
    TSpectrum *s = new TSpectrum();
    double source[4096] = {0};
    for ( int i =0; i < flips_histU.GetNbinsX(); i++)
    {
        source[i] = flips_histU.GetBinContent(i+1);
    }

    s->TSpectrum::Background(source,flips_histU.GetNbinsX(),6,TSpectrum::kBackDecreasingWindow,TSpectrum::kBackOrder2,kFALSE,TSpectrum::kBackSmoothing3,kFALSE);

    for ( int i =0; i<flips_histU.GetNbinsX();i++)
    {
        d->SetBinContent(i+1,source[i]);
    }
    d->Draw("SAME L");
    c1->Print(".png");

"```
However, I get the following mistake:
/tmp/ccYbgrMg.o: In function `main':
flipbitFrequency.cc:(.text+0x23d3): undefined reference to `TSpectrum::TSpectrum()'
flipbitFrequency.cc:(.text+0x2484): undefined reference to `TSpectrum::Background(double*, int, int, int, int, bool, int, bool)'
collect2: error: ld returned 1 exit status
make: *** [flipbitFrequency] Error 1

Try to add “-lSpectrum” to your linker command line (after another ROOT libraries).

i tried
#include “-lSpectrum.h” and “-lSpectrum”, and it didn’t recognize it.

fatal error: -lSpectrum: No such file or directory
 #include "-lSpectrum"
          ^~~~~~~~~~~~

google search -> ld linker command line

that didn’t help, but thanks

that worked! I appreciate it

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