GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Fitter.cxx
Go to the documentation of this file.
1 // $Id: TGo4Fitter.cxx 1526 2015-06-11 11:48:59Z linev $
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 für 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 #include "TGo4Fitter.h"
15 
16 #include <stdlib.h>
17 
18 #include "Riostream.h"
19 #include "TClass.h"
20 #include "TMath.h"
21 #include "TH1.h"
22 #include "TGraph.h"
23 #include "TCanvas.h"
24 #include "TObjArray.h"
25 #include "TObjString.h"
26 #include "TROOT.h"
27 #include "THStack.h"
28 #include "TArrayD.h"
29 
30 #include "TGo4FitData.h"
31 #include "TGo4FitDataHistogram.h"
32 #include "TGo4FitDataGraph.h"
33 #include "TGo4FitModel.h"
34 #include "TGo4FitModelGauss1.h"
35 #include "TGo4FitModelGauss2.h"
36 #include "TGo4FitModelPolynom.h"
37 #include "TGo4FitAmplEstimation.h"
38 #include "TGo4FitSlot.h"
39 #include "TGo4FitMinuit.h"
40 
43  fxDatas(), fxModels(), fiFitFunctionType(0), fiMemoryUsage(0),
44  fxUserFitFunction(0), fxDrawObjs(0)
45 {
46 }
47 
48 TGo4Fitter::TGo4Fitter(const char* iName, const char* iTitle) :
49  TGo4FitterAbstract(iName, iTitle),
50  fxDatas(), fxModels(), fiFitFunctionType(0), fiMemoryUsage(0), fxUserFitFunction(0), fxDrawObjs(0)
51 {
52  fxDatas.SetOwner(kTRUE);
53  fxModels.SetOwner(kTRUE);
54 }
55 
56 TGo4Fitter::TGo4Fitter(const char* iName, Int_t iFitFunctionType, Bool_t IsAddStandardActions) :
57  TGo4FitterAbstract(iName,"TGo4Fitter object"),
58  fxDatas(), fxModels(), fiFitFunctionType(0), fiMemoryUsage(100), fxUserFitFunction(0), fxDrawObjs(0)
59 {
60  fxDatas.SetOwner(kTRUE);
61  fxModels.SetOwner(kTRUE);
62  SetFitFunctionType(iFitFunctionType);
63  if (IsAddStandardActions) AddStandardActions();
64 }
65 
67 {
70 }
71 
72 void TGo4Fitter::SetMemoryUsage(Int_t iMemoryUsage)
73 {
74  if (iMemoryUsage<0) fiMemoryUsage=0; else
75  if (iMemoryUsage>100) fiMemoryUsage=100; else
76  fiMemoryUsage = iMemoryUsage;
77 }
78 
80 {
82 
83  for(Int_t ndata=0;ndata<GetNumData();ndata++)
84  GetData(ndata)->CollectParsTo(*this);
85 
86  for(Int_t nmodel=0;nmodel<GetNumModel();nmodel++) {
87  TGo4FitModel* model = GetModel(nmodel);
88  for (Int_t n=0;n<model->NumAssigments();n++)
89  if (FindData(model->AssignmentName(n))) {
90  model->CollectParsTo(*this);
91  break;
92  }
93  }
94 }
95 
96 void TGo4Fitter::Clear(Option_t* option)
97 {
99  DeleteAllData();
100  DeleteAllModels();
101 }
102 
104 {
105  return (n>=0) && (n<GetNumData()) ? dynamic_cast<TGo4FitData*> (fxDatas[n]) : 0;
106 }
107 
108 const char* TGo4Fitter::GetDataName(Int_t n)
109 {
110  return GetData(n) ? GetData(n)->GetName() : 0;
111 }
112 
113 TGo4FitData* TGo4Fitter::FindData(const char* DataName)
114 {
115  return (DataName==0) ? 0 : dynamic_cast<TGo4FitData*> (fxDatas.FindObject(DataName));
116 }
117 
119 {
120  fxDatas.Add(data);
123  return data;
124 }
125 
126 TGo4FitDataHistogram* TGo4Fitter::AddH1(const char* DataName, TH1* histo, Bool_t Owned, Double_t lrange, Double_t rrange)
127 {
128  TGo4FitDataHistogram *data = new TGo4FitDataHistogram(DataName, histo, Owned);
129  if ((lrange<rrange) || (rrange!=0.)) data->SetRange(0,lrange,rrange);
130  AddData(data);
131  return data;
132 }
133 
134 TGo4FitDataHistogram* TGo4Fitter::SetH1(const char* DataName, TH1* histo, Bool_t Owned)
135 {
136  TGo4FitDataHistogram* data = dynamic_cast<TGo4FitDataHistogram*> (FindData(DataName));
137  if (data!=0) data->SetHistogram(histo, Owned);
138  return data;
139 }
140 
141 
142 TGo4FitDataGraph* TGo4Fitter::AddGraph(const char* DataName, TGraph* gr, Bool_t Owned, Double_t lrange, Double_t rrange)
143 {
144  TGo4FitDataGraph *data = new TGo4FitDataGraph(DataName, gr, Owned);
145  if ((lrange<rrange) || (rrange!=0.)) data->SetRange(0,lrange,rrange);
146  AddData(data);
147  return data;
148 }
149 
150 TGo4FitDataGraph* TGo4Fitter::SetGraph(const char* DataName, TGraph* gr, Bool_t Owned)
151 {
152  TGo4FitDataGraph *data = dynamic_cast<TGo4FitDataGraph*> (FindData(DataName));
153  if (data!=0) data->SetGraph(gr, Owned);
154  return data;
155 }
156 
158 {
159  if (comp)
160  for (Int_t n=0;n<comp->NumSlots();n++) {
161  TGo4FitSlot* slot = comp->GetSlot(n);
162  ClearSlot(slot, kFALSE);
163  for(Int_t n2=0;n2<NumSlots();n2++) {
164  TGo4FitSlot* slot2 = GetSlot(n2);
165  if (slot2->GetConnectedSlot()==slot)
166  slot2->ClearConnectionToSlot();
167  }
168 
169  }
170 }
171 
172 TGo4FitData* TGo4Fitter::RemoveData(const char* DataName, Bool_t IsDel)
173 {
174  TGo4FitData* dat = FindData(DataName);
175  if (dat) {
178  fxDatas.Remove(dat);
179  if(IsDel) { CheckSlotsBeforeDelete(dat); delete dat; dat = 0; }
180  fxDatas.Compress();
181  }
182  return dat;
183 }
184 
186 {
187  fxDatas.Delete();
188  fxDatas.Compress();
191 }
192 
194 {
195  return (n>=0) && (n<GetNumModel()) ? dynamic_cast<TGo4FitModel*> (fxModels[n]) : 0;
196 }
197 
198 TGo4FitModel* TGo4Fitter::FindModel(const char* ModelName)
199 {
200  return (ModelName==0) ? 0 : dynamic_cast<TGo4FitModel*> (fxModels.FindObject(ModelName));
201 }
202 
204 {
205  fxModels.Add(model);
208  return model;
209 }
210 
211 TGo4FitModel* TGo4Fitter::AddModel(const char* DataName, TGo4FitModel* model)
212 {
213  model->AssignToData(DataName);
214  fxModels.Add(model);
217  return model;
218 }
219 
221 {
222  if(n<GetNumData()) return GetData(n); else return GetModel(n-GetNumData());
223 }
224 
225 void TGo4Fitter::AddPolynomX(const char* DataName, const char* NamePrefix, Int_t MaxOrder, Int_t GroupIndex, Double_t lrange, Double_t rrange)
226 {
227  if (DataName==0) return;
228 
229  Bool_t flag = kFALSE;
230  Int_t NumTry = 0;
231  Bool_t createmodel = kFALSE;
232 
233  do {
234  TString Prefix(NamePrefix);
235  if (NumTry>0) Prefix+=NumTry;
236  flag = kFALSE;
237  Bool_t findsame = kFALSE;
238 
239  for(Int_t Order=0; Order<=MaxOrder; Order++) {
240  TString Name(Prefix);
241  Name += "_";
242  Name += Order;
243  findsame = FindModel(Name.Data());
244  if (findsame && !createmodel) break;
245 
246  if (createmodel) {
247  TGo4FitModelPolynom* comp = new TGo4FitModelPolynom(Name, Order);
248  comp->SetGroupIndex(GroupIndex);
249  if ((lrange<rrange) || (rrange!=0.)) comp->SetRange(0,lrange,rrange);
250  AddModel(DataName, comp);
251  }
252  }
253 
254  flag = kTRUE;
255  if (findsame) { NumTry++; createmodel = kFALSE; } else
256  if (createmodel) flag = kFALSE;
257  else createmodel = kTRUE;
258 
259  } while (flag);
260 }
261 
262 void TGo4Fitter::AddPolynomX(const char* DataName, const char* NamePrefix, TArrayD& Coef, Int_t GroupIndex)
263 {
264  if (DataName==0) return;
265 
266  Bool_t flag = kFALSE;
267  Int_t NumTry = 0;
268  Bool_t createmodel = kFALSE;
269 
270  do {
271  Bool_t findsame = kFALSE;
272 
273  for (Int_t n=0;n<Coef.GetSize();n++) {
274  TString Name(NamePrefix);
275  if (NumTry>0) Name+=NumTry;
276  Name+="_";
277  Name+=n;
278  findsame = FindModel(Name.Data());
279  if (findsame && !createmodel) break;
280 
281  if (createmodel) {
282  TGo4FitModelPolynom* model = new TGo4FitModelPolynom(Name, n);
283  model->SetAmplValue(Coef[n]);
284  model->SetGroupIndex(GroupIndex);
285  AddModel(DataName, model);
286  }
287  }
288 
289  flag = kTRUE;
290  if (findsame) { NumTry++; createmodel = kFALSE; } else
291  if (createmodel) flag = kFALSE;
292  else createmodel = kTRUE;
293 
294  } while(flag);
295 }
296 
297 void TGo4Fitter::AddPolynoms(const char* DataName, const char* NamePrefix, Int_t MaxOrder, Int_t NumAxis, Int_t GroupIndex)
298 {
299  if (DataName==0) return;
300  TArrayD Orders(NumAxis);
301  Orders.Reset(0.);
302 
303  Bool_t flag = kFALSE;
304  Int_t NumTry = 0;
305  Bool_t createmodel = kFALSE;
306 
307  do {
308 
309  TString Prefix(NamePrefix);
310  if (NumTry>0) Prefix+=NumTry;
311  flag = kFALSE;
312  Bool_t findsame = kFALSE;
313 
314  do {
315  TString Name(Prefix);
316  for(Int_t n=0; n<NumAxis; n++) {
317  Name+="_";
318  Name+=Int_t(Orders[n]);
319  }
320  findsame = FindModel(Name.Data());
321  if (findsame && !createmodel) break;
322 
323  if (createmodel) {
324  TGo4FitModelPolynom* comp = new TGo4FitModelPolynom(Name, Orders);
325  comp->SetGroupIndex(GroupIndex);
326  AddModel(DataName, comp);
327  }
328 
329  Int_t nn = 0;
330  do {
331  Orders[nn] += 1.;
332  if (Orders[nn]<=MaxOrder) break;
333  Orders[nn]=0;
334  nn++;
335  } while (nn<NumAxis);
336  flag = (nn<NumAxis);
337  } while (flag);
338 
339  flag = kTRUE;
340  if (findsame) { NumTry++; createmodel = kFALSE; } else
341  if (createmodel) flag = kFALSE;
342  else createmodel = kTRUE;
343 
344  } while (flag);
345 }
346 
347 TGo4FitModelGauss1* TGo4Fitter::AddGauss1(const char* DataName, const char* ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl, Int_t Axis)
348 {
349  TGo4FitModelGauss1* gauss = new TGo4FitModelGauss1(ModelName, iPosition, iWidth, Axis);
350  gauss->SetAmplValue(iAmpl);
351  AddModel(DataName, gauss);
352  return gauss;
353 }
354 
355 TGo4FitModel* TGo4Fitter::CloneModel(const char* ModelName, const char* NewName)
356 {
357  TGo4FitModel* mod = FindModel(ModelName);
358  if (mod==0) return 0;
359 
360  TString newname;
361  int cnt = 0;
362 
363  do {
364  newname = NewName ? NewName : mod->GetName();
365  if (cnt>0) {
366  newname += "_";
367  newname += cnt;
368  }
369  cnt++;
370  } while (FindModel(newname.Data()));
371 
372  TGo4FitModel* newmod = (TGo4FitModel*) mod->Clone(newname.Data());
373 
374  return AddModel(newmod);
375 }
376 
377 TGo4FitModel* TGo4Fitter::RemoveModel(const char * ModelName, Bool_t IsDel)
378 {
379  TGo4FitModel* mod = FindModel(ModelName);
380  if (mod) {
383  fxModels.Remove(mod);
384  if(IsDel) { CheckSlotsBeforeDelete(mod); delete mod; mod = 0; }
385  fxModels.Compress();
386  }
387  return mod;
388 }
389 
390 Int_t TGo4Fitter::NumModelsAssosiatedTo(const char* DataName)
391 {
392  Int_t res = 0;
393  for (Int_t n=0;n<GetNumModel();n++)
394  if (GetModel(n)->IsAssignTo(DataName)) res++;
395  return res;
396 }
397 
398 void TGo4Fitter::DeleteModelsAssosiatedTo(const char* DataName)
399 {
400  Int_t n=0;
401  while (n<GetNumModel()) {
402  TGo4FitModel* model = GetModel(n++);
403  if (model->IsAssignTo(DataName)){
404  if (model->NumAssigments()==1) {
407  fxModels.Remove(model);
408  delete model;
409  fxModels.Compress();
410  n--;
411  } else model->ClearAssignmentTo(DataName);
412  }
413  }
414 }
415 
417 {
418  fxModels.Delete();
419  fxModels.Compress();
422 }
423 
424 void TGo4Fitter::AssignModelTo(const char* ModelName, const char* DataName, Double_t RatioValue, Bool_t FixRatio)
425 {
426  TGo4FitModel* model = FindModel(ModelName);
427  if (model) {
428  if (DataName!=0)
429  model->AssignToData(DataName, RatioValue, FixRatio);
430  else {
431  model->ClearAssignments();
432  for (int n=0; n<GetNumData(); n++)
433  model->AssignToData(GetData(n)->GetName(), RatioValue, FixRatio);
434  }
436  }
437 }
438 
439 void TGo4Fitter::ClearModelAssignmentTo(const char* ModelName, const char* DataName)
440 {
441  TGo4FitModel* model = FindModel(ModelName);
442  if (model==0) return;
443  if (DataName!=0) model->ClearAssignmentTo(DataName);
444  else model->ClearAssignments();
446 }
447 
448 void TGo4Fitter::ChangeDataNameInAssignments(const char* oldname, const char* newname)
449 {
450  for(Int_t n=0;n<GetNumModel();n++)
451  GetModel(n)->ChangeDataNameInAssignments(oldname,newname);
452 }
453 
455 {
456  Int_t dbuf = -1, mbuf = -1;
457  switch (GetMemoryUsage()) {
458  case 0: dbuf = 0; mbuf = 0; break;
459  case 1: dbuf = 1; mbuf = 0; break;
460  case 2: dbuf = 1; mbuf = 1; break;
461  default: dbuf = -1; mbuf = -1;
462  }
463 
464  for(Int_t i1=0;i1<GetNumData();i1++) {
465  TGo4FitData *data = GetData(i1);
466  if (!data->Initialize(dbuf)) return kFALSE;
467  for(Int_t i2=0;i2<GetNumModel();i2++)
469  }
470 
471  for(Int_t i2=0;i2<GetNumModel();i2++) {
472  TGo4FitModel *fModel = GetModel(i2);
473  if (!fModel->Initialize(mbuf)) return kFALSE;
474  }
475 
476  if( (fiFitFunctionType == ff_user) && (fxUserFitFunction==0) ) {
477  std::cout << " User fit function not set. Switch to least squares " << std::endl;
479  }
480 
481  return kTRUE;
482 }
483 
485 {
486  for(Int_t i=0;i<GetNumData();i++) GetData(i)->Finalize();
487 
488  for(Int_t i=0;i<GetNumModel();i++) GetModel(i)->Finalize();
489 }
490 
491 Double_t TGo4Fitter::PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev)
492 {
493  switch (FitFunctionType) {
494  case ff_least_squares: {
495  Double_t zn1 = (value-modelvalue);
496  return zn1*zn1; }
497  case ff_chi_square: {
498  if (standdev<=0.) return 0.;
499  Double_t zn2 = (value-modelvalue);
500  return zn2*zn2/standdev; }
501  case ff_chi_Pearson: {
502  if (modelvalue<=0.) return 0.;
503  Double_t zn3 = (value-modelvalue);
504  return zn3*zn3/modelvalue; }
505  case ff_chi_Neyman: {
506  Double_t zn4 = (value-modelvalue);
507  return zn4*zn4/((value<1.) ? 1. : value); }
508  case ff_chi_gamma: {
509  if (value<0.) return 0.;
510  Double_t zn5 = (value+((value<1.) ? 0. : 1.)-modelvalue);
511  return zn5*zn5/(value+1.); }
512  case ff_ML_Poisson:
513  if (modelvalue<=0.) return 0.;
514  return modelvalue - value*TMath::Log(modelvalue);
515  case ff_user:
516  if (fxUserFitFunction==0) return 0;
517  return fxUserFitFunction(value, modelvalue, standdev);
518  default:
519  return (value-modelvalue)*(value-modelvalue);
520  }
521 }
522 
523 Double_t TGo4Fitter::CalculateFCN(Int_t FitFunctionType, TGo4FitData* selectdata)
524 {
525  if (GetMemoryUsage()>0) RebuildAll();
526 
527  Double_t fSum = 0.;
528 
529  for(Int_t n=0;n<GetNumData();n++) {
530  TGo4FitData* dat = GetData(n);
531  if (selectdata && (dat!=selectdata)) continue;
532  Double_t DataAmpl = dat->GetAmplValue();
533 
534  if (dat->BuffersAllocated()) {
535  Int_t size = dat->GetBinsSize();
536  Double_t* values = dat->GetBinsValues();
537  Double_t* res = dat->GetBinsResult();
538  Double_t* devs = dat->GetBinsDevs();
539 
540  for(Int_t nbin=0;nbin<size;nbin++)
541  fSum += PointFitFunction(FitFunctionType, DataAmpl*values[nbin], res[nbin], DataAmpl*DataAmpl*devs[nbin] );
542  } else {
543 
544  TGo4FitDataIter* iter = dat->MakeIter();
545  if (!iter->Reset()) { delete iter; continue; }
546 
547  TObjArray Models;
548 
549  TArrayD Ampls(GetNumModel());
550  for(Int_t nm=0;nm<GetNumModel();nm++)
551  if (GetModel(nm)->IsAssignTo(dat->GetName())) {
552  TGo4FitModel* model = GetModel(nm);
553  Models.Add(model);
554  model->BeforeEval(iter->ScalesSize());
555  Ampls[Models.GetLast()] = model->GetAmplValue() * model->GetRatioValueFor(dat->GetName());
556  }
557 
558  do {
559  Double_t value = DataAmpl * iter->Value();
560  Double_t deviat = DataAmpl * DataAmpl * iter->StandardDeviation();
561 
562  Double_t modelvalue = 0.;
563  for(Int_t nm=0;nm<=Models.GetLast();nm++) {
564  TGo4FitModel* model = dynamic_cast<TGo4FitModel*> (Models.At(nm));
565  modelvalue += Ampls[nm] * model->EvaluateAtPoint(iter);
566  }
567 
568  fSum += PointFitFunction(FitFunctionType, value, modelvalue, deviat);
569 
570  } while (iter->Next());
571 
572  for(Int_t nm=0;nm<=Models.GetLast();nm++)
573  ((TGo4FitModel*) Models.At(nm))->AfterEval();
574 
575  delete iter;
576  }
577  }
578 
579  return fSum;
580 }
581 
582 Double_t TGo4Fitter::CalculateFitFunction(Double_t* pars, Int_t FitFunctionType, const char* DataName)
583 {
584 
585  if (FitFunctionType<0) FitFunctionType = GetFitFunctionType();
586 
587  if (pars) {
588  ExecuteDependencies(pars);
589  SetParsValues(pars);
590  }
591 
592  return CalculateFCN(FitFunctionType, FindData(DataName));
593 }
594 
595 Int_t TGo4Fitter::CalculateNDF(const char* DataName)
596 {
597  TGo4FitData* selectdata = FindData(DataName);
598 
599  Int_t NDF = 0;
600 
601  if (selectdata!=0) {
602  NDF = selectdata->DefineBinsSize();
603  for(Int_t nm=0;nm<GetNumModel();nm++) {
604  TGo4FitModel* model = GetModel(nm);
605  if (model->IsAssignTo(selectdata->GetName()))
606  NDF -= model->NumFreePars();
607  }
608  } else {
609  for (Int_t n=0;n<GetNumData();n++)
610  NDF += GetData(n)->DefineBinsSize();
611  NDF -= NumFreePars();
612  }
613 
614  return NDF;
615 }
616 
618 {
620 }
621 
623 {
624  return CalculateNDF(0);
625 }
626 
627 void TGo4Fitter::RebuildAll(Bool_t ForceBuild)
628 {
629  for(Int_t i2=0;i2<GetNumModel();i2++)
630  GetModel(i2)->RebuildShape(ForceBuild);
631 
632  for(Int_t i1=0;i1<GetNumData();i1++) {
633  TGo4FitData* data = GetData(i1);
634  if (!data->BuffersAllocated()) continue;
635 
636  Int_t size = data->GetBinsSize();
637  Double_t* result = data->GetBinsResult();
638  for (Int_t nbin=0;nbin<size;nbin++) result[nbin] = 0.;
639 
640  for(Int_t i2=0;i2<GetNumModel();i2++) {
641  TGo4FitModel *model = GetModel(i2);
642  if (model->IsAssignTo(data->GetName()))
643  model->AddModelToDataResult(data);
644  }
645  }
646 }
647 
648 void TGo4Fitter::EstimateAmplitudes(Int_t NumIters)
649 {
650  TGo4FitAmplEstimation abc("this",NumIters);
651  abc.DoAction(this);
652 }
653 
654 void TGo4Fitter::AddAmplEstimation(Int_t NumIters)
655 {
656  AddAction(new TGo4FitAmplEstimation("AmplEstim",NumIters));
657 }
658 
660 {
662  AddSimpleMinuit();
663 }
664 
665 void TGo4Fitter::FillSlotList(TSeqCollection* list)
666 {
668  for(Int_t i=0;i<GetNumComp();i++)
669  GetComp(i)->FillSlotList(list);
670 }
671 
673 {
674  return model==0 ? kFALSE : model->BuffersAllocated();
675 }
676 
678 {
679  return data==0 ? kFALSE : data->BuffersAllocated();
680 }
681 
683 {
684  return (data==0) ? 0 : data->GetBinsSize();
685 }
686 
688 {
689  return (data==0) ? 0 : data->GetBinsValues();
690 }
691 
693 {
694  return (data==0) ? 0 : data->GetBinsDevs();
695 }
696 
698 {
699  return (data==0) ? 0 : data->GetBinsResult();
700 }
701 
702 Double_t* TGo4Fitter::GetModelBinsValues(TGo4FitModel* model, const char* DataName)
703 {
704  return (model==0) ? 0 : model->GetModelBins(DataName);
705 }
706 
707 void TGo4Fitter::Print(Option_t* option) const
708 {
709  TString Opt(option);
710  if (Opt=="Ampls") { PrintAmpls(); return; } else
711  if (Opt=="Pars") { PrintPars(); return; } else
712  if (Opt=="Results") { PrintResults(); return; } else
713  if (Opt=="Lines") { PrintLines(); return; }
714 
716  std::cout << "Fitiing function type: ";
717  switch (fiFitFunctionType) {
718  case ff_chi_square : std::cout << "ff_chi_square" << std::endl; break;
719  case ff_chi_Pearson : std::cout << "ff_chi_Pearson" << std::endl; break;
720  case ff_chi_Neyman : std::cout << "ff_chi_Neyman" << std::endl; break;
721  case ff_chi_gamma : std::cout << "ff_chi_gamma" << std::endl; break;
722  case ff_ML_Poisson : std::cout << "ff_ML_Poisson" << std::endl; break;
723  case ff_user : std::cout << "user defined" << std::endl; break;
724  default: std::cout << "ff_least_squares" << std::endl;
725  }
726  std::cout << std::endl << " LIST OF DATA OBJECTS" << std::endl;
727  fxDatas.Print(option);
728  std::cout << std::endl << " LIST OF MODEL OBJECTS" << std::endl;
729  fxModels.Print(option);
730 }
731 
732 Bool_t TGo4Fitter::CalculatesMomentums(const char* DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t& first, Double_t& second)
733 {
734  TGo4FitData* data = FindData(DataName);
735  if (data==0) return kFALSE;
736 
737  TGo4FitDataIter* iter = data->MakeIter();
738  if (iter==0) return kFALSE;
739 
740  Int_t size = iter->CountPoints(UseRanges);
741  if (size==0) { delete iter; return kFALSE; }
742 
743  TObjArray Models;
744  if (SubstractModels)
745  for(Int_t nm=0; nm<GetNumModel(); nm++)
746  if (GetModel(nm)->IsAssignTo(DataName))
747  Models.Add(GetModel(nm));
748 
749  TArrayD Ampls(Models.GetLast()+1);
750  for(Int_t n=0;n<=Models.GetLast();n++) {
751  TGo4FitModel* model = (TGo4FitModel*) Models[n];
752  model->BeforeEval(iter->ScalesSize());
753  Ampls[n] = model->GetAmplValue() * model->GetRatioValueFor(DataName);
754  }
755 
756  TArrayD bins(size), scales(size);
757 
758  Int_t pnt=0;
759 
760  if (iter->Reset(UseRanges)) do {
761  Double_t value = iter->Value();
762  for(Int_t n=0;n<=Models.GetLast();n++) {
763  TGo4FitModel* model = (TGo4FitModel*) Models[n];
764  value -= Ampls[n] * model->EvaluateAtPoint(iter);
765  }
766  value = TMath::Abs(value);
767  bins[pnt] = value;
768  scales[pnt] = iter->x();
769  pnt++;
770  } while (iter->Next(UseRanges));
771 
772  delete iter;
773 
774  for(Int_t n=0;n<=Models.GetLast();n++) {
775  TGo4FitModel* model = (TGo4FitModel*) Models[n];
776  model->AfterEval();
777  }
778 
779  Int_t niter=0;
780 
781  do {
782  Double_t sum00=0.;
783  Double_t sum11=0.;
784  Double_t sum22=0.;
785  for (Int_t pnt=0;pnt<size;pnt++)
786  if ((bins[pnt]>0.) && ((niter==0) || (TMath::Abs(scales[pnt]-first)<second*2.))) {
787  sum00 += bins[pnt];
788  sum11 += bins[pnt]*scales[pnt];
789  sum22 += bins[pnt]*scales[pnt]*scales[pnt];
790  }
791 
792  if (sum00>0.) {
793  Double_t mid = sum11/sum00;
794  Double_t dev = TMath::Sqrt(sum22/sum00-mid*mid);
795 
796  if (niter>0)
797  if ((dev/second>0.8) && (dev/second<1.2)) niter=10;
798 
799  first = mid; second = dev;
800 
801  } else niter=10;
802 
803  } while (niter++<8);
804 
805  return kTRUE;
806 }
807 
808 Double_t TGo4Fitter::CalculatesIntegral(const char* DataName, const char* ModelName, Bool_t onlycounts)
809 {
810  TGo4FitData* data = FindData(DataName);
811  if (data==0) return 0.;
812 
813  TGo4FitModel* model = ModelName!=0 ? FindModel(ModelName) : 0;
814  if ((ModelName!=0) && (model==0)) return 0.;
815 
816  TGo4FitDataIter* iter = data->MakeIter();
817  if (iter==0) return 0.;
818 
819  double sum = 0.;
820  double ampl = 1.;
821 
822  if (!iter->Reset(kTRUE)) {
823  delete iter;
824  return 0.;
825  }
826 
827  if (model!=0) {
828  model->BeforeEval(iter->ScalesSize());
829  ampl = model->GetAmplValue() * model->GetRatioValueFor(DataName);
830  }
831 
832  do {
833  double dx = onlycounts ? 1. : iter->xWidths();
834  double value = model==0 ? iter->Value() : model->EvaluateAtPoint(iter);
835  sum += ampl*value*dx;
836  } while (iter->Next(kTRUE));
837 
838  if (model!=0)
839  model->AfterEval();
840 
841  delete iter;
842 
843  return sum;
844 }
845 
846 Double_t TGo4Fitter::CalculatesModelIntegral(const char* ModelName, Bool_t OnlyCounts)
847 {
848  TGo4FitModel* model = FindModel(ModelName);
849  if (model==0) return 0.;
850  return CalculatesIntegral(model->AssignmentName(0), ModelName, OnlyCounts);
851 }
852 
853 TObject* TGo4Fitter::CreateDrawObject(const char* ResName, const char* DataName, Bool_t IsModel, const char* ModelName)
854 {
855  TGo4FitData* data = FindData(DataName);
856  if (data==0) return 0;
857 
858  TObjArray Models;
859  if (IsModel) {
860  TGo4FitModel* model = FindModel(ModelName);
861  if (model) Models.Add(model); else {
862  Int_t groupindex = -1;
863 
864  if (ModelName!=0) {
865  TString modelname(ModelName);
866  if (modelname=="Background") groupindex = 0; else
867  if (modelname.Index("Group",0,TString::kExact)==0) {
868  modelname.Remove(0,5);
869  char* err = 0;
870  groupindex = strtol(modelname.Data(),&err,10);
871  if (err && (*err!=0)) groupindex=-1;
872  }
873  }
874 
875  for(Int_t nm=0; nm<GetNumModel(); nm++) {
876  TGo4FitModel* model = GetModel(nm);
877  if (model->IsAssignTo(DataName))
878  if ((groupindex<0) || (model->GetGroupIndex()==groupindex))
879  Models.Add(model);
880  }
881  }
882  if (Models.GetLast()<0) return 0;
883  }
884 
885  TGo4FitDataIter* iter = data->MakeIter();
886  if (iter==0) return 0;
887 
888  if (!iter->Reset(kFALSE)) { delete iter; return 0; }
889 
890  TH1* histo = 0;
891  Int_t ndim = 0;
892  TGraph* gr = 0;
893  Bool_t UseRanges = kTRUE;
894 
895  if (iter->HasIndexes() && (iter->IndexesSize()==iter->ScalesSize()) && iter->HasWidths()) {
896  histo = iter->CreateHistogram(ResName, kFALSE, !IsModel);
897 
898  if (histo) {
899  ndim = histo->GetDimension();
900  UseRanges = Models.GetLast() >= 0;
901  }
902  } else {
903  gr = iter->CreateGraph(ResName, kTRUE, !IsModel);
904  UseRanges = kTRUE;
905  }
906 
907  if (((histo!=0) || (gr!=0)) && IsModel) {
908  TArrayD Ampls(Models.GetLast()+1);
909 
910  for(Int_t n=0;n<=Models.GetLast();n++) {
911  TGo4FitModel* model = (TGo4FitModel*) Models[n];
912  model->BeforeEval(iter->ScalesSize());
913  Ampls[n] = model->GetAmplValue() * model->GetRatioValueFor(DataName);
914  }
915 
916  if (iter->Reset(UseRanges)) do {
917  Double_t zn = 0;
918  for(Int_t n=0;n<=Models.GetLast();n++) {
919  TGo4FitModel* model = (TGo4FitModel*) Models[n];
920  zn += Ampls[n] * model->EvaluateAtPoint(iter);
921  }
922  if (histo)
923  switch(ndim) {
924  case 1: histo->SetBinContent(iter->Indexes()[0]+1,zn); break;
925  case 2: histo->SetBinContent(iter->Indexes()[0]+1,iter->Indexes()[1]+1,zn); break;
926  case 3: histo->SetBinContent(iter->Indexes()[0]+1,iter->Indexes()[1]+1,iter->Indexes()[2]+1,zn); break;
927  }
928  if(gr) {
929  (gr->GetX())[iter->Point()] = iter->x();
930  (gr->GetY())[iter->Point()] = zn;
931  }
932 
933  } while (iter->Next(UseRanges));
934 
935  for(Int_t n=0;n<=Models.GetLast();n++) {
936  TGo4FitModel* model = (TGo4FitModel*) Models[n];
937  model->AfterEval();
938  }
939  }
940 
941  delete iter;
942 
943  if (gr && IsModel)
944  for(Int_t n1=0;n1<gr->GetN()-1;n1++)
945  for(Int_t n2=n1+1;n2<gr->GetN();n2++)
946  if ((gr->GetX())[n1]>(gr->GetX())[n2]) {
947  Double_t xx = (gr->GetX())[n1];
948  (gr->GetX())[n1] = (gr->GetX())[n2];
949  (gr->GetX())[n2] = xx;
950  Double_t yy = (gr->GetY())[n1];
951  (gr->GetY())[n1] = (gr->GetY())[n2];
952  (gr->GetY())[n2] = yy;
953  }
954 
955  TNamed* res = 0;
956  if (histo) res = histo; else res = gr;
957  if (res) {
958  TString title;
959  if (IsModel)
960  if (ModelName) { title = "Draw of model "; title+=ModelName; }
961  else { title = "Draw of full model of "; title+=DataName; }
962  else { title = "Draw of data "; title+=DataName; }
963  res->SetTitle(title.Data());
964  }
965 
966  return res;
967 }
968 
969 
970 /* valid format for draw options
971 
972  "" - draw all data
973  "*" - draw all data with models
974  "**" - draw all data with models and all components
975  "DataName" - draw select data with model
976  "DataName-" - draw select data without model
977  "DataName*" - draw select data with model and components
978  "DataName-, Background" - draw data and sum of components, belongs to background group (index=0)
979  "DataName-, Group1" - draw data and sum of components, belongs to group 1
980  "ModelName" - draw model component and correspondent data
981 */
982 
983 void TGo4Fitter::Draw(Option_t* option)
984 {
985  TString opt(option);
986 
987  TCanvas *fCanvas = 0;
988 
989  if ((opt.Length()>0) && (opt[0]=='#')) {
990  opt.Remove(0,1);
991  TString CanvasName;
992  Int_t n=0;
993  do {
994  CanvasName = "Canvas";
995  CanvasName+=n++;
996  } while (gROOT->FindObject(CanvasName.Data()));
997  fCanvas = new TCanvas(CanvasName,TString("Draw of fitter ")+GetName()+" "+opt,3);
998  fCanvas->cd();
999  }
1000 
1001  Bool_t drawdata = kFALSE;
1002  TGo4FitData *selectdata = 0;
1003  TObjArray selectmodels;
1004  selectmodels.SetOwner(kTRUE);
1005  Bool_t drawcomp = kFALSE;
1006  Bool_t drawmodel = kFALSE;
1007 
1008  if (opt=="*") { opt = ""; drawdata = kTRUE; }
1009 
1010  while (opt.Length()>0) {
1011  Int_t len = opt.Index(",",0,TString::kExact);
1012 
1013  if (len<0) len = opt.Length();
1014  if (len==0) break;
1015 
1016  TString optpart(opt.Data(), len);
1017  while ((optpart.Length()>0) && (optpart[0]==' ')) optpart.Remove(0,1);
1018 
1019  Bool_t find = kFALSE;
1020 
1021  for(Int_t n=0;n<GetNumData();n++)
1022  if (optpart.Index(GetDataName(n),0,TString::kExact)==0) {
1023  selectdata = GetData(n);
1024  drawdata = kTRUE;
1025  drawmodel = kTRUE;
1026  find = kTRUE;
1027  optpart.Remove(0,strlen(GetDataName(n)));
1028  if (optpart=="*") drawcomp = kTRUE; else
1029  if (optpart=="-") drawmodel = kFALSE;
1030  break;
1031  }
1032 
1033  if (!find) {
1034  selectmodels.Add(new TObjString(optpart));
1035  TGo4FitModel* model = FindModel(optpart.Data());
1036  if (model && (selectdata==0))
1037  for(Int_t n=0;n<GetNumData();n++)
1038  if (model->IsAssignTo(GetDataName(n)))
1039  selectdata = GetData(n);
1040  }
1041 
1042  opt.Remove(0,len);
1043  if (opt.Length()>0) opt.Remove(0,1);
1044  }
1045 
1046  if ((selectdata==0) && !drawdata)
1047  if (GetNumData()>0) selectdata = GetData(0);
1048 
1050  fxDrawObjs = new TObjArray();
1051 
1052  for(Int_t n=0;n<GetNumData();n++) {
1053  TGo4FitData* data = GetData(n);
1054  if (selectdata && (data!=selectdata)) continue;
1055 
1056  if (drawdata) {
1057  TObject* obj = CreateDrawObject(TString(data->GetName())+"_bins", data->GetName(), kFALSE);
1058 
1059  TAttLine* line = dynamic_cast<TAttLine*> (obj);
1060  if (line) {
1061  line->SetLineColor(1);
1062  line->SetLineWidth(1);
1063  }
1064  if (obj) fxDrawObjs->Add(obj);
1065  }
1066 
1067  if (drawmodel) {
1068  TObject* mobj = CreateDrawObject(TString(data->GetName())+"_fullmodel", data->GetName(), kTRUE);
1069 
1070  TAttLine* line = dynamic_cast<TAttLine*> (mobj);
1071  if (line) {
1072  line->SetLineColor(4);
1073  line->SetLineWidth(2);
1074  }
1075  if (mobj) fxDrawObjs->Add(mobj);
1076  }
1077 
1078  if (drawcomp)
1079  for(Int_t nmodel=0;nmodel<GetNumModel();nmodel++) {
1080  TGo4FitModel *model = GetModel(nmodel);
1081  if ( !model->IsAssignTo(data->GetName())) continue;
1082 
1083  TObject* cobj = CreateDrawObject(TString(data->GetName())+"_"+model->GetName(), data->GetName(), kTRUE, model->GetName());
1084 
1085  TAttLine* line = dynamic_cast<TAttLine*> (cobj);
1086  if (line) {
1087  line->SetLineColor(6);
1088  line->SetLineWidth(1);
1089  }
1090  if (cobj) fxDrawObjs->Add(cobj);
1091  }
1092 
1093  for (Int_t n=0;n<=selectmodels.GetLast();n++) {
1094  TString name = ((TObjString*) (selectmodels[n]))->String();
1095 
1096  TObject* cobj = CreateDrawObject(TString(data->GetName())+"_" +name, data->GetName(), kTRUE, name.Data());
1097 
1098  TAttLine* line = dynamic_cast<TAttLine*> (cobj);
1099  if (line) {
1100  line->SetLineColor(6);
1101  line->SetLineWidth(1);
1102  }
1103  if (cobj) fxDrawObjs->Add(cobj);
1104  }
1105  }
1106 
1107  if (fxDrawObjs->GetLast()==0) fxDrawObjs->At(0)->Draw(); else
1108  if (fxDrawObjs->GetLast()>0) {
1109  Bool_t allhisto = kTRUE;
1110  for (Int_t n=0;n<=fxDrawObjs->GetLast();n++)
1111  if (!(fxDrawObjs->At(n)->InheritsFrom(TH1::Class()))) allhisto = kFALSE;
1112  if (allhisto) {
1113  THStack* stack = new THStack(TString("Stack")+"_"+fxDrawObjs->At(0)->GetName(),fxDrawObjs->At(0)->GetName());
1114  for (Int_t n=0;n<=fxDrawObjs->GetLast();n++) stack->Add((TH1*)fxDrawObjs->At(n));
1115  fxDrawObjs->Clear();
1116  fxDrawObjs->Add(stack);
1117  stack->Draw("nostack");
1118  } else
1119  for (Int_t n=0;n<=fxDrawObjs->GetLast();n++)
1120  if (n==0) fxDrawObjs->At(n)->Draw("A*");
1121  else fxDrawObjs->At(n)->Draw("L");
1122  }
1123 
1124  if (fCanvas!=0) fCanvas->Update();
1125 }
1126 
1128 {
1129  std::cout << std::endl << "*** LIST OF AMPLITUDES VALUE ***" << std::endl;
1130  for(Int_t n=0;n<GetNumComp();n++) {
1131  TGo4FitComponent* comp = ((TGo4Fitter*) this)->GetComp(n);
1132  if (comp->GetAmplPar() != 0)
1133  std::cout << " " << comp->GetAmplFullName() << " " << comp->GetAmplValue() << " " << comp->GetAmplError() << std::endl;
1134  }
1135 }
1136 
1138 {
1139  std::cout << std::endl << " *** LIST OF LINES PARAMETERS ***" << std::endl;
1140 
1141  int MaxAxis = 0;
1142  for (Int_t n=0; n<GetNumModel();n++) {
1143  TGo4FitModel* m = ((TGo4Fitter*) this)->GetModel(n);
1144  if (m==0) continue;
1145  Double_t zn;
1146  for (int naxis=0;naxis<3;naxis++)
1147  if (m->GetPosition(naxis,zn) || m->GetWidth(naxis,zn)) MaxAxis = naxis;
1148  }
1149 
1150  std::cout << std::setw(10) << "Name" << std::setw(12) << "Ampl";
1151  for(Int_t naxis=0;naxis<=MaxAxis;naxis++)
1152  std::cout << std::setw(11) << "Pos" << naxis << std::setw(11) << "Width" << naxis;
1153  std::cout << std::endl;
1154 
1155  for (Int_t n=0; n<GetNumModel();n++) {
1156  TGo4FitModel* m = ((TGo4Fitter*) this)->GetModel(n);
1157  if (m==0) continue;
1158  std::cout << std::setw(10) << m->GetName() << std::setw(12) << m->GetAmplValue();
1159 
1160  for (int naxis=0;naxis<=MaxAxis;naxis++) {
1161  Double_t pos, width;
1162  std::cout << std::setw(12);
1163  if (m->GetPosition(naxis,pos)) std::cout << pos;
1164  else std::cout << "---";
1165  std::cout << std::setw(12);
1166  if (m->GetWidth(naxis,width)) std::cout << width;
1167  else std::cout << "---";
1168  }
1169  std::cout << std::endl;
1170  }
1171 }
1172 
1173 
1175 {
1176  if (fxDrawObjs) {
1177  lst.AddAll(fxDrawObjs);
1178  delete fxDrawObjs;
1179  fxDrawObjs = 0;
1180  }
1181 }
1182 
1184 {
1185  if (fxDrawObjs) {
1186  for(Int_t n=0;n<=fxDrawObjs->GetLast();n++)
1187  gROOT->Add(fxDrawObjs->At(n));
1188  delete fxDrawObjs;
1189  fxDrawObjs = 0;
1190  }
1191 }
1192 
1193 TString TGo4Fitter::FindNextName(const char* Head, Int_t start, Bool_t isModel)
1194 {
1195  TString name;
1196  Int_t n = start;
1197  do {
1198  name.Form("%s%d", Head, n++);
1199  } while (isModel ? FindModel(name.Data())!=0 : FindData(name.Data())!=0 );
1200  return name;
1201 }
1202 
1203 void TGo4Fitter::Streamer(TBuffer& b)
1204 {
1205  if (b.IsReading()) {
1206  TGo4Fitter::Class()->ReadBuffer(b, this);
1210  } else {
1212  TGo4Fitter::Class()->WriteBuffer(b, this);
1213  }
1214 }
virtual void DoAction(TGo4FitterAbstract *Fitter)
Double_t xWidths() const
TH1 * CreateHistogram(const char *HistoName, Bool_t UseRanges=kFALSE, Bool_t SetBins=kFALSE)
void SetUpdateSlotList()
virtual void Print(Option_t *option) const
Definition: TGo4Fitter.cxx:707
friend class TGo4FitAmplEstimation
Definition: TGo4Fitter.h:385
TGo4FitDataGraph * AddGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:142
void PrintLines() const
void RebuildAll(Bool_t ForceBuild=kFALSE)
Definition: TGo4Fitter.cxx:627
virtual Double_t DoCalculation()
Definition: TGo4Fitter.cxx:617
Bool_t HasWidths() const
Definition: TGo4FitData.h:499
virtual void Clear(Option_t *option="")
void SetMemoryUsage(Int_t iMemoryUsage)
Definition: TGo4Fitter.cxx:72
TObjArray * fxDrawObjs
Definition: TGo4Fitter.h:446
void SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned=kFALSE)
virtual void Finalize()
virtual Int_t DoNDFCalculation()
Definition: TGo4Fitter.cxx:622
TGo4FitSlot * GetSlot(Int_t nslot)
Double_t x() const
Definition: TGo4FitData.h:484
void ClearAssignments()
TGo4FitComponent * GetComp(Int_t n)
Definition: TGo4Fitter.cxx:220
Double_t * GetBinsValues()
Definition: TGo4FitData.h:255
void MoveDrawObjectsToROOT()
void SetFitFunctionType(Int_t iFitFunctionType)
Definition: TGo4Fitter.h:80
virtual void Draw(Option_t *option)
Definition: TGo4Fitter.cxx:983
void AddAmplEstimation(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:654
void ClearModelAssignmentTo(const char *ModelName, const char *DataName=0)
Definition: TGo4Fitter.cxx:439
virtual void CollectAllPars()
Definition: TGo4Fitter.cxx:79
const char * GetAmplFullName()
virtual TGo4FitDataIter * MakeIter()
Definition: TGo4FitData.h:165
virtual void Finalize()
virtual void FinalizeFitterData()
Definition: TGo4Fitter.cxx:484
Int_t GetDataBinsSize(TGo4FitData *data)
Definition: TGo4Fitter.cxx:682
void EstimateAmplitudes(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:648
TGo4FitModel * FindModel(const char *ModelName)
Definition: TGo4Fitter.cxx:198
Int_t GetGroupIndex() const
Definition: TGo4FitModel.h:119
void AddPolynoms(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t NumAxis=1, Int_t GroupIndex=0)
Definition: TGo4Fitter.cxx:297
void ClearConnectionToSlot()
Definition: TGo4FitSlot.cxx:94
Double_t * GetDataBinsResult(TGo4FitData *data)
Definition: TGo4Fitter.cxx:697
void AssignToData(const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Double_t * GetModelBins(const char *DataName) const
Int_t NumModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:390
void AddAction(TGo4FitterAction *Action)
void CheckSlotsBeforeDelete(TGo4FitComponent *comp)
Definition: TGo4Fitter.cxx:157
TGraph * CreateGraph(const char *GraphName, Bool_t UseRanges=kFALSE, Bool_t SetBins=kFALSE)
void AddPolynomX(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t GroupIndex=0, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:225
virtual Bool_t Initialize(Int_t UseBuffers=-1)
void ClearAssignmentTo(const char *DataName)
Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev)
Definition: TGo4Fitter.cxx:491
void AssignModelTo(const char *ModelName, const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Definition: TGo4Fitter.cxx:424
void ClearSlot(TGo4FitSlot *slot, Bool_t NonOwned)
void SetAmplValue(Double_t iAmpl)
const char * AssignmentName(Int_t n)
Definition: TGo4FitModel.h:129
void SetOwner(TNamed *iOwner)
Definition: TGo4FitNamed.h:58
TObjArray fxModels
Definition: TGo4Fitter.h:424
TGo4FitData * RemoveData(const char *DataName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:172
void DeleteAllData()
Definition: TGo4Fitter.cxx:185
TGo4FitModel * RemoveModel(const char *ModelName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:377
Int_t fiMemoryUsage
Definition: TGo4Fitter.h:434
TUserFitFunction fxUserFitFunction
Definition: TGo4Fitter.h:444
Double_t * GetDataBinsDevs(TGo4FitData *data)
Definition: TGo4Fitter.cxx:692
virtual Bool_t Reset(Bool_t UseRanges=kTRUE)
Int_t DefineBinsSize()
virtual Double_t EvaluateAtPoint(TGo4FitData *data, Int_t nbin, Bool_t UseRanges=kTRUE)
Int_t fiFitFunctionType
Definition: TGo4Fitter.h:429
void DeleteModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:398
virtual void FillSlotList(TSeqCollection *list)
Definition: TGo4Fitter.cxx:665
Double_t CalculatesIntegral(const char *DataName, const char *ModelName=0, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:808
Int_t Point() const
Definition: TGo4FitData.h:524
Int_t GetMemoryUsage()
Definition: TGo4Fitter.h:113
void PrepareSlotsForWriting()
TGo4FitData * AddData(TGo4FitData *d)
Definition: TGo4Fitter.cxx:118
virtual Bool_t GetPosition(Int_t naxis, Double_t &pos)
virtual void Print(Option_t *option) const
Double_t * GetBinsResult()
Definition: TGo4FitData.h:267
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
void SetGraph(TGraph *iGraph, Bool_t iGraphOwned=kFALSE)
Bool_t BuffersAllocated() const
Definition: TGo4FitData.h:238
TGo4FitSlot * GetConnectedSlot() const
Definition: TGo4FitSlot.h:124
void CheckDuplicatesOnSlot()
TGo4FitModelGauss1 * AddGauss1(const char *DataName, const char *ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl=1., Int_t Axis=0)
Definition: TGo4Fitter.cxx:347
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
Definition: TGo4Fitter.cxx:448
void SetRange(Int_t naxis, Double_t min, Double_t max)
virtual void CollectAllPars()
Int_t CalculateNDF(const char *DataName=0)
Definition: TGo4Fitter.cxx:595
TGo4FitDataGraph * SetGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:150
TGo4FitModel * GetModel(Int_t n)
Definition: TGo4Fitter.cxx:193
Double_t CalculatesModelIntegral(const char *ModelName, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:846
Double_t * GetBinsDevs()
Definition: TGo4FitData.h:261
TObjArray fxDatas
Definition: TGo4Fitter.h:419
Int_t GetNumComp() const
Definition: TGo4Fitter.h:281
Int_t CountPoints(Bool_t UseRanges=kTRUE)
virtual Bool_t Initialize(Int_t UseBuffers=-1)
Int_t GetBinsSize() const
Definition: TGo4FitData.h:243
virtual Bool_t Next(Bool_t UseRanges=kTRUE)
virtual Bool_t BeforeEval(Int_t ndim)
void ConnectToDataIfAssigned(TGo4FitData *data)
TString FindNextName(const char *Head, Int_t start, Bool_t isModel=kTRUE)
virtual void FillSlotList(TSeqCollection *lst)
void PrintAmpls() const
virtual void AfterEval()
Definition: TGo4FitModel.h:253
TGo4FitData * GetData(Int_t n)
Definition: TGo4Fitter.cxx:103
void SetGroupIndex(Int_t index=-1)
Definition: TGo4FitModel.h:109
virtual Bool_t GetWidth(Int_t naxis, Double_t &width)
virtual ~TGo4Fitter()
Definition: TGo4Fitter.cxx:66
Int_t NumAssigments() const
Definition: TGo4FitModel.h:124
Int_t GetFitFunctionType()
Definition: TGo4Fitter.h:85
Double_t * GetModelBinsValues(TGo4FitModel *model, const char *DataName)
Definition: TGo4Fitter.cxx:702
Double_t CalculateFitFunction(Double_t *pars=0, Int_t FitFunctionType=-1, const char *DataName=0)
Definition: TGo4Fitter.cxx:582
virtual void CollectParsTo(TGo4FitParsList &list)
Bool_t DataBuffersAllocated(TGo4FitData *data)
Definition: TGo4Fitter.cxx:677
Bool_t HasIndexes() const
Definition: TGo4FitData.h:454
TGo4FitModel * CloneModel(const char *ModelName, const char *NewName=0)
Definition: TGo4Fitter.cxx:355
const char * GetDataName(Int_t n)
Definition: TGo4Fitter.cxx:108
Bool_t BuffersAllocated() const
Double_t Value() const
Definition: TGo4FitData.h:514
Int_t GetNumModel() const
Definition: TGo4Fitter.h:178
TGo4FitModel * AddModel(TGo4FitModel *m)
Definition: TGo4Fitter.cxx:203
const Int_t * Indexes() const
Definition: TGo4FitData.h:464
void PrintPars() const
TObject * CreateDrawObject(const char *ObjName, const char *DataName, Bool_t IsModel=kFALSE, const char *ModelName=0)
Definition: TGo4Fitter.cxx:853
virtual Bool_t InitFitterData()
Definition: TGo4Fitter.cxx:454
void RebuildShape(Bool_t ForceBuild=kFALSE)
Bool_t IsAssignTo(const char *DataName) const
Definition: TGo4FitModel.h:141
TGo4FitDataHistogram * SetH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:134
Bool_t CalculatesMomentums(const char *DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t &first, Double_t &second)
Definition: TGo4Fitter.cxx:732
Double_t * GetDataBinsValues(TGo4FitData *data)
Definition: TGo4Fitter.cxx:687
virtual void Clear(Option_t *option=0)
Definition: TGo4Fitter.cxx:96
TGo4FitData * FindData(const char *DataName)
Definition: TGo4Fitter.cxx:113
Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData *selectdata=0)
Definition: TGo4Fitter.cxx:523
Bool_t AddModelToDataResult(TGo4FitData *data)
Int_t IndexesSize() const
Definition: TGo4FitData.h:459
Double_t StandardDeviation() const
Definition: TGo4FitData.h:519
Double_t GetRatioValueFor(const char *DataName)
void ProvideLastDrawObjects(TObjArray &lst)
Bool_t ModelBuffersAllocated(TGo4FitModel *model)
Definition: TGo4Fitter.cxx:672
void AddStandardActions()
Definition: TGo4Fitter.cxx:659
Int_t ScalesSize() const
Definition: TGo4FitData.h:474
TGo4FitParameter * GetAmplPar()
void ExecuteDependencies(Double_t *pars)
void DeleteAllModels()
Definition: TGo4Fitter.cxx:416
Int_t GetNumData() const
Definition: TGo4Fitter.h:123
void SetParsValues(Double_t *pars)
TGo4FitDataHistogram * AddH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:126