37#define PEAK_WINDOW 1024
64 :
TNamed(
"Spectrum",
"Miroslav Morhac peak finder")
148 if (
h ==
nullptr)
return nullptr;
149 Int_t dimension =
h->GetDimension();
151 Error(
"Search",
"Only implemented for 1-d histograms");
176 Int_t first =
h->GetXaxis()->GetFirst();
177 Int_t last =
h->GetXaxis()->GetLast();
181 for (i = 0; i <
size; i++)
source[i] =
h->GetBinContent(i + first);
194 hb->GetListOfFunctions()->Delete();
196 for (i=0; i<
size; i++)
hb->SetBinContent(i+first,
source[i]);
262 if (
hin ==
nullptr)
return 0;
263 Int_t dimension =
hin->GetDimension();
265 Error(
"Search",
"Only implemented for 1-d and 2-d histograms");
269 Warning(
"Search",
"threshold must 0<threshold<1, threshold=0.05 assumed");
289 if (dimension == 1) {
290 Int_t first =
hin->GetXaxis()->GetFirst();
291 Int_t last =
hin->GetXaxis()->GetLast();
296 for (i = 0; i <
size; i++)
source[i] =
hin->GetBinContent(i + first);
305 for (i = 0; i <
npeaks; i++) {
317 (
TPolyMarker*)
hin->GetListOfFunctions()->FindObject(
"TPolyMarker");
319 hin->GetListOfFunctions()->Remove(
pm);
323 hin->GetListOfFunctions()->Add(
pm);
324 pm->SetMarkerStyle(23);
326 pm->SetMarkerSize(1.3);
512 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;
514 return "Wrong Parameters";
516 return "Width of Clipping Window Must Be Positive";
518 return "Too Large Clipping Window";
520 return "Incorrect width of smoothing window";
522 for (i = 0; i <
ssize; i++){
555 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
564 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
618 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
627 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
727 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
736 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
827 b6 = (
b6 - 6 *
c6 + 15 *
d6 + 15 *
e6 - 6 * f6 +
g6) / 20;
900 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
909 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
1000 b6 = (
b6 - 6 *
c6 + 15 *
d6 + 15 *
e6 - 6 * f6 +
g6) / 20;
1066 b8 = ( -
b8 + 8 *
c8 - 28 *
d8 + 56 *
e8 - 56 * f8 - 28 *
g8 + 8 *
h8 -
i8)/70;
1088 for (i = 0, b2 = 0; i <
ssize; i++){
1097 for (b2 = b1 + 1,
c = 0,
priz = 0;
priz == 0 && b2 <
ssize; b2++){
1109 for (
j = b1,
c = 0;
j <= b2;
j++){
1115 for (
j = b1,
d = 0;
j <= b2 &&
j <
ssize;
j++){
1125 for (
j = b2,
c = 0;
j >= b1;
j--){
1131 for (
j = b2,
d = 0;
j >= b1 &&
j >= 0;
j--){
1194 return "Averaging Window must be positive";
1230 if((i -
l + 1) <
xmin)
1251 for(i = 0; i <
ssize; i++)
1457 return "Wrong Parameters";
1460 return "Wrong Parameters";
1473 for (i = 0; i <
ssize; i++) {
1486 return "ZERO RESPONSE VECTOR";
1490 for (i = 0; i <
ssize; i++)
1494 for (i = 0; i <
ssize; i++){
1506 for (k = 0; k <
ssize; k++){
1518 for (i = 0; i <
ssize; i++){
1523 for (i = 0; i <
ssize; i++)
1529 for (i = 0; i <
ssize; i++)
1533 for (i = 0; i <
ssize; i++) {
1564 for (i = 0; i <
ssize; i++)
1570 for (i = 0; i <
ssize; i++) {
1578 for (i = 0; i <
ssize; i++)
1663 return "Wrong Parameters";
1666 return "Wrong Parameters";
1678 for (i = 0; i <
ssize; i++) {
1690 return "ZERO RESPONSE VECTOR";
1694 for (i = 0; i <
ssize; i++)
1698 for (i = 0; i <
ssize; i++){
1709 for (i = 0; i <
ssize; i++)
1727 for (k = kmax; k >= kmin; k--){
1744 for (i = 0; i <
ssize; i++)
1750 for (i = 0; i <
ssize; i++) {
1758 for (i = 0; i <
ssize; i++)
1891 return "Wrong Parameters";
1893 return "Sizex must be greater than sizey)";
1895 return "Number of iterations must be positive";
1903 for (i = 0; i <
ssizex; i++) {
1912 for (i = 0; i <
ssizex; i++)
1918 return (
"ZERO COLUMN IN RESPONSE MATRIX");
1922 for (i = 0; i <
ssizex; i++)
1927 for (i = 0; i <
ssizey; i++) {
1930 for (k = 0; k <
ssizex; k++) {
1938 for (k = 0; k <
ssizex; k++) {
1950 for (i = 0; i <
ssizey; i++)
1955 for (i = 0; i <
ssizey; i++) {
1958 for (k = 0; k <
ssizey; k++) {
1967 for (k = 0; k <
ssizey; k++) {
1979 for (i = 0; i <
ssizey; i++)
1984 for (i = 0; i <
ssizey; i++)
1990 for (i = 0; i <
ssizey; i++)
1994 for (i = 0; i <
ssizey; i++) {
2014 for (i = 0; i <
ssizey; i++)
2021 for (i = 0; i <
ssizex; i++) {
2133 Error(
"SearchHighRes",
"Invalid sigma, must be greater than or equal to 1");
2138 Error(
"SearchHighRes",
"Invalid threshold, must be positive and less than 100");
2144 Error(
"SearchHighRes",
"Too large sigma");
2150 Error(
"SearchHighRes",
"Averaging window must be positive");
2157 Error(
"SearchHighRes",
"Too large clipping window");
2164 for(i = 0;i < k;i++){
2194 else if(i >=
ssize + shift){
2195 a = i - (
ssize - 1 + shift);
2230 for (
w =
j - i -
bw;
w <=
j - i +
bw;
w++){
2239 for (
w =
j + i -
bw;
w <=
j + i +
bw;
w++){
2263 else if(
j >=
ssize + shift){
2321 if((i -
l + 1) <
xmin)
2481 if(i >= shift && i <
ssize + shift){
2500 if(i >= shift && i <
ssize + shift){
2502 for(
j = i - 1,
a = 0,
b = 0;
j <= i + 1;
j++){
2548 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.