/// \file /// \ingroup tutorial_spectrum /// \notebook /// Example to illustrate the 2-d peak finder (class TSpectrum2). /// /// This script generates a random number of 2-d gaussian peaks /// The position of the peaks is found via TSpectrum2 /// To execute this example, do: /// /// ~~~{.cpp} /// root > .x peaks2.C (generate up to 50 peaks by default) /// root > .x peaks2.C(10) (generate up to 10 peaks) /// root > .x peaks2.C+(200) (generate up to 200 peaks via ACLIC) /// ~~~ /// /// The script will iterate generating a new histogram having /// between 5 and the maximun number of peaks specified. /// Double Click on the bottom right corner of the pad to go to a new spectrum /// To Quit, select the "quit" item in the canvas "File" menu /// /// \macro_image /// \macro_code /// /// \author Rene Brun #include "TSpectrum2.h" #include "TCanvas.h" #include "TRandom.h" #include "TH2.h" #include "TF2.h" #include "TMath.h" #include "TROOT.h" TSpectrum2 *s; TH2F *h2 = 0; Int_t npeaks = 30; void findPeak2() { TCanvas *c1 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c1"); if (!c1) c1 = new TCanvas("c1","c1",10,10,1000,700); Int_t nfound = s->Search(h2,2,"col"); Double_t *xpeaks = s->GetPositionX(); Double_t *ypeaks = s->GetPositionY(); Int_t pf; for (pf=0;pfUpdate(); s->Print(); c1->SaveAs("peaks.pdf"); } void findlabmscanpeaks(char *scan,char *motors,int ipm,int maxpeaks) { s = new TSpectrum2(2*maxpeaks); char rootfilesdir[255]="/media/ayad/ParticleDisk1/labm/scanfiles/scanrootfiles"; char filec[255]; sprintf(filec,"%s/%s-%s-steps-rate-over-current.root",rootfilesdir,scan,motors); TFile* file = TFile::Open(filec); sprintf(filec,"PM %d;2",ipm); file->GetObject(filec, h2); findPeak2(); }