37#define PEAK_WINDOW 1024 
   63          :
TNamed(
"Spectrum", 
"Miroslav Morhac peak finder")
 
 
  147   if (
h == 
nullptr) 
return nullptr;
 
  148   Int_t dimension = 
h->GetDimension();
 
  150      Error(
"Search", 
"Only implemented for 1-d histograms");
 
  175   Int_t first = 
h->GetXaxis()->GetFirst();
 
  176   Int_t last  = 
h->GetXaxis()->GetLast();
 
  180   for (i = 0; i < 
size; i++) 
source[i] = 
h->GetBinContent(i + first);
 
  193   hb->GetListOfFunctions()->Delete();
 
  195   for (i=0; i< 
size; i++) 
hb->SetBinContent(i+first,
source[i]);
 
 
  261   if (
hin == 
nullptr) 
return 0;
 
  262   Int_t dimension = 
hin->GetDimension();
 
  264      Error(
"Search", 
"Only implemented for 1-d and 2-d histograms");
 
  268      Warning(
"Search",
"threshold must 0<threshold<1, threshold=0.05 assumed");
 
  288   if (dimension == 1) {
 
  289      Int_t first = 
hin->GetXaxis()->GetFirst();
 
  290      Int_t last  = 
hin->GetXaxis()->GetLast();
 
  295      for (i = 0; i < 
size; i++) 
source[i] = 
hin->GetBinContent(i + first);
 
  304      for (i = 0; i < 
npeaks; i++) {
 
  316         (
TPolyMarker*)
hin->GetListOfFunctions()->FindObject(
"TPolyMarker");
 
  318         hin->GetListOfFunctions()->Remove(
pm);
 
  322      hin->GetListOfFunctions()->Add(
pm);
 
  323      pm->SetMarkerStyle(23);
 
  325      pm->SetMarkerSize(1.3);
 
 
  511   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;
 
  513      return "Wrong Parameters";
 
  515      return "Width of Clipping Window Must Be Positive";
 
  517      return "Too Large Clipping Window";
 
  519      return "Incorrect width of smoothing window";
 
  521   for (i = 0; i < 
ssize; i++){
 
  554               for (
w = 
j - i - 
bw; 
w <= 
j - i + 
bw; 
w++){
 
  563               for (
w = 
j + i - 
bw; 
w <= 
j + i + 
bw; 
w++){
 
  617               for (
w = 
j - i - 
bw; 
w <= 
j - i + 
bw; 
w++){
 
  626               for (
w = 
j + i - 
bw; 
w <= 
j + i + 
bw; 
w++){
 
  726               for (
w = 
j - i - 
bw; 
w <= 
j - i + 
bw; 
w++){
 
  735               for (
w = 
j + i - 
bw; 
w <= 
j + i + 
bw; 
w++){
 
  826               b6 = (
b6 - 6 * 
c6 + 15 * 
d6 + 15 * 
e6 - 6 * f6 + 
g6) / 20;
 
  899               for (
w = 
j - i - 
bw; 
w <= 
j - i + 
bw; 
w++){
 
  908               for (
w = 
j + i - 
bw; 
w <= 
j + i + 
bw; 
w++){
 
  999               b6 = (
b6 - 6 * 
c6 + 15 * 
d6 + 15 * 
e6 - 6 * f6 + 
g6) / 20;
 
 1065               b8 = ( -
b8 + 8 * 
c8 - 28 * 
d8 + 56 * 
e8 - 56 * f8 - 28 * 
g8 + 8 * 
h8 - 
i8)/70;
 
 1087      for (i = 0, b2 = 0; i < 
ssize; i++){
 
 1096            for (b2 = b1 + 1, 
c = 0, 
priz = 0; 
priz == 0 && b2 < 
ssize; b2++){
 
 1108               for (
j = b1, 
c = 0; 
j <= b2; 
j++){
 
 1114                  for (
j = b1, 
d = 0; 
j <= b2 && 
j < 
ssize; 
j++){
 
 1124               for (
j = b2, 
c = 0; 
j >= b1; 
j--){
 
 1130                  for (
j = b2, 
d = 0;
j >= b1 && 
j >= 0; 
j--){
 
 
 1193      return "Averaging Window must be positive";
 
 1229         if((i - 
l + 1) < 
xmin)
 
 1250   for(i = 0; i < 
ssize; i++)
 
 
 1456      return "Wrong Parameters";
 
 1459      return "Wrong Parameters";
 
 1472   for (i = 0; i < 
ssize; i++) {
 
 1485      return "ZERO RESPONSE VECTOR";
 
 1489   for (i = 0; i < 
ssize; i++)
 
 1493   for (i = 0; i < 
ssize; i++){
 
 1505      for (k = 0; k < 
ssize; k++){
 
 1517   for (i = 0; i < 
ssize; i++){
 
 1522   for (i = 0; i < 
ssize; i++)
 
 1528         for (i = 0; i < 
ssize; i++)
 
 1532         for (i = 0; i < 
ssize; i++) {
 
 1563         for (i = 0; i < 
ssize; i++)
 
 1569   for (i = 0; i < 
ssize; i++) {
 
 1577   for (i = 0; i < 
ssize; i++)
 
 
 1662      return "Wrong Parameters";
 
 1665      return "Wrong Parameters";
 
 1677   for (i = 0; i < 
ssize; i++) {
 
 1689      return "ZERO RESPONSE VECTOR";
 
 1693   for (i = 0; i < 
ssize; i++)
 
 1697   for (i = 0; i < 
ssize; i++){
 
 1708         for (i = 0; i < 
ssize; i++)
 
 1726                        for (k = kmax; k >= kmin; k--){
 
 1743         for (i = 0; i < 
ssize; i++)
 
 1749   for (i = 0; i < 
ssize; i++) {
 
 1757   for (i = 0; i < 
ssize; i++)
 
 
 1890      return "Wrong Parameters";
 
 1892      return "Sizex must be greater than sizey)";
 
 1894      return "Number of iterations must be positive";
 
 1902      for (i = 0; i < 
ssizex; i++) {
 
 1911         for (i = 0; i < 
ssizex; i++)
 
 1917      return (
"ZERO COLUMN IN RESPONSE MATRIX");
 
 1921   for (i = 0; i < 
ssizex; i++)
 
 1926   for (i = 0; i < 
ssizey; i++) {
 
 1929         for (k = 0; k < 
ssizex; k++) {
 
 1937      for (k = 0; k < 
ssizex; k++) {
 
 1949   for (i = 0; i < 
ssizey; i++)
 
 1954   for (i = 0; i < 
ssizey; i++) {
 
 1957         for (k = 0; k < 
ssizey; k++) {
 
 1966      for (k = 0; k < 
ssizey; k++) {
 
 1978   for (i = 0; i < 
ssizey; i++)
 
 1983   for (i = 0; i < 
ssizey; i++)
 
 1989         for (i = 0; i < 
ssizey; i++)
 
 1993         for (i = 0; i < 
ssizey; i++) {
 
 2013         for (i = 0; i < 
ssizey; i++)
 
 2020   for (i = 0; i < 
ssizex; i++) {
 
 
 2132      Error(
"SearchHighRes", 
"Invalid sigma, must be greater than or equal to 1");
 
 2137      Error(
"SearchHighRes", 
"Invalid threshold, must be positive and less than 100");
 
 2143      Error(
"SearchHighRes", 
"Too large sigma");
 
 2149         Error(
"SearchHighRes", 
"Averaging window must be positive");
 
 2156         Error(
"SearchHighRes", 
"Too large clipping window");
 
 2163      for(i = 0;i < k;i++){
 
 2193      else if(i >= 
ssize + shift){
 
 2194         a = i - (
ssize - 1 + shift);
 
 2229               for (
w = 
j - i - 
bw; 
w <= 
j - i + 
bw; 
w++){
 
 2238               for (
w = 
j + i - 
bw; 
w <= 
j + i + 
bw; 
w++){
 
 2262         else if(
j >= 
ssize + shift){
 
 2320            if((i - 
l + 1) < 
xmin)
 
 2480      if(i >= shift && i < 
ssize + shift){
 
 2499         if(i >= shift && i < 
ssize + shift){
 
 2501               for(
j = i - 1, 
a = 0, 
b = 0; 
j <= i + 1; 
j++){
 
 2547      Warning(
"SearchHighRes", 
"Peak buffer full");
 
 
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
 
int Int_t
Signed integer 4 bytes (int)
 
double Double_t
Double 8 bytes.
 
const char Option_t
Option string (const char)
 
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.