library: libHist
#include "TSpectrum2.h"

TSpectrum2


class description - header file - source file - inheritance tree (.pdf)

class TSpectrum2 : public TNamed

Inheritance Chart:
TObject
<-
TNamed
<-
TSpectrum2

    public:
TSpectrum2() TSpectrum2(Int_t maxpositions, Float_t resolution = 1) TSpectrum2(const TSpectrum2&) virtual ~TSpectrum2() virtual const char* Background(const TH1* hist, int niter, Option_t* option = "goff") const char* Background(float** spectrum, Int_t ssizex, Int_t ssizey, Int_t numberIterationsX, Int_t numberIterationsY, Int_t direction, Int_t filterType) static TClass* Class() const char* Deconvolution(float** source, float** resp, Int_t ssizex, Int_t ssizey, Int_t numberIterations, Int_t numberRepetitions, Double_t boost) TH1* GetHistogram() const Int_t GetNPeaks() const Float_t* GetPositionX() const Float_t* GetPositionY() const virtual TClass* IsA() const TSpectrum2& operator=(const TSpectrum2&) virtual void Print(Option_t* option = "") const virtual Int_t Search(const TH1* hist, Double_t sigma = 2, Option_t* option = "goff", Double_t threshold = 0.05) Int_t SearchHighRes(float** source, float** dest, Int_t ssizex, Int_t ssizey, Double_t sigma, Double_t threshold, Bool_t backgroundRemove, Int_t deconIterations, Bool_t markov, Int_t averWindow) void SetResolution(Float_t resolution = 1) virtual void ShowMembers(TMemberInspector& insp, char* parent) const char* SmoothMarkov(float** source, Int_t ssizex, Int_t ssizey, Int_t averWindow) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members


    protected:
Int_t fMaxPeaks Maximum number of peaks to be found Int_t fNPeaks number of peaks found Float_t* fPosition [fNPeaks] array of current peak positions Float_t* fPositionX [fNPeaks] X position of peaks Float_t* fPositionY [fNPeaks] Y position of peaks Float_t fResolution resolution of the neighboring peaks TH1* fHistogram resulting histogram public:
static const enum TSpectrum2:: kBackIncreasingWindow static const enum TSpectrum2:: kBackDecreasingWindow static const enum TSpectrum2:: kBackSuccessiveFiltering static const enum TSpectrum2:: kBackOneStepFiltering

Class Description

   THIS CLASS CONTAINS ADVANCED SPECTRA PROCESSING FUNCTIONS.            
                                                                         
   ONE-DIMENSIONAL BACKGROUND ESTIMATION FUNCTIONS                       
   TWO-DIMENSIONAL BACKGROUND ESTIMATION FUNCTIONS                       
   ONE-DIMENSIONAL SMOOTHING FUNCTIONS                                   
   TWO-DIMENSIONAL SMOOTHING FUNCTIONS                                   
   ONE-DIMENSIONAL DECONVOLUTION FUNCTIONS                               
   TWO-DIMENSIONAL DECONVOLUTION FUNCTIONS                               
   ONE-DIMENSIONAL PEAK SEARCH FUNCTIONS                                 
   TWO-DIMENSIONAL PEAK SEARCH FUNCTIONS                                 
                                                                         
   These functions were written by:                                      
   Miroslav Morhac                                                       
   Institute of Physics                                                  
   Slovak Academy of Sciences                                            
   Dubravska cesta 9, 842 28 BRATISLAVA                                  
   SLOVAKIA                                                              
                                                                         
   email:fyzimiro@savba.sk,    fax:+421 7 54772479                       
                                                                         
  The original code in C has been repackaged as a C++ class by R.Brun    
                                                                         
  The algorithms in this class have been published in the following      
  references:                                                            
   [1]  M.Morhac et al.: Background elimination methods for              
   multidimensional coincidence gamma-ray spectra. Nuclear               
   Instruments and Methods in Physics Research A 401 (1997) 113-         
   132.                                                                  
                                                                         
   [2]  M.Morhac et al.: Efficient one- and two-dimensional Gold         
   deconvolution and its application to gamma-ray spectra                
   decomposition. Nuclear Instruments and Methods in Physics             
   Research A 401 (1997) 385-408.                                        
                                                                         
   [3]  M.Morhac et al.: Identification of peaks in multidimensional     
   coincidence gamma-ray spectra. Nuclear Instruments and Methods in     
   Research Physics A  443(2000), 108-125.                               
                                                                         
   These NIM papers are also available as Postscript files from:         


ftp://root.cern.ch/root/SpectrumDec.ps.gz
ftp://root.cern.ch/root/SpectrumSrc.ps.gz
ftp://root.cern.ch/root/SpectrumBck.ps.gz

TSpectrum2()
 Constructor.
TSpectrum2(Int_t maxpositions, Float_t resolution)
  maxpositions:  maximum number of peaks
  resolution:    determines resolution of the neighboring peaks
                 default value is 1 correspond to 3 sigma distance
                 between peaks. Higher values allow higher resolution
                 (smaller distance between peaks.
                 May be set later through SetResolution.
~TSpectrum2()
 Destructor.
const char * Background(const TH1 * h, int number_of_iterations, Option_t * option)
   ONE-DIMENSIONAL BACKGROUND ESTIMATION FUNCTION                        
   This function calculates background spectrum from source in h.        
   The result is placed in the vector pointed by spectrum pointer.       
                                                                         
   Function parameters:                                                  
   spectrum:  pointer to the vector of source spectrum                   
   size:      length of spectrum and working space vectors               
   number_of_iterations, for details we refer to manual                  
                                                                         

void Print(Option_t *)
 Print the array of positions
Int_t Search(const TH1 * hin, Double_t sigma, Option_t * option, Double_t threshold)
   ONE-DIMENSIONAL PEAK SEARCH FUNCTION                                  
   This function searches for peaks in source spectrum in hin            
   The number of found peaks and their positions are written into        
   the members fNpeaks and fPositionX.                                   
                                                                         
   Function parameters:                                                  
   hin:       pointer to the histogram of source spectrum                
   sigma:   sigma of searched peaks, for details we refer to manual      
            Note that sigma is in number of bins                         
   threshold: (default=0.05)  peaks with amplitude less than             
       threshold*highest_peak are discarded.                             
                                                                         
   if option is not equal to "goff" (goff is the default), then          
   a polymarker object is created and added to the list of functions of  
   the histogram. The histogram is drawn with the specified option and   
   the polymarker object drawn on top of the histogram.                  
   The polymarker coordinates correspond to the npeaks peaks found in    
   the histogram.                                                        
   A pointer to the polymarker object can be retrieved later via:        
    TList *functions = hin->GetListOfFunctions();                        
    TPolyMarker *pm = (TPolyMarker*)functions->FindObject("TPolyMarker") 
                                                                         

void SetResolution(Float_t resolution)
  resolution: determines resolution of the neighboring peaks
              default value is 1 correspond to 3 sigma distance
              between peaks. Higher values allow higher resolution
              (smaller distance between peaks.
              May be set later through SetResolution.
const char * Background(float **spectrum, Int_t ssizex, Int_t ssizey, Int_t numberIterationsX, Int_t numberIterationsY, Int_t direction, Int_t filterType)
   TWO-DIMENSIONAL BACKGROUND ESTIMATION FUNCTION - RECTANGULAR RIDGES   
   This function calculates background spectrum from source spectrum.    
   The result is placed to the array pointed by spectrum pointer.        
                                                                         
   Function parameters:                                                  
   spectrum-pointer to the array of source spectrum                      
   ssizex-x length of spectrum                                           
   ssizey-y length of spectrum                                           
   numberIterationsX-maximal x width of clipping window                  
   numberIterationsY-maximal y width of clipping window                  
                           for details we refer to manual                
   direction- direction of change of clipping window                     
               - possible values=kBackIncreasingWindow                   
                                 kBackDecreasingWindow                   
   filterType-determines the algorithm of the filtering                  
                  -possible values=kBackSuccessiveFiltering              
                                   kBackOneStepFiltering                 
                                                                         
                                                                         


Background estimation

 

Goal: Separation of useful information (peaks) from useless information (background)

         method is based on Sensitive Nonlinear Iterative Peak (SNIP) clipping algorithm [1]

         there exist two algorithms for the estimation of new value in the channel “

 

Algorithm based on Successive Comparisons

It is an extension of one-dimensional SNIP algorithm to another dimension. For details we refer to [2].

 

Algorithm based on One Step Filtering

New value in the estimated channel is calculated as

 

 

 

.

 

where p = 1, 2, …, number_of_iterations.

 

Function:

const char* TSpectrum2::Background (float **spectrum, int ssizex, int ssizey, int numberIterationsX, int numberIterationsY, int direction, int filterType) 

 

This function calculates background spectrum from the source spectrum.  The result is placed in the matrix pointed by spectrum pointer.  One can also switch the direction of the change of the clipping window and to select one of the two above given algorithms. On successful completion it returns 0. On error it returns pointer to the string describing error.

 

Parameters:

        spectrum-pointer to the matrix of source spectrum                 

        ssizex, ssizey-lengths of the spectrum matrix                                

        numberIterationsX, numberIterationsYmaximal widths of clipping

        window,                                

        direction- direction of change of clipping window                 

               - possible values=kBackIncreasingWindow                     

                                            kBackDecreasingWindow                     

        filterType-type of the clipping algorithm,                             

                  -possible values=kBack SuccessiveFiltering

                                              kBackOneStepFiltering                             

 

References:

[1]  C. G Ryan et al.: SNIP, a statistics-sensitive background treatment for the quantitative analysis of PIXE spectra in geoscience applications. NIM, B34 (1988), 396-402.

[2]  M. Morháč, J. Kliman, V. Matoušek, M. Veselský, I. Turzo.: Background elimination methods for multidimensional gamma-ray spectra. NIM, A401 (1997) 113-132.

const char* SmoothMarkov(float **source, Int_t ssizex, Int_t ssizey, Int_t averWindow)
   TWO-DIMENSIONAL MARKOV SPECTRUM SMOOTHING FUNCTION

   This function calculates smoothed spectrum from source spectrum
      based on Markov chain method.
   The result is placed in the array pointed by source pointer.

   Function parameters:
   source-pointer to the array of source spectrum
   ssizex-x length of source
   ssizey-y length of source
   averWindow-width of averaging smoothing window


Smoothing

 

Goal: Suppression of statistical fluctuations

         the algorithm is based on discrete Markov chain, which has very simple invariant distribution

 

                 

          being defined from the normalization condition

 

         n is the length of the smoothed spectrum and

 

 

 


is the probability of the change of the peak position from channel i to the channel i+1.  is the normalization constant so that  and m is a width of smoothing window. We have extended this algortihm to two dimensions.

 

Function:

const char* TSpectrum2::SmoothMarkov(float **fSpectrum, int ssizex, int ssizey,  int averWindow) 

 

This function calculates smoothed spectrum from the source spectrum based on Markov chain method. The result is placed in the vector pointed by source pointer. On successful completion it returns 0. On error it returns pointer to the string describing error.

 

Parameters:

        fSpectrum-pointer to the matrix of source spectrum                 

        ssizex, ssizey -lengths of the spectrum matrix                                

        averWindow-width of averaging smoothing window

 

Reference:

[1] Z.K. Silagadze, A new algorithm for automatic photopeak searches. NIM A 376 (1996), 451. 

const char * Deconvolution(float **source, float **resp, Int_t ssizex, Int_t ssizey, Int_t numberIterations, Int_t numberRepetitions, Double_t boost)
   TWO-DIMENSIONAL DECONVOLUTION FUNCTION
   This function calculates deconvolution from source spectrum
   according to response spectrum
   The result is placed in the matrix pointed by source pointer.

   Function parameters:
   source-pointer to the matrix of source spectrum
   resp-pointer to the matrix of response spectrum
   ssizex-x length of source and response spectra
   ssizey-y length of source and response spectra
   numberIterations, for details we refer to manual
   numberRepetitions, for details we refer to manual
   boost, boosting factor, for details we refer to manual


Deconvolution

 

Goal: Improvement of the resolution in spectra, decomposition of multiplets

 

Mathematical formulation of the 2-dimensional convolution system is

 

 

 

 

 

 

 

 


where h(i,j) is the impulse response function, x, y are input and output matrices, respectively,  are the lengths of x and h matrices

         let us assume that we know the response and the output matrices (spectra) of the above given system.

         the deconvolution represents solution of the overdetermined system of linear equations, i.e.,  the calculation of the matrix x.

         from numerical stability point of view the operation of deconvolution is extremely critical (ill-posed  problem) as well as time consuming operation.

         the Gold deconvolution algorithm proves to work very well even for 2-dimensional systems. Generalization of the algorithm for 2-dimensional systems was presented in [1], [2].

         for Gold deconvolution algorithm as well as for boosted deconvolution algorithm we refer also to TSpectrum

 

Function:

const char* TSpectrum2::Deconvolution(float **source, const float **resp, int ssizex, int ssizey, int numberIterations, int numberRepetitions, double boost)

 

This function calculates deconvolution from source spectrum according to response spectrum using Gold deconvolution algorithm. The result is placed in the matrix pointed by source pointer. On successful completion it returns 0. On error it returns pointer to the string describing error. If desired after every numberIterations one can apply boosting operation (exponential function with exponent given by boost coefficient) and repeat it numberRepetitions times.

 

Parameters:

        source-pointer to the matrix of source spectrum                 

        resp-pointer to the matrix of response spectrum                 

        ssizex, ssizey-lengths of the spectrum matrix                                

        numberIterations-number of iterations

        numberRepetitions-number of repetitions for boosted deconvolution. It must be

        greater or equal to one.

        boost-boosting coefficient, applies only if numberRepetitions is greater than one. 

        Recommended range <1,2>.

 

References:

 [1] M. Morháč, J. Kliman, V. Matoušek, M. Veselský, I. Turzo.: Efficient one- and two-dimensional Gold deconvolution and its application to gamma-ray spectra decomposition. NIM, A401 (1997) 385-408.

[2] Morháč M., Matoušek V., Kliman J., Efficient algorithm of multidimensional deconvolution and its application to nuclear data processing, Digital Signal Processing 13 (2003) 144.

 

Int_t SearchHighRes(float **source,float **dest, Int_t ssizex, Int_t ssizey, Double_t sigma, Double_t threshold, Bool_t backgroundRemove,Int_t deconIterations, Bool_t markov, Int_t averWindow)
   TWO-DIMENSIONAL HIGH-RESOLUTION PEAK SEARCH FUNCTION                  
   This function searches for peaks in source spectrum                   
      It is based on deconvolution method. First the background is       
      removed (if desired), then Markov spectrum is calculated           
      (if desired), then the response function is generated              
      according to given sigma and deconvolution is carried out.         
                                                                         
   Function parameters:                                                  
   source-pointer to the matrix of source spectrum                       
   dest-pointer to the matrix of resulting deconvolved spectrum          
   ssizex-x length of source spectrum                                    
   ssizey-y length of source spectrum                                    
   sigma-sigma of searched peaks, for details we refer to manual         
   threshold-threshold value in % for selected peaks, peaks with         
                amplitude less than threshold*highest_peak/100           
                are ignored, see manual                                  
      backgroundRemove-logical variable, set if the removal of           
                background before deconvolution is desired               
      deconIterations-number of iterations in deconvolution operation    
      markov-logical variable, if it is true, first the source spectrum  
             is replaced by new spectrum calculated using Markov         
             chains method.                                              
   averWindow-averanging window of searched peaks, for details           
                  we refer to manual (applies only for Markov method)    
                                                                         

Peaks searching

 

Goal: to identify automatically the peaks in spectrum with the presence of the continuous background, one-fold coincidences (ridges) and statistical fluctuations - noise.

 

The common problems connected with correct peak identification in two-dimensional coincidence spectra are

 

Function:

Int_t TSpectrum2::SearchHighRes (float **source,float **dest, int ssizex, int ssizey, float sigma, double threshold, bool backgroundRemove,int deconIterations, bool markov, int averWindow)   

 

This function searches for peaks in source spectrum. It is based on deconvolution method. First the background is removed (if desired), then Markov smoothed spectrum is calculated (if desired), then the response function is generated according to given sigma and deconvolution is carried out. The order of peaks is arranged according to their heights in the spectrum after background elimination. The highest peak is the first in the list. On success it returns number of found peaks.

 

Parameters:

        source-pointer to the matrix of source spectrum                 

        dest-resulting spectrum after deconvolution

        ssizex, ssizey-lengths of the source and destination spectra               

        sigma-sigma of searched peaks

threshold- threshold value in % for selected peaks, peaks with amplitude less than threshold*highest_peak/100 are ignored

backgroundRemove- background_remove-logical variable, true if the removal of background before deconvolution is desired 

deconIterations-number of iterations in deconvolution operation

markov-logical variable, if it is true, first the source spectrum is replaced by new spectrum calculated using Markov chains method

averWindow-width of averaging smoothing window

 

References:

[1] M.A. Mariscotti: A method for identification of peaks in the presence of background and its application to spectrum analysis. NIM 50 (1967), 309-320.

[2]  M. Morháč, J. Kliman, V. Matoušek, M. Veselský, I. Turzo.:Identification of peaks in multidimensional coincidence gamma-ray spectra. NIM, A443 (2000) 108-125.

[3] Z.K. Silagadze, A new algorithm for automatic photopeak searches. NIM A 376 (1996), 451.

TSpectrum2()
Int_t GetNPeaks()

Author: Miroslav Morhac 17/01/2006
Last update: root/hist:$Name: $:$Id: TSpectrum2.cxx,v 1.15 2006/06/28 13:11:49 brun Exp $


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.