[ROOT] TSpectrum - fake x real data

From: Antonio Kanaan (kanaan@astro.ufsc.br)
Date: Sun Jun 03 2001 - 18:50:58 MEST


Hi Folks,

1) thanks to Rene and Martin for their help with TSpectrum.  I moved
ahead on my problem which is going fairly well with fake data.  Not so
good with real data though.  The following code with comment-attached
data at its end shows a situation where the eye can easily catch 5
peaks (at x = 3,6,12,15,18) and other peak-finding algorithm find 4
(x=6,12,15,18).  In my use of TSpectrum I can only get 2 peaks
(x=6,12).

I wonder if there is a way to set a threshold so lower peaks can be
detected.

2) A problem I have when using TGraph which can be seen in this example:

Why can I zoom in X but not in Y in a TGraph? I can zoom in both on a
histogram.


#include "TCanvas.h"
#include "TGraph.h"
#include "TH1.h"
#include "TSpectrum.h"

#include <iostream>
#include <fstream>
using namespace std;

const Int_t MAXNPT = 250; /* number of points */ 
Float_t x[MAXNPT],y[MAXNPT],z ; /* data arrays */




//___________________________________________________________________
search4()
{
  Int_t n,npts;
  
  TCanvas *c1 = new TCanvas("c1","the fit canvas",800,600);

  // fills up the x and y reading file "
  ifstream infile("./peak.real") ;
  n = 0 ;
  while ( (infile >> x[n] >> y[n++]) ) 
  npts = n;

  //TH1F *hpx    = new TH1F("hpx","Peaks",npts,-0.5,npts-0.5);
  //for (Int_t j=0 ; j<npts ; j++) hpx->SetBinContent(j+1,y[j]) ;
  //hpx->Draw() ;

  Int_t npeaks ;
  TSpectrum *sp1 = new TSpectrum();
  npeaks = sp1->Search1(y,npts,0.75) ;
  //sp1->Search(hpx,1.0,"") ;
  npeaks = sp1->GetNPeaks() ;
  cout << "Peaks found " << npeaks << endl ;

  Float_t *peaks ;
  peaks = sp1->GetPositionX() ;
  for (Int_t j=0 ; j<npeaks ; j++)
    cout << "Peak at = " << peaks[j] << endl ;

  // creates a TGraph object to display the computed curves
  TGraph *gr  = new TGraph (npts, x, y);
  gr->Draw("AC*") ;

  return(0) ;
  
}

/*

File peak.real to be read by the above code:

1 16020
2 14968
3 13199
4 14029
5 13545
6 15274
7 19903
8 17252
9 12782
10 11068
11 10640
12 14207
13 17253
14 14815
15 15847
16 17072
17 14595
18 15388
19 15183
20 11014
21 7766

*/



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:47 MET