GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitPeakFinder.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4FITPEAKFINDER_H
15 #define TGO4FITPEAKFINDER_H
16 
17 #include "TGo4FitterAction.h"
18 
19 #include "TArrayD.h"
20 
21 class TGo4Fitter;
22 class TGo4FitData;
23 
31  public:
32 
37 
42  TGo4FitPeakFinder(const char *Name, const char *DataName = nullptr, Bool_t ClearModels = kFALSE, Int_t PolOrder = -1);
43 
47  virtual ~TGo4FitPeakFinder();
48 
49  void SetDataName(const char *name) { fxDataName = name; }
50  const char *GetDataName() const { return fxDataName.Data(); }
51  void SetClearModels(Bool_t clear) { fbClearModels = clear; }
52  Bool_t GetClearModels() const { return fbClearModels; }
53 
54 
55  void SetupPolynomialBackground(Int_t PolynomOrder);
56 
57  void SetupForFirst(Double_t MaxAmplFactor, Double_t MinWidth, Double_t MaxWidth);
58 
59  void SetupForSecond(Double_t LineWidth);
60 
61  void SetupForThird(Double_t NoiseFactor, Double_t NoiseMinimum, Int_t ChannelSum);
62 
63  void DoAction(TGo4FitterAbstract *Fitter) override;
64 
65  Bool_t CanChangeFitter() const override { return kTRUE; }
66 
67  // Following functions directly changes single parameters of peakfinders.
68  // Normally you should not use them, because some or all of them can be changed later on
69  // You should use Setup... routines to configure specific peakfinder
70 
71  void SetUsePolynom(Bool_t use) { fbUsePolynom = use; }
72  Bool_t GetUsePolynom() const { return fbUsePolynom; }
73  void SetPolynomOrder(Int_t order) { fiPolynomOrder = order; }
74  Int_t GetPolynomOrder() const { return fiPolynomOrder; }
75 
76  void SetPeakFinderType(Int_t typ) { fiPeakFinderType = typ; }
77  Int_t GetPeakFinderType() const { return fiPeakFinderType; }
78 
79  void Set0MaxAmplFactor(Double_t factor) { fd0MaxAmplFactor = factor; }
80  Double_t Get0MaxAmplFactor() const { return fd0MaxAmplFactor; }
81  void Set0MinWidth(Double_t min) { fd0MinWidth = min; }
82  Double_t Get0MinWidth() const { return fd0MinWidth; }
83  void Set0MaxWidth(Double_t max) { fd0MaxWidth = max; }
84  Double_t Get0MaxWidth() const { return fd0MaxWidth; }
85 
86  void Set1LineWidth(Double_t width) { fd1LineWidth = width; }
87  Double_t Get1LineWidth() const { return fd1LineWidth; }
88 
89  void Set2NoiseFactor(Double_t factor) { fd2NoiseFactor = factor; }
90  Double_t Get2NoiseFactor() const { return fd2NoiseFactor; }
91  void Set2NoiseMinimum(Double_t min) { fd2NoiseMinimum = min; }
92  Double_t Get2NoiseMinimum() const { return fd2NoiseMinimum; }
93  void Set2ChannelSum(Int_t sum) { fi2ChannelSum = sum; }
94  Int_t Get2ChannelSum() const { return fi2ChannelSum; }
95 
99  void Print(Option_t *option = "") const override;
100 
101  private:
102 
103  void ROOTPeakFinder(TGo4Fitter *fitter,
104  TGo4FitData *data,
105  Int_t PolynomOrder,
106  Double_t Sigma);
107 
115  void SergeyLinevPeakFinder(TGo4Fitter *fitter,
116  TGo4FitData *data,
117  Int_t PolOrder,
118  Double_t AmplThreshold,
119  Double_t MinWidth,
120  Double_t MaxWidth);
121 
126  void HansEsselPeakFinder(TGo4Fitter *fitter,
127  TGo4FitData *data,
128  Int_t MaxNumPeaks = 50,
129  Int_t ChannelSum = 1,
130  Double_t NoiseFactor = 2.,
131  Double_t NoiseMinimum = 10.,
132  Int_t MinimasOrder = -1);
133 
134  static void DefinePolynom(Int_t size, // number of experimental points
135  Double_t *bins, // array of bins
136  Double_t *scales, // array of scale values
137  TArrayD &Coef, // array of polynomial coefficients
138  Double_t *weight = nullptr, // statistical weight of each bin
139  Double_t *backgr = nullptr, // background values
140  Char_t *use = nullptr); // usage of each points
141 
142  static void DefinePolynomEx(Int_t size, Double_t *bins, Double_t *scales, Double_t *weight, Double_t *backgr,
143  Int_t lbound, Int_t rbound, TArrayD& Coef);
144 
145  static Double_t CalcPolynom(const TArrayD &Coef, Double_t x);
146 
147 
148  Int_t fiPeakFinderType{0}; // 0 - by S.Linev, 1 - ROOT TSpectrum, 2 - by H.Essel
149 
150  TString fxDataName;
151 
152  Bool_t fbClearModels{kFALSE};
153 
154  Bool_t fbUsePolynom{kFALSE};
155  Int_t fiPolynomOrder{0};
156 
157  Double_t fd0MinWidth{0};
158  Double_t fd0MaxWidth{0};
159  Double_t fd0MaxAmplFactor{0};
160 
161  Double_t fd1LineWidth{0};
162 
163  Double_t fd2NoiseFactor{0};
164  Double_t fd2NoiseMinimum{0};
165  Int_t fi2ChannelSum{0};
166 
167  ClassDefOverride(TGo4FitPeakFinder,1)
168 };
169 
170 #endif // TGO4FITPEAKFINDER_H
Bool_t GetUsePolynom() const
void SetupForSecond(Double_t LineWidth)
void Set2NoiseFactor(Double_t factor)
Double_t Get0MinWidth() const
void Print(Option_t *option="") const override
Bool_t GetClearModels() const
Int_t GetPolynomOrder() const
void SetDataName(const char *name)
void DoAction(TGo4FitterAbstract *Fitter) override
Int_t GetPeakFinderType() const
static void DefinePolynomEx(Int_t size, Double_t *bins, Double_t *scales, Double_t *weight, Double_t *backgr, Int_t lbound, Int_t rbound, TArrayD &Coef)
static void DefinePolynom(Int_t size, Double_t *bins, Double_t *scales, TArrayD &Coef, Double_t *weight=nullptr, Double_t *backgr=nullptr, Char_t *use=nullptr)
Int_t Get2ChannelSum() const
Double_t Get2NoiseMinimum() const
void SergeyLinevPeakFinder(TGo4Fitter *fitter, TGo4FitData *data, Int_t PolOrder, Double_t AmplThreshold, Double_t MinWidth, Double_t MaxWidth)
void Set2NoiseMinimum(Double_t min)
void SetPeakFinderType(Int_t typ)
Double_t Get0MaxWidth() const
Double_t Get1LineWidth() const
void Set0MaxWidth(Double_t max)
void Set0MaxAmplFactor(Double_t factor)
Bool_t CanChangeFitter() const override
void SetupForFirst(Double_t MaxAmplFactor, Double_t MinWidth, Double_t MaxWidth)
void Set2ChannelSum(Int_t sum)
const char * GetDataName() const
void SetupPolynomialBackground(Int_t PolynomOrder)
void SetUsePolynom(Bool_t use)
void SetupForThird(Double_t NoiseFactor, Double_t NoiseMinimum, Int_t ChannelSum)
void Set1LineWidth(Double_t width)
void SetClearModels(Bool_t clear)
static Double_t CalcPolynom(const TArrayD &Coef, Double_t x)
Double_t Get2NoiseFactor() const
void ROOTPeakFinder(TGo4Fitter *fitter, TGo4FitData *data, Int_t PolynomOrder, Double_t Sigma)
Double_t Get0MaxAmplFactor() const
void SetPolynomOrder(Int_t order)
void HansEsselPeakFinder(TGo4Fitter *fitter, TGo4FitData *data, Int_t MaxNumPeaks=50, Int_t ChannelSum=1, Double_t NoiseFactor=2., Double_t NoiseMinimum=10., Int_t MinimasOrder=-1)
void Set0MinWidth(Double_t min)