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:
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
for (
Int_t p=0;p<npeaks;p++) {
}
return result;
}
void findPeak2() {
printf("Generating histogram with %d peaks\n",npeaks);
delete h2;
for (p=0;p<npeaks;p++) {
}
Int_t nfound =
s->Search(h2,2,
"col");
for (p=0;p<npeaks;p++) {
for (pf=0;pf<nfound;pf++) {
if (diffx < 2*dx && diffy < 2*dy) ngood++;
}
}
if (ngood > nfound) ngood = nfound;
for (pf=0;pf<nfound;pf++) {
for (p=0;p<npeaks;p++) {
if (diffx < 2*dx && diffy < 2*dy) nf++;
}
if (nf == 0) nghost++;
}
printf("Gener=%d, Found=%d, Good=%d, Ghost=%d\n",npeaks,nfound,ngood,nghost);
printf("\nDouble click in the bottom right corner of the pad to continue\n");
}
}
void peaks2(
Int_t maxpeaks=50) {
for (int i=0; i<10; ++i) {
findPeak2();
}
}
R__EXTERN TRandom * gRandom
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
virtual void SetParameters(const Double_t *params)
A 2-Dim function with parameters.
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)}
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Advanced 2-dimensional spectra processing.
static constexpr double s
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.