56 return (value < 0.) ? 0. : 1. / (value + 1.);
58 return (modelvalue <= 0.) ? 0. : 1. / modelvalue;
71 for (Int_t n = 0; n < fitter->
GetNumData(); n++)
79 TObjArray comps, fixedcomps;
84 Bool_t assigned = kFALSE;
96 fixedcomps.Add(fModel);
99 Int_t ncomp = comps.GetLast() + 1;
103 TMatrixD matr(ncomp, ncomp);
104 TVectorD vector(ncomp);
106 Double_t **DopData =
new Double_t *[fitter->
GetNumData()];
107 for (Int_t n = 0; n < fitter->
GetNumData(); n++)
110 Double_t **Weights =
new Double_t *[fitter->
GetNumData()];
111 for (Int_t n = 0; n < fitter->
GetNumData(); n++)
116 Bool_t changed = kFALSE;
122 for (Int_t ndata = 0; ndata < fitter->
GetNumData(); ndata++) {
131 Double_t *weight = Weights[ndata];
133 for (Int_t nbin = 0; nbin < size; nbin++)
134 weight[nbin] =
PointWeight(niter, FFtype, ampl * values[nbin], result[nbin], ampl * ampl * devs[nbin]);
137 for (Int_t n1 = 0; n1 < ncomp; n1++)
138 for (Int_t n2 = n1; n2 < ncomp; n2++) {
140 for (Int_t ndata = 0; ndata < fitter->
GetNumData(); ndata++) {
143 if (bins1 && bins2) {
145 Double_t *weight = Weights[ndata];
146 for (Int_t nbin = 0; nbin < size; nbin++)
147 fSum += bins1[nbin] * bins2[nbin] * weight[nbin];
155 for (Int_t ndata = 0; ndata < fitter->
GetNumData(); ndata++) {
160 Double_t *bins = DopData[ndata];
162 for (Int_t nbin = 0; nbin < size; nbin++)
163 bins[nbin] = dampl * values[nbin];
165 for (Int_t n = 0; n <= fixedcomps.GetLast(); n++) {
170 for (Int_t nbin = 0; nbin < size; nbin++)
171 bins[nbin] -= mampl * mbins[nbin];
178 for (Int_t n = 0; n < ncomp; n++) {
180 for (Int_t ndata = 0; ndata < fitter->
GetNumData(); ndata++) {
185 Double_t *bins = DopData[ndata];
186 Double_t *weight = Weights[ndata];
187 for (Int_t nbin = 0; nbin < size; nbin++)
188 fSum += bins[nbin] * bins1[nbin] * weight[nbin];
193 if (matr.Determinant() == 0.) {
194 std::cerr <<
" Amplitude estimation algorithm failed. " << std::endl;
196 <<
" Determinant of matrix == 0.; This may be due to equivalent model components or zero model at all"
204 for (Int_t n = 0; n < ncomp; n++) {
219 for (Int_t n = 0; n < fitter->
GetNumData(); n++)
223 for (Int_t n = 0; n < fitter->
GetNumData(); n++)
239 fixedindex.Reset(-1);
244 for (Int_t n = 0; n < nmodel; n++) {
246 Bool_t assigned = kFALSE;
256 refindex[ncomp++] = n;
258 fixedindex[nfixed++] = n;
264 TMatrixD matr(ncomp, ncomp);
265 TVectorD vector(ncomp);
267 TArrayC Usage(nmodel);
268 TArrayD ModelValues(nmodel);
269 TArrayD ModelAmpls(nmodel);
273 Bool_t changed = kFALSE;
279 for (Int_t ndata = 0; ndata < fitter->
GetNumData(); ndata++) {
289 ModelAmpls.Reset(0.);
290 ModelValues.Reset(0.);
291 for (Int_t n = 0; n < nmodel; n++) {
301 Double_t result = 0.;
302 for (Int_t n = 0; n < nmodel; n++)
305 result += ModelAmpls[n] * ModelValues[n];
308 PointWeight(niter, FFtype, dampl * iter->Value(), result, dampl * dampl * iter->StandardDeviation());
312 for (Int_t i1 = 0; i1 < ncomp; i1++)
313 for (Int_t i2 = i1; i2 < ncomp; i2++) {
314 Double_t zn = matr(i1, i2);
315 zn += ModelValues[refindex[i1]] * ModelValues[refindex[i2]] * weight;
321 Double_t dvalue = dampl * iter->Value();
322 for (Int_t nf = 0; nf < nfixed; nf++)
323 dvalue -= ModelAmpls[fixedindex[nf]] * ModelValues[fixedindex[nf]];
325 for (Int_t i1 = 0; i1 < ncomp; i1++) {
326 Double_t zn = vector(i1);
327 zn += ModelValues[refindex[i1]] * dvalue * weight;
331 }
while (iter->Next());
333 for (Int_t n = 0; n < nmodel; n++)
339 if (matr.Determinant() == 0.) {
340 std::cerr <<
" Amplitude estimation algorithm failed. " << std::endl;
342 <<
" Determinant of matrix == 0.; This may be due to equivalent model components or zero model at all"
350 for (Int_t n = 0; n < ncomp; n++) {
371 std::cout <<
" number of iterations " <<
fiNumIters << std::endl;
Bool_t CalculateWithBuffers(TGo4Fitter *fitter)
virtual ~TGo4FitAmplEstimation()
Destroys TGo4FitAmplEstimation object.
Bool_t CalculateWithIterators(TGo4Fitter *fitter)
Double_t PointWeight(Int_t niter, Int_t FFtype, Double_t value, Double_t modelvalue, Double_t standdev)
TGo4FitAmplEstimation()
Default constructor.
void DoAction(TGo4FitterAbstract *Fitter) override
Perform amplitude estimations.
void Print(Option_t *option="") const override
Print information on standard output.
Int_t fiNumIters
Number of iterations, used for amplitude estimation.
TGo4FitParameter * GetAmplPar()
Return amplitude parameter object.
void SetAmplError(Double_t iError)
Set error of amplitude parameter.
Double_t GetAmplValue()
Return value of amplitude parameter.
void SetAmplValue(Double_t iAmpl)
Set value of amplitude parameter.
Basic abstract class for representing data, which should be fitted.
virtual std::unique_ptr< TGo4FitDataIter > MakeIter()
Creates iterator for data object.
Basic abstract class for representing model components of fitted data.
const char * AssignmentName(Int_t n)
Returns name of data, to which model object is assigned.
virtual Bool_t BeforeEval(Int_t ndim)
Prepares (if necessary) some intermediate variables to be able calculate values of model via EvalN() ...
Bool_t IsAssignTo(const char *DataName) const
Checks, if model assigned to given data.
virtual Double_t EvaluateAtPoint(TGo4FitData *data, Int_t nbin, Bool_t UseRanges=kTRUE)
Evaluate model value for specified data point.
virtual void AfterEval()
Clear buffers, which were created by BeforeEval() method.
Double_t GetRatioValueFor(const char *DataName)
Returns ratio value for specified data object.
Int_t NumAssigments() const
Returns number of assignment for this model.
void Print(Option_t *option="") const override
Bool_t GetFixed() const
Return status, if parameter fixed or not.
Bool_t IsInitialized() const
Return kTRUE, if Initialize() was done.
TGo4FitterAction()
Default constructor.
Central class of Go4Fit package.
Bool_t ModelBuffersAllocated(TGo4FitModel *model)
Bool_t DataBuffersAllocated(TGo4FitData *data)
Double_t * GetDataBinsResult(TGo4FitData *data) const
TGo4FitModel * GetModel(Int_t n)
Return model component with given index.
const char * GetDataName(Int_t n)
Return name of data object with given index.
Double_t * GetModelBinsValues(TGo4FitModel *model, const char *DataName) const
Int_t GetNumModel() const
Return number of model component in fitter.
Int_t GetDataBinsSize(TGo4FitData *data) const
void RebuildAll(Bool_t ForceBuild=kFALSE)
Update all data objects and model components according to current parameters values.
TGo4FitData * GetData(Int_t n)
Return data object with given index.
TGo4FitData * FindData(const char *DataName)
Return data object with given name.
Int_t GetNumData() const
Return number of data objects in fitter.
Double_t * GetDataBinsDevs(TGo4FitData *data) const
Double_t * GetDataBinsValues(TGo4FitData *data) const
Int_t GetFitFunctionType() const
Return type of fitted function.