GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TModelTemplate.cxx
Go to the documentation of this file.
1 // $Id: TModelTemplate.cxx 2627 2019-10-01 08:02:45Z 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 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 /* template for user model class
15  The only function, which should be redefined by used - UserFunction()
16  In given example constructor provides a general interface to create
17  several parameters. Amplitude parameters can be add, if necessary.
18  Any kind of other constructors with predefine parameters set and names can be invented
19  Here user function is Gaussian
20 */
21 
22 
23 #include "TString.h"
24 #include "TMath.h"
25 #include "TModelTemplate.h"
26 
27 TModelTemplate::TModelTemplate(const char* iName, Int_t iNPars, Bool_t AddAmplitude) :
28  TGo4FitModel(iName,"Template for user model",AddAmplitude)
29 {
30  for (Int_t n=0;n<iNPars;n++) {
31  TString s("Par"); s+=n;
32  NewParameter(s.Data(),"model template parameter",0.);
33  }
34 }
35 
36 Double_t TModelTemplate::UserFunction(Double_t* Coordinates, Double_t* Parameters)
37 {
38  Double_t pos = Parameters[0];
39  Double_t width = Parameters[1];
40  Double_t x = Coordinates[0];
41  return TMath::Exp(-0.5*(x-pos)*(x-pos)/width/width);
42 }
TGo4FitParameter * NewParameter(const char *Name, const char *Title, Double_t iValue=0., Bool_t Fixed=kFALSE, Int_t AtIndx=-1)
virtual Double_t UserFunction(Double_t *Coordinates, Double_t *Parameters)
TModelTemplate(const char *iName, Int_t iNPars, Bool_t AddAmplitude=kFALSE)