Dear rooters,
Could someone teach me
In the latter, only an empty canvas is displayed... (though a candidate is successfully found)
2. whether it is possible to seach peaks using TSpectrum::Search()
without displaying any canvas/histogram (or control its display) in interactive root sessions (i.e. w/o -b option) or not?
Even though the histogram is not explicitly drawn, the attached script (when run as unnamed one) displays it.
Thanks in advance.
Yours,
Kazuyoshi
-- Kazuyoshi Furutaka furutaka _dot_ kazuyoshi _at_ jaea _dot_ go _dot_ jpReceived on Thu Dec 14 2006 - 06:28:24 MET
#if !defined(__CINT__)
# include "TCanvas.h"
# include "TH1.h"
# include "TFile.h"
# include "TSpectrum.h"
#endif
{ //void peakSearchTest() { // create a canvas TCanvas *c1 = new TCanvas("c1","c1",10,10,800,500); // read and draw a histogram from a file TFile f("hsimple.root"); TH1F *h = (TH1F*)f.Get("hpx"); //h->Draw(); // search a peak, maxpositions=1, resolution=1(default) TSpectrum *s = new TSpectrum(2); // in histogram 'h', sigma=2, options="", thresh.=0.10 Int_t npfound = s->Search(h,2,"",0.10); if ( npfound > 0 ) { Float_t *xpeaks = s->GetPositionX(); for ( Int_t np=0 ; np < npfound ; np++ ) { Float_t xp = *(xpeaks+np); Int_t bin = h->GetXaxis()->FindBin(xp); printf("Found a candidate of peak at %d channel.\n", bin); } } }
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:02 MET