00001 // $Id: TModelTemplate.cxx 554 2010-01-22 15:53:21Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 /* template for user model class 00015 The only function, which should be redefined by used - UserFunction() 00016 In given example constructor provides a general interface to create 00017 several parameters. Amplitude parameters can be add, if necessary. 00018 Any kind of other constructors with predefine parameters set and names can be invented 00019 Here user function is Gaussian 00020 */ 00021 00022 00023 #include "TString.h" 00024 #include "TMath.h" 00025 #include "TModelTemplate.h" 00026 00027 TModelTemplate::TModelTemplate(const char* iName, Int_t iNPars, Bool_t AddAmplitude) : 00028 TGo4FitModel(iName,"Template for user model",AddAmplitude) 00029 { 00030 for (Int_t n=0;n<iNPars;n++) { 00031 TString s("Par"); s+=n; 00032 NewParameter(s.Data(),"model template parameter",0.); 00033 } 00034 } 00035 00036 Double_t TModelTemplate::UserFunction(Double_t* Coordinates, Double_t* Parameters) 00037 { 00038 Double_t pos = Parameters[0]; 00039 Double_t width = Parameters[1]; 00040 Double_t x = Coordinates[0]; 00041 return TMath::Exp(-0.5*(x-pos)*(x-pos)/width/width); 00042 }