00001 // $Id: TGo4FitterEnvelope.cxx 934 2013-01-29 15:59:24Z 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 #include "TGo4FitterEnvelope.h" 00015 00016 #include "Riostream.h" 00017 00018 TGo4FitterEnvelope::TGo4FitterEnvelope() 00019 : TGo4Parameter("Fitter envelope"), fxFitter(0) 00020 { 00021 } 00022 00023 TGo4FitterEnvelope::TGo4FitterEnvelope(const char* name, TGo4Fitter* fitter) 00024 : TGo4Parameter(name) 00025 { 00026 fxFitter=fitter; 00027 } 00028 00029 TGo4FitterEnvelope::~TGo4FitterEnvelope() 00030 { 00031 if(fxFitter) delete fxFitter; 00032 } 00033 00034 Int_t TGo4FitterEnvelope::PrintParameter(Text_t * buffer, Int_t buflen) 00035 { 00036 Int_t locallen=128000; 00037 Text_t localbuf[128000]; 00038 if(buflen<0 && buffer!=0) 00039 return 0; 00040 Int_t size=0; 00041 Text_t* current=localbuf; 00042 size+=TGo4Parameter::PrintParameter(current,locallen-size-1); 00043 current= localbuf + size; 00044 if(fxFitter) 00045 size+=sprintf(current," \t This object contains the fitter: %s \n",fxFitter->GetName()); 00046 else 00047 size+=sprintf(current," \t This object contains no fitter\n"); 00048 current=localbuf+size; 00049 // here we optionally might put printout of fitter if we like... 00050 if(buffer==0) 00051 { 00052 std::cout << localbuf << std::endl; 00053 } 00054 else 00055 { 00056 if(size>buflen-1) 00057 size=buflen-1; 00058 strncpy(buffer,localbuf,size); 00059 } 00060 return size; 00061 } 00062 00063 Bool_t TGo4FitterEnvelope::UpdateFrom(TGo4Parameter *pp) 00064 { 00065 TGo4FitterEnvelope * from = dynamic_cast<TGo4FitterEnvelope *> (pp); 00066 00067 if(from==0) return kFALSE; 00068 00069 if(fxFitter!=0) delete fxFitter; 00070 fxFitter = from->GetFitter(kTRUE);// change ownership to us 00071 return kTRUE; 00072 } 00073 00074 void TGo4FitterEnvelope::Clear(Option_t* opt) 00075 { 00076 if(fxFitter) fxFitter->Clear(opt); 00077 } 00078 00079 TGo4Fitter* TGo4FitterEnvelope::GetFitter(Bool_t chown) 00080 { 00081 TGo4Fitter* rev=fxFitter; 00082 if(chown) fxFitter=0; 00083 return rev; 00084 } 00085 00086 void TGo4FitterEnvelope::SetFitter(TGo4Fitter* fitter) 00087 { 00088 if(fxFitter!=0) delete fxFitter; 00089 fxFitter=fitter; 00090 }