// @(#)root/spectrum:$Id$
// Author: Miroslav Morhac   17/01/2006

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
#ifndef ROOT_TSpectrum2
#define ROOT_TSpectrum2

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

class TH1;

class TSpectrum2 : public TNamed {
protected:
   Int_t         fMaxPeaks;       //Maximum number of peaks to be found
   Int_t         fNPeaks;         //number of peaks found
   Double_t      *fPosition;       //[fNPeaks] array of current peak positions
   Double_t      *fPositionX;      //[fNPeaks] X position of peaks
   Double_t      *fPositionY;      //[fNPeaks] Y position of peaks
   Double_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)

public:
   enum {
       kBackIncreasingWindow =0,
       kBackDecreasingWindow =1,
       kBackSuccessiveFiltering =0,
       kBackOneStepFiltering =1
   };

   TSpectrum2();
   TSpectrum2(Int_t maxpositions, Double_t resolution=1);
   virtual ~TSpectrum2();
   virtual TH1  *Background(const TH1 *hist, Int_t niter=20, Option_t *option="");
   TH1          *GetHistogram() const {return fHistogram;}
   Int_t         GetNPeaks() const {return fNPeaks;}
   Double_t      *GetPositionX() const {return fPositionX;}
   Double_t      *GetPositionY() const {return fPositionY;}
   virtual void  Print(Option_t *option="") const;
   virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05);
   static void   SetAverageWindow(Int_t w=3);   //set average window
   static void   SetDeconIterations(Int_t n=3); //set max number of decon iterations
   void          SetResolution(Double_t resolution=1);

   //new functions January 2006
   const char   *Background(Double_t **spectrum,Int_t ssizex, Int_t ssizey,Int_t numberIterationsX,Int_t numberIterationsY,Int_t direction,Int_t filterType);   
   const char   *SmoothMarkov(Double_t **source, Int_t ssizex, Int_t ssizey, Int_t averWindow);   
   const char   *Deconvolution(Double_t **source, Double_t **resp, Int_t ssizex, Int_t ssizey,Int_t numberIterations, Int_t numberRepetitions, Double_t boost);
   Int_t         SearchHighRes(Double_t **source,Double_t **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);

   static Int_t        StaticSearch(const TH1 *hist, Double_t sigma=2, Option_t *option="goff", Double_t threshold=0.05);
   static TH1         *StaticBackground(const TH1 *hist,Int_t niter=20, Option_t *option="");

   ClassDef(TSpectrum2,1)  //Peak Finder, background estimator, Deconvolution for 2-D histograms
};

#endif

 TSpectrum2.h:1
 TSpectrum2.h:2
 TSpectrum2.h:3
 TSpectrum2.h:4
 TSpectrum2.h:5
 TSpectrum2.h:6
 TSpectrum2.h:7
 TSpectrum2.h:8
 TSpectrum2.h:9
 TSpectrum2.h:10
 TSpectrum2.h:11
 TSpectrum2.h:12
 TSpectrum2.h:13
 TSpectrum2.h:14
 TSpectrum2.h:15
 TSpectrum2.h:16
 TSpectrum2.h:17
 TSpectrum2.h:18
 TSpectrum2.h:19
 TSpectrum2.h:20
 TSpectrum2.h:21
 TSpectrum2.h:22
 TSpectrum2.h:23
 TSpectrum2.h:24
 TSpectrum2.h:25
 TSpectrum2.h:26
 TSpectrum2.h:27
 TSpectrum2.h:28
 TSpectrum2.h:29
 TSpectrum2.h:30
 TSpectrum2.h:31
 TSpectrum2.h:32
 TSpectrum2.h:33
 TSpectrum2.h:34
 TSpectrum2.h:35
 TSpectrum2.h:36
 TSpectrum2.h:37
 TSpectrum2.h:38
 TSpectrum2.h:39
 TSpectrum2.h:40
 TSpectrum2.h:41
 TSpectrum2.h:42
 TSpectrum2.h:43
 TSpectrum2.h:44
 TSpectrum2.h:45
 TSpectrum2.h:46
 TSpectrum2.h:47
 TSpectrum2.h:48
 TSpectrum2.h:49
 TSpectrum2.h:50
 TSpectrum2.h:51
 TSpectrum2.h:52
 TSpectrum2.h:53
 TSpectrum2.h:54
 TSpectrum2.h:55
 TSpectrum2.h:56
 TSpectrum2.h:57
 TSpectrum2.h:58
 TSpectrum2.h:59
 TSpectrum2.h:60
 TSpectrum2.h:61
 TSpectrum2.h:62
 TSpectrum2.h:63
 TSpectrum2.h:64
 TSpectrum2.h:65
 TSpectrum2.h:66
 TSpectrum2.h:67