Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Minimizer.h
1/*
2 * HalMinimizer.h
3 *
4 * Created on: 30-04-2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HALMINIMIZER_H_
10#define HALMINIMIZER_H_
11#include "FitParam.h"
12
13#include "Array.h"
14#include "MinimizerStepConf.h"
15
16#include "Math/Minimizer.h"
17
18#include <vector>
27/*
28class HalMinimizerParameter : public TObject {
29private:
30 Double_t fMapMin;
31 Double_t fMapMax;
32 Double_t fMin;
33 Double_t fMax;
34 Double_t fStartParam;
35 Int_t fMapSteps;
36 std::vector<Double_t> fValues;
37 TString fParName;
38
39public:
40 HalMinimizerParameter() : fMapMin(0), fMapMax(0), fMin(0), fMax(0), fStartParam(0), fMapSteps(0) {};
41 Double_t GetMapMin() const { return fMapMin; };
42 Double_t GetMapMax() const { return fMapMax; }
43
44 Int_t GetMapSteps() const { return fMapSteps; };
45 Int_t GetNProbes() const { return fValues.size(); };
46 Double_t GetStepSize() const {
47 Double_t n = GetNProbes() - 1;
48 return (fMin - fMax) / n;
49 };
50 Bool_t IsConst() const {
51 if (GetNProbes() < 1) return kTRUE;
52 return kFALSE;
53 }
54 virtual ~HalMinimizerParameter() {};
55};
56*/
57namespace Hal {
58 class Minimizer : public ROOT::Math::Minimizer {
59
60 protected:
61 enum eMinimizeType { kScan, kAnt };
62
63 private:
64 static Minimizer* fgInstance;
65 std::vector<FitParam> fParameters;
66 std::vector<Double_t> fParamsMin; // found minimum
67 std::vector<Int_t> fNonConstMap;
68 std::vector<std::vector<Double_t>> fAllowedValues;
69 std::vector<Int_t> fStateVector;
70 std::vector<Int_t> fStateVectorMin;
71
72 ROOT::Math::IMultiGenFunction* fFunc;
73 eMinimizeType fMinimizeType;
74 Int_t fNCalls;
75 Int_t fFreePars = {0};
76 Bool_t fDiscreteFit;
77 Bool_t fTrace;
78 Double_t fGlobMin;
79 Double_t fNDF;
80 double* fQuantumFits; //[fNo]
81 double* fSmoothFits; //[fNo]
82 double* fErrors; //[fNo]
83 double* fTempParams; //[fNo]
84 void InitFit();
85 void FinishFit();
86 void EstimateErrors();
87 void MinimizeAnt();
88 void MinimizeScan();
89 void MinimizeNelderMead();
90 void ChangeStateVector(std::vector<Int_t>& vec);
91 void SetTempParams();
92 void EstimateError(Int_t par, Double_t& min, Double_t& quantumMin, Double_t& error);
93 Bool_t LoopOverParameter(Int_t param);
94 Bool_t IsFixed(Int_t i) const;
95 Double_t GetChi2();
96 Int_t GetNParams() const { return fParameters.size(); };
97 Int_t GetNFree() const { return fNonConstMap.size(); };
98 Int_t GetNFixed() const { return fParameters.size() - fNonConstMap.size(); };
99
100 public:
101 Minimizer();
102 void SetNDF(Double_t ndf) { fNDF = ndf; }
103 void SetTrace(Bool_t trace) { fTrace = trace; };
107 void UseDiscreteFit() { fDiscreteFit = kTRUE; };
111 void DisableDiscreteFit() { fDiscreteFit = kFALSE; };
116 static Minimizer* Instance();
117 virtual bool SetVariable(unsigned int /* ivar*/, const std::string& /*name*/, double /*val*/, double /*step*/) {
118 return false;
119 };
120
121 virtual bool SetParLimits(unsigned int ivar, double min, double max);
129 virtual bool SetFixedVariable(unsigned int ivar, const std::string& name, double val);
140 virtual bool
141 SetLimitedVariable(unsigned int ivar, const std::string& name, double val, double points, double lower, double upper);
149 virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper);
150 virtual bool Minimize();
151 virtual void Reset();
152 virtual void SetParamConf(const MinimizerStepConf& conf, Bool_t overwrite);
153 virtual double MinValue() const { return 0; };
154 virtual const double* X() const;
155 virtual const double* Errors() const { return fErrors; }
156 virtual double Edm() const { return -1; }
157 virtual const double* MinGradient() const { return NULL; }
158 virtual unsigned int NCalls() const { return 0; };
159 virtual unsigned int NIterations() const { return NCalls(); }
160 virtual unsigned int NDim() const { return fParameters.size(); };
161 void SetFunction(const ROOT::Math::IMultiGenFunction& func);
162 void SetMinimizerType(TString opt);
163 FitParam GetParConf(Int_t idx) const { return fParameters[idx]; }
164 virtual ~Minimizer();
165 ClassDef(Minimizer, 1)
166 };
167} // namespace Hal
168
169#endif /* HALMINIMIZER_H_ */
void DisableDiscreteFit()
Definition Minimizer.h:111
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
Definition Minimizer.cxx:40
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
Definition Minimizer.cxx:48
static Minimizer * Instance()
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double points, double lower, double upper)
Definition Minimizer.cxx:61
void UseDiscreteFit()
Definition Minimizer.h:107