Passing a sub-range of a histo to TSpectrum

From: Roger Mason <rmason_at_esd.mun.ca>
Date: Wed, 22 Jul 2009 16:21:12 -0230


Hello,

I cannot get TSpectrum to find the peaks in my spectrum, so I'm tying to pass a sub-range that should be easier to deal with. The following code         

#include <TSpectrum.h>
#include <TGraph.h>
#include <TH1F.h>
#include <TCanvas.h>
#include <TMath.h>

void tspectrumB () {
  TCanvas* c1 = new TCanvas("c1","PL/Raman Spectrum",1024,768);   c1->Divide(1,2);

  // This is the whole spectrum
  TGraph* file1 = new TGraph("file1_2col_np.dat");   Int_t N = file1->GetN();

  Double_t* x  = file1->GetX();
  Double_t* y = file1->GetY();
  Double_t xmax = TMath::MaxElement(N,x);
  printf("Maximum wavenumber = %f\n",xmax);   c1->cd(1);
  file1->Draw("ap");

  // Select just the bit from 18200 - 18800   Double_t armin = 18200;
  Double_t armax = 18800;

  TH1F* arh = new TH1F("arh","Reduced range",600,armin,armax);

  printf("Line number %d\n",__LINE__);

  for ( Int_t i = 18200; i < 18800; i++ ) {     printf("y[%d] contains %f\n",i,y[i] );     arh->Fill(i,y[i]);
    // printf("Bin (%d) contains %f\n",i,arh->GetBinContent(i) );   }

  printf("Line number %d\n",__LINE__);

  c1->cd(2);
  arh->Draw();

  TSpectrum* s = new TSpectrum(4);
  Int_t nfound = s->Search(arh,1,"",0.01);   printf("Found %d candidate peaks to fit\n",nfound);   c1->Update();

}

segfaults in the loop that fills histo arh. I can't see what I'm doing wrong.

I'm using ROOT 5.20/00 (trunk_at_24524, Oct 01 2008, 15:00:00 on linux).

Thanks,
Roger Received on Wed Jul 22 2009 - 21:08:14 CEST

This archive was generated by hypermail 2.2.0 : Tue Aug 04 2009 - 11:50:02 CEST