library: libHist #include "TSpectrum.h"

# TSpectrum

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

## class TSpectrum : public TNamed

| Inheritance Chart:

`TObject`

<-

`TNamed`

<-

`TSpectrum`

        public:

                              TSpectrum()
                              TSpectrum(Int_t maxpositions, Float_t resolution = 1)
                              TSpectrum(const TSpectrum&)
                      virtual ~TSpectrum()
                       double Area(double a, double sigma, double t, double b)
          virtual const char* Background(TH1* hist, int niter, Option_t* option = "goff") const
                  const char* Background1(float* spectrum, int size, int niter) const
                  const char* Background1General(float* spectrum, int size, int number_of_iterations, int direction, int filter_order, bool compton) const
                         void BitReverse(float* working_space, int num)
                         void BitReverseHaar(float* working_space, int shift, int num, int start)
               static TClass* Class()
                  const char* Deconvolution1(float* source, const float* resp, int size, int niter) const
                  const char* Deconvolution1HighResolution(float* source, const float* resp, int size, int number_of_iterations, int number_of_repetitions, double boost) const
                  const char* Deconvolution1Unfolding(float* source, const float** resp, int sizex, int sizey, int number_of_iterations) const
                       double Dera1(double i)
                       double Dera2(double i)
                       double Deramp(double i, double i0, double sigma, double t, double s, double b)
                       double Derb(int num_of_fitted_peaks, double i, const double* parameter, double sigma, double t, double b)
                       double Derderi0(double i, double amp, double i0, double sigma)
                       double Derdersigma(int num_of_fitted_peaks, double i, const double* parameter, double sigma)
                       double Derfc(double x)
                       double Deri0(double i, double amp, double i0, double sigma, double t, double s, double b)
                       double Derpa(double sigma, double t, double b)
                       double Derpb(double a, double sigma, double t, double b)
                       double Derpsigma(double a, double t, double b)
                       double Derpt(double a, double sigma, double b)
                       double Ders(int num_of_fitted_peaks, double i, const double* parameter, double sigma)
                       double Dersigma(int num_of_fitted_peaks, double i, const double* parameter, double sigma, double t, double s, double b)
                       double Dert(int num_of_fitted_peaks, double i, const double* parameter, double sigma, double b)
                  const char* Enhance1(const float* source, float* dest, int size, int type, int degree, int xmin, int xmax, float enhance_coeff) const
                       double Erfc(double x)
                  const char* Filter1Zonal(const float* source, float* dest, int size, int type, int degree, int xmin, int xmax, float filter_coeff) const
                  const char* Fit1Awmi(float* source, TSpectrumOneDimFit* p, int size) const
                  const char* Fit1Stiefel(float* source, TSpectrumOneDimFit* p, int size) const
                         void Fourier(float* working_space, int num, int hartley, int direction, int zt_clear)
                          int GeneralExe(float* working_space, int zt_clear, int num, int degree, int type)
                          int GeneralInv(float* working_space, int num, int degree, int type)
                         TH1* GetHistogram() const
                        Int_t GetNPeaks() const
                     Float_t* GetPositionX() const
                     Float_t* GetPositionY() const
                         void Haar(float* working_space, int num, int direction)
              virtual TClass* IsA() const
                       double Lls(double a)
                   TSpectrum& operator=(const TSpectrum&)
                       double Ourpowl(double a, int pw)
                virtual Int_t Search(TH1* hist, Double_t sigma, Option_t* option = "goff", Double_t threshold = 0.05)
                        Int_t Search1HighRes(float* source, float* dest, int size, float sigma, double threshold, bool background_remove, int decon_iterations, bool markov, int aver_window)
                  static void SetAverageWindow(Int_t w = 3)
                  static void SetDeconIterations(Int_t n = 3)
                         void SetResolution(Float_t resolution = 1)
                       double Shape(int num_of_fitted_peaks, double i, const double* parameter, double sigma, double t, double s, double b, double a0, double a1, double a2)
                 virtual void ShowMembers(TMemberInspector& insp, char* parent)
                  const char* Smooth1Markov(float* source, int size, int aver_window) const
                         void StiefelInversion(double** a, int rozmer)
                 virtual void Streamer(TBuffer& b)
                         void StreamerNVirtual(TBuffer& b)
                  const char* Transform1(const float* source, float* dest, int size, int type, int direction, int degree) const
                         void Walsh(float* working_space, int num)

### Data Members

        protected:

                 Int_t fMaxPeaks        Maximum number of peaks to be found
                 Int_t fNPeaks          number of peaks found
              Float_t* fPosition        !array of current peak positions
              Float_t* fPositionX       !X position of peaks
              Float_t* fPositionY       !Y position of peaks
               Float_t fResolution      resolution of the neighboring peaks
                  TH1* fHistogram       resulting histogram
          static Int_t fgAverageWindow  Average window of searched peaks
          static Int_t fgIterations     Maximum number of decon iterations (default=3)

## Class Description

       THIS CLASS CONTAINS ADVANCED SPECTRA PROCESSING FUNCTIONS.

       ONE-DIMENSIONAL BACKGROUND ESTIMATION FUNCTIONS
       ONE-DIMENSIONAL SMOOTHING FUNCTIONS
       ONE-DIMENSIONAL DECONVOLUTION FUNCTIONS
       ONE-DIMENSIONAL PEAK SEARCH FUNCTIONS
       ONE-DIMENSIONAL PEAKS FITTING FUNCTIONS
       ONE-DIMENSIONAL ORTHOGONAL TRANSFORMS 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. Submitted for publication in
       Nuclear Instruments and Methods in Physics Research A.

       These NIM papers are also available as doc or ps files from:

Spectrum.doc
SpectrumDec.ps.gz
SpectrumSrc.ps.gz
SpectrumBck.ps.gz

    ____________________________________________________________________________

TSpectrum() :TNamed("Spectrum", "Miroslav Morhac peak finder")

TSpectrum(Int_t maxpositions, Float_t resolution) :TNamed("Spectrum", "Miroslav Morhac peak finder")

      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.

~TSpectrum()

void SetAverageWindow(Int_t w)

     static function: Set average window of searched peaks
     see TSpectrum::Search1HighRes

void SetDeconIterations(Int_t n)

     static function: Set max number of decon iterations in deconvolution operation
     see TSpectrum::Search1HighRes

const char* Background(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

Int_t Search(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.
       The search is performed in the current histogram range.

       Function parameters:
       hin:       pointer to the histogram of source spectrum
       sigma:   sigma of searched peaks, for details we refer to manual
       threshold: (default=0.05)  peaks with amplitude less than
           threshold*highest_peak are discarded.  0<threshold<1

       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* Background1(float *spectrum, int size, int number_of_iterations)

const char* Background1General(float *spectrum, int size, int number_of_iterations, int direction, int filter_order, bool compton)

const char* Smooth1Markov(float *source, int size, int aver_window)

const char* Deconvolution1(float *source, const float *resp, int size, int number_of_iterations)

       ONE-DIMENSIONAL DECONVOLUTION FUNCTION
       This function calculates deconvolution from source spectrum
       according to response spectrum
       The result is placed in the vector pointed by source pointer.

       Function parameters:
       source:  pointer to the vector of source spectrum
       res:     pointer to the vector of response spectrum
       size:    length of source and response spectra
       number_of_iterations, for details we refer to this reference:

        M. Morhac, J. Kliman, V. Matousek, M. Veselský, I. Turzo.:
        Efficient one- and two-dimensional Gold deconvolution and its
        application to gamma-ray spectra decomposition.
        NIM, A401 (1997) 385-408.

double Lls(double a)

       AUXILIARY FUNCION

       LLS operator. It calculates log(log(sqrt(a+1))) value of a.

const char* Deconvolution1HighResolution(float *source, const float *resp, int size, int number_of_iterations, int number_of_repetitions, double boost)

const char* Deconvolution1Unfolding(float *source, const float **resp, int sizex, int sizey, int number_of_iterations)

Int_t Search1HighRes(float *source,float *dest, int size, float sigma, double threshold, bool background_remove,int decon_iterations, bool markov, int aver_window)

double Erfc(double x)

       AUXILIARY FUNCION

       This funcion calculates error function of x.

double Derfc(double x)

double Deramp(double i, double i0, double sigma, double t, double s, double b)

double Deri0(double i, double amp, double i0, double sigma, double t, double s, double b)

double Derderi0(double i, double amp, double i0, double sigma)

double Dersigma(int num_of_fitted_peaks, double i, const double *parameter, double sigma, double t, double s, double b)

double Derdersigma(int num_of_fitted_peaks, double i, const double *parameter, double sigma)

double Dert(int num_of_fitted_peaks, double i, const double *parameter, double sigma, double b)

double Ders(int num_of_fitted_peaks, double i, const double *parameter, double sigma)

double Derb(int num_of_fitted_peaks, double i, const double *parameter, double sigma, double t, double b)

double Dera1(double i) //derivative of backgroud according to a1

double Dera2(double i) //derivative of backgroud according to a2

double Shape(int num_of_fitted_peaks, double i, const double *parameter, double sigma, double t, double s, double b, double a0, double a1, double a2)

double Area(double a, double sigma, double t, double b)

double Derpa(double sigma, double t, double b)

double Derpsigma(double a, double t, double b)

double Derpt(double a, double sigma, double b)

double Derpb(double a, double sigma, double t, double b)

double Ourpowl(double a, int pw)

const char* Fit1Awmi(float *source, TSpectrumOneDimFit * p, int size)

void StiefelInversion(double **a, int size)

       AUXILIARY FUNCION

       This funcion calculates solution of the system of linear equations.
       The matrix a should have a dimension size*(size+4)
       The calling function should fill in the matrix, the column size should
       contain vector y (right side of the system of equations). The result is
       placed into size+1 column of the matrix.
       according to sigma of peaks.
          Function parameters:
                  -a-matrix with dimension size*(size+4)                          //
                  -size-number of rows of the matrix

const char* Fit1Stiefel(float *source, TSpectrumOneDimFit * p, int size)

void Haar(float *working_space, int num, int direction)

       AUXILIARY FUNCION

       This funcion calculates Haar transform of a part of data
          Function parameters:
                  -working_space-pointer to vector of transformed data
                  -num-length of processed data
                  -direction-forward or inverse transform

void Walsh(float *working_space, int num)

void BitReverse(float *working_space, int num)

       AUXILIARY FUNCION

       This funcion carries out bir-reverse reordering of data
          Function parameters:
                  -working_space-pointer to vector of processed data
                  -num-length of processed data

void Fourier(float *working_space, int num, int hartley, int direction, int zt_clear)

       AUXILIARY FUNCION

       This funcion calculates Fourier based transform of a part of data
          Function parameters:
                  -working_space-pointer to vector of transformed data
                  -num-length of processed data
                  -hartley-1 if it is Hartley transform, 0 othewise
                  -direction-forward or inverse transform

void BitReverseHaar(float *working_space, int shift, int num, int start)

int GeneralExe(float *working_space, int zt_clear, int num, int degree, int type)

int GeneralInv(float *working_space, int num, int degree, int type)

const char* Transform1(const float *source, float *dest, int size, int type, int direction, int degree)

const char* Filter1Zonal(const float *source, float *dest, int size, int type, int degree, int xmin, int xmax, float filter_coeff)

const char* Enhance1(const float *source, float *dest, int size, int type, int degree, int xmin, int xmax, float enhance_coeff)

### Inline Functions

                   TH1* GetHistogram() const
                  Int_t GetNPeaks() const
               Float_t* GetPositionX() const
               Float_t* GetPositionY() const
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
              TSpectrum TSpectrum(const TSpectrum&)
             TSpectrum& operator=(const TSpectrum&)

Author: Miroslav Morhac 27/05/99
Last update: root/hist:$Name: $:$Id: TSpectrum.cxx,v 1.29 2005/06/20 08:34:56 brun Exp $