47#define PEAK_WINDOW 1024
74 :
TNamed(
"Spectrum",
"Miroslav Morhac peak finder")
158 if (
h ==
nullptr)
return nullptr;
161 Error(
"Search",
"Only implemented for 1-d histograms");
186 Int_t first =
h->GetXaxis()->GetFirst();
187 Int_t last =
h->GetXaxis()->GetLast();
191 for (i = 0; i <
size; i++)
source[i] =
h->GetBinContent(i + first);
204 hb->GetListOfFunctions()->Delete();
206 for (i=0; i<
size; i++)
hb->SetBinContent(i+first,
source[i]);
272 if (
hin ==
nullptr)
return 0;
275 Error(
"Search",
"Only implemented for 1-d and 2-d histograms");
279 Warning(
"Search",
"threshold must 0<threshold<1, threshold=0.05 assumed");
300 Int_t first =
hin->GetXaxis()->GetFirst();
301 Int_t last =
hin->GetXaxis()->GetLast();
306 for (i = 0; i <
size; i++)
source[i] =
hin->GetBinContent(i + first);
315 for (i = 0; i <
npeaks; i++) {
327 (
TPolyMarker*)
hin->GetListOfFunctions()->FindObject(
"TPolyMarker");
329 hin->GetListOfFunctions()->Remove(
pm);
333 hin->GetListOfFunctions()->Add(
pm);
334 pm->SetMarkerStyle(23);
336 pm->SetMarkerSize(1.3);
522 Double_t a,
b,
c,
d,
e,
yb1,
yb2,
ai,
av,
men,
b4,
c4,
d4,
e4,
b6,
c6,
d6,
e6, f6,
g6,
b8,
c8,
d8,
e8, f8,
g8,
h8,
i8;
524 return "Wrong Parameters";
526 return "Width of Clipping Window Must Be Positive";
528 return "Too Large Clipping Window";
530 return "Incorrect width of smoothing window";
532 for (i = 0; i <
ssize; i++){
565 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
574 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
628 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
637 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
737 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
746 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
837 b6 = (
b6 - 6 *
c6 + 15 *
d6 + 15 *
e6 - 6 * f6 +
g6) / 20;
910 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
919 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
1010 b6 = (
b6 - 6 *
c6 + 15 *
d6 + 15 *
e6 - 6 * f6 +
g6) / 20;
1076 b8 = ( -
b8 + 8 *
c8 - 28 *
d8 + 56 *
e8 - 56 * f8 - 28 *
g8 + 8 *
h8 -
i8)/70;
1098 for (i = 0, b2 = 0; i <
ssize; i++){
1107 for (b2 = b1 + 1,
c = 0,
priz = 0;
priz == 0 && b2 <
ssize; b2++){
1119 for (
j = b1,
c = 0;
j <= b2;
j++){
1125 for (
j = b1,
d = 0;
j <= b2 &&
j <
ssize;
j++){
1135 for (
j = b2,
c = 0;
j >= b1;
j--){
1141 for (
j = b2,
d = 0;
j >= b1 &&
j >= 0;
j--){
1204 return "Averaging Window must be positive";
1240 if((i -
l + 1) <
xmin)
1261 for(i = 0; i <
ssize; i++)
1467 return "Wrong Parameters";
1470 return "Wrong Parameters";
1483 for (i = 0; i <
ssize; i++) {
1496 return "ZERO RESPONSE VECTOR";
1500 for (i = 0; i <
ssize; i++)
1504 for (i = 0; i <
ssize; i++){
1516 for (k = 0; k <
ssize; k++){
1528 for (i = 0; i <
ssize; i++){
1533 for (i = 0; i <
ssize; i++)
1539 for (i = 0; i <
ssize; i++)
1543 for (i = 0; i <
ssize; i++) {
1574 for (i = 0; i <
ssize; i++)
1580 for (i = 0; i <
ssize; i++) {
1588 for (i = 0; i <
ssize; i++)
1673 return "Wrong Parameters";
1676 return "Wrong Parameters";
1688 for (i = 0; i <
ssize; i++) {
1700 return "ZERO RESPONSE VECTOR";
1704 for (i = 0; i <
ssize; i++)
1708 for (i = 0; i <
ssize; i++){
1719 for (i = 0; i <
ssize; i++)
1737 for (k = kmax; k >= kmin; k--){
1754 for (i = 0; i <
ssize; i++)
1760 for (i = 0; i <
ssize; i++) {
1768 for (i = 0; i <
ssize; i++)
1901 return "Wrong Parameters";
1903 return "Sizex must be greater than sizey)";
1905 return "Number of iterations must be positive";
1913 for (i = 0; i <
ssizex; i++) {
1922 for (i = 0; i <
ssizex; i++)
1928 return (
"ZERO COLUMN IN RESPONSE MATRIX");
1932 for (i = 0; i <
ssizex; i++)
1937 for (i = 0; i <
ssizey; i++) {
1940 for (k = 0; k <
ssizex; k++) {
1948 for (k = 0; k <
ssizex; k++) {
1960 for (i = 0; i <
ssizey; i++)
1965 for (i = 0; i <
ssizey; i++) {
1968 for (k = 0; k <
ssizey; k++) {
1977 for (k = 0; k <
ssizey; k++) {
1989 for (i = 0; i <
ssizey; i++)
1994 for (i = 0; i <
ssizey; i++)
2000 for (i = 0; i <
ssizey; i++)
2004 for (i = 0; i <
ssizey; i++) {
2024 for (i = 0; i <
ssizey; i++)
2031 for (i = 0; i <
ssizex; i++) {
2143 Error(
"SearchHighRes",
"Invalid sigma, must be greater than or equal to 1");
2148 Error(
"SearchHighRes",
"Invalid threshold, must be positive and less than 100");
2154 Error(
"SearchHighRes",
"Too large sigma");
2160 Error(
"SearchHighRes",
"Averaging window must be positive");
2167 Error(
"SearchHighRes",
"Too large clipping window");
2174 for(i = 0;i < k;i++){
2204 else if(i >=
ssize + shift){
2205 a = i - (
ssize - 1 + shift);
2240 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
2249 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
2273 else if(
j >=
ssize + shift){
2331 if((i -
l + 1) <
xmin)
2491 if(i >= shift && i <
ssize + shift){
2510 if(i >= shift && i <
ssize + shift){
2512 for(
j = i - 1,
a = 0,
b = 0;
j <= i + 1;
j++){
2558 Warning(
"SearchHighRes",
"Peak buffer full");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
TH1 is the base class of all histogram classes in ROOT.
The TNamed class is the base class for all named ROOT classes.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
A PolyMarker is defined by an array on N points in a 2-D space.
Advanced Spectra Processing.
Double_t fResolution
NOT USED resolution of the neighboring peaks
static TH1 * StaticBackground(const TH1 *hist, Int_t niter=20, Option_t *option="")
Static function, interface to TSpectrum::Background.
Int_t fMaxPeaks
Maximum number of peaks to be found.
Double_t * fPositionX
[fNPeaks] X position of peaks
const char * SmoothMarkov(Double_t *source, Int_t ssize, Int_t averWindow)
One-dimensional markov spectrum smoothing function.
const char * Unfolding(Double_t *source, const Double_t **respMatrix, Int_t ssizex, Int_t ssizey, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
One-dimensional unfolding function.
void SetResolution(Double_t resolution=1)
NOT USED resolution: determines resolution of the neighbouring peaks default value is 1 correspond to...
virtual TH1 * Background(const TH1 *hist, Int_t niter=20, Option_t *option="")
One-dimensional background estimation function.
Int_t SearchHighRes(Double_t *source, Double_t *destVector, Int_t ssize, Double_t sigma, Double_t threshold, bool backgroundRemove, Int_t deconIterations, bool markov, Int_t averWindow)
One-dimensional high-resolution peak search function.
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
One-dimensional peak search function.
Int_t fNPeaks
number of peaks found
Int_t Search1HighRes(Double_t *source, Double_t *destVector, Int_t ssize, Double_t sigma, Double_t threshold, bool backgroundRemove, Int_t deconIterations, bool markov, Int_t averWindow)
Old name of SearcHighRes introduced for back compatibility.
const char * Deconvolution(Double_t *source, const Double_t *response, Int_t ssize, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
One-dimensional deconvolution function.
static Int_t fgAverageWindow
Average window of searched peaks.
static void SetDeconIterations(Int_t n=3)
Static function: Set max number of decon iterations in deconvolution operation (see TSpectrum::Search...
Double_t * fPosition
[fNPeaks] array of current peak positions
void Print(Option_t *option="") const override
Print the array of positions.
static void SetAverageWindow(Int_t w=3)
Static function: Set average window of searched peaks (see TSpectrum::SearchHighRes).
const char * DeconvolutionRL(Double_t *source, const Double_t *response, Int_t ssize, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
One-dimensional deconvolution function.
static Int_t fgIterations
Maximum number of decon iterations (default=3)
TH1 * fHistogram
resulting histogram
~TSpectrum() override
Destructor.
static Int_t StaticSearch(const TH1 *hist, Double_t sigma=2, Option_t *option="goff", Double_t threshold=0.05)
Static function, interface to TSpectrum::Search.
Double_t * fPositionY
[fNPeaks] Y position of peaks
void ToLower()
Change string to lower-case.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.