Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

AIDA_FitResult.cpp

Go to the documentation of this file.
00001  /**********************************************************************
00002   *                                                                    *
00003   * Copyright (c) 2002 Lorenzo Moneta, CERN/IT                       *
00004   *                   <Lorenzo.Moneta.cern.ch>                       *
00005   *                                                                    *
00006   * This library is free software; you can redistribute it and/or      *
00007   * modify it under the terms of the GNU Lesser General Public         *
00008   * License as published by the Free Software Foundation; either       *
00009   * version 2.1 of the License, or (at your option) any later version. *
00010   *                                                                    *
00011   * This library is distributed in the hope that it will be useful,    *
00012   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00013   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014   * Lesser General Public License for more details.                    *
00015   *                                                                    *
00016   * You should have received a copy of the GNU Lesser General Public   *
00017   * License along with this library (see file COPYING); if not, write  *
00018   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00019   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00020   *                                                                    *
00021   **********************************************************************/
00022 
00023 // Implementation file for class AIDA_FitResult
00024 // 
00025 // Authors  : Lorenzo Moneta , Jakub Moscicki
00026 // Created  : Fri Oct  4 14:08:23 2002
00027 // 
00028 // Last update: Fri Oct  4 14:08:23 2002
00029 // 
00030 
00031 #include "AIDA_FitResult.h"
00032 #include "FML/debug.h"
00033 #include "FML/util.h"
00034 
00035 namespace Anaphe  { 
00036   namespace AIDA_Fitter_FML { 
00037 
00038     // constructs from an FML Fit Result 
00039     
00040     AIDA_FitResult::AIDA_FitResult( std::auto_ptr<Anaphe::FML::FitResult> r) : 
00041       m_result(r){
00042       assert(m_result.get());
00043       // convert FML function to AIDA Function
00044       std::auto_ptr<Anaphe::FML::IFMLFunction> f(&m_result->fittedFunction() );
00045       assert (f.get());
00046       std::auto_ptr<Anaphe::AIDA_Function_FML::AIDA_FunctionAdapter> 
00047         aida_f(new Anaphe::AIDA_Function_FML::AIDA_FunctionAdapter(f) ); 
00048       m_fadapter = aida_f; 
00049       assert(m_fadapter.get()); 
00050       
00051       fillAnnotation(m_fadapter.get()); 
00052     }
00053 
00054 
00055     AIDA_FitResult::~AIDA_FitResult() 
00056     {
00057     }
00058 
00059     AIDA_FitResult::AIDA_FitResult(const AIDA_FitResult &) 
00060     {
00061     }
00062 
00063     AIDA_FitResult & AIDA_FitResult::operator = (const AIDA_FitResult &rhs) 
00064     {
00065       if (this == &rhs) return *this;  // time saving self-test
00066       
00067       return *this;
00068     }
00069 
00070 
00071 
00073     
00074     bool AIDA_FitResult::isValid()
00075     {
00076       return m_result->isValid();
00077     }
00078 
00079     int AIDA_FitResult::fitStatus()
00080     {
00081       return m_result->fitStatus();
00082     }
00083     
00084     AIDA::IFunction * AIDA_FitResult::fittedFunction()
00085     {
00086       return m_fadapter.get();
00087     }
00088     
00089     double AIDA_FitResult::quality()
00090     {
00091       return m_result->quality();
00092     }
00093 
00094     int AIDA_FitResult::ndf()
00095     {
00096       return m_result->ndf();
00097     }
00098     
00099     const std::vector<double>  & AIDA_FitResult::fittedParameters() const
00100     { 
00101       return m_fadapter->parameters(); 
00102     }
00103     const std::vector<std::string>  & AIDA_FitResult::fittedParameterNames() const
00104     { 
00105       return m_fadapter->parameterNames(); 
00106     }
00107     double AIDA_FitResult::fittedParameter(std::string & name) { 
00108       return m_fadapter->parameter(name);
00109     }
00110 
00111 
00112 
00113 const std::vector<double> & AIDA_FitResult::errors() const 
00114 { 
00115   return m_result->errors();
00116 }
00117 
00118 const std::vector<double> & AIDA_FitResult::errorsPlus() const
00119 { 
00120   return m_result->errorsPlus();
00121 }
00122 
00123 const std::vector<double> & AIDA_FitResult::errorsMinus() const
00124 { 
00125   return m_result->errorsMinus();
00126 }
00127 
00128 double AIDA_FitResult::covMatrixElement(int i, int j)
00129 {
00130   return m_result->covMatrixElement(i,j);
00131 }
00132     
00133 std::string AIDA_FitResult::fitMethodName()
00134 {
00135   return m_result->fitConfig().fitMethodName();
00136 }
00137 
00138 std::string AIDA_FitResult::engineName()
00139 {
00140   return m_result->fitConfig().engineName();
00141 }
00142 
00143 std::string AIDA_FitResult::dataDescription()
00144 {
00145   return m_result->dataDescription();
00146 }
00147 
00148 const std::vector<std::string>  & AIDA_FitResult::constraints()
00149 {
00150   return m_constr;
00151 }
00152 
00153 AIDA::IFitParameterSettings * AIDA_FitResult::fitParameterSettings(std::string name)
00154 {
00155   Anaphe::FML::FitParameterSettings *ps_fml = &m_result->fitConfig().fitParameterSettings(name);
00156   
00157   // create a proxy to underlying implementation
00158   AIDA_FitParameterSettings * ps = new AIDA_FitParameterSettings(ps_fml); 
00159   m_fitpar[name] = ps;
00160 
00161   return m_fitpar[name];
00162 }
00163             
00165       
00166 // I don't have time to implement these setters.
00167     // They are only required if foreign implementation wanted
00168     // to set something, but it is not vital for functioning of 
00169     // FML in the AIDA framework.
00170     // FML::FitResultSetter should be cleaned and its setter method
00171     // should be probably not organized in blocks but rather in idividual
00172     // setters for every thing separately, this would make this wrapper
00173     // easier to implement.
00174     // KUBA
00175 
00176 void AIDA_FitResult::setIsValid(bool yes)
00177 {
00178   INFO_MSG("AIDA_FitResult: setters not implemented");
00179   /*
00180     Anaphe::FML::FitResultSetter rs(*m_result.get());
00181     rs.setFlags(yes, m_result->fitStatus());
00182   */
00183 }
00184 
00185 void AIDA_FitResult::setFitStatus(int status)
00186 {
00187   INFO_MSG("AIDA_FitResult: setters not implemented");
00188   /*
00189     Anaphe::FML::FitResultSetter rs(*m_result.get());
00190     rs.setFitStatus(m_result->isValid(), status);
00191   */
00192 }
00193 
00194 void AIDA_FitResult::setFittedFunction(AIDA::IFunction * f)
00195 {
00196 
00197   INFO_MSG("AIDA_FitResult: setters not implemented");
00198   
00199         /*
00200         assert(f);
00201 
00202         Anaphe::FML::IFMLFunction *ff = Anaphe::AIDA_Function_FML::getImplementation(f);
00203 
00204         Anaphe::AIDA_Function_FML::FMLFunctionAdapter fa(f);
00205 
00206         if(!ff)           
00207           ff = &fa;         
00208             
00209         Anaphe::FML::FitResultSetter rs(*m_result.get());       
00210         rs.setConfig(m_result->fitConfig(), *ff, m_result->dataDescription());
00211 
00212         m_fadapter = AIDAFunctionAdapter(&m_result.fittedFunction());
00213         */
00214       }
00215 
00216       void AIDA_FitResult::setQuality(double quality)
00217       {
00218         INFO_MSG("AIDA_FitResult: setters not implemented");
00219       }
00220 
00221       void AIDA_FitResult::setNdf(int ndf)
00222       {
00223         INFO_MSG("AIDA_FitResult: setters not implemented");
00224       }
00225 
00226       void AIDA_FitResult::setCovMatrixElement(int i, int j, double val)
00227       { 
00228         INFO_MSG("AIDA_FitResult: setters not implemented"); 
00229       }
00230 
00231       void AIDA_FitResult::setFitMethodName(std::string name)
00232       {
00233         INFO_MSG("AIDA_FitResult: setters not implemented");
00234       }
00235       void AIDA_FitResult::setEngineName(std::string name)
00236       {
00237         INFO_MSG("AIDA_FitResult: setters not implemented");
00238       }
00239 
00240       void AIDA_FitResult::setDataDescription(std::string descr)
00241       {
00242         INFO_MSG("AIDA_FitResult: setters not implemented");
00243       }
00244       void AIDA_FitResult::setConstraints(const std::vector<std::string>  & cv)
00245       {
00246         INFO_MSG("AIDA_FitResult: setters not implemented");
00247       }
00248 
00249       void AIDA_FitResult::setFitParameterSettings(std::string name, AIDA::IFitParameterSettings * s)
00250       {
00251         INFO_MSG("AIDA_FitResult: setters not implemented");
00252       }
00253  
00254 
00255       // Utility method
00256 // update annotation with fitted information
00257 
00258 void AIDA_FitResult::fillAnnotation(AIDA::IFunction * f) { 
00259   AIDA::IAnnotation & anno = f->annotation(); 
00260 
00261   std::string s(Util::to_string(quality() ) + " / " + Util::to_string(ndf() ) ); 
00262   anno.addItem("Fit Method ", fitMethodName() , false);  
00263   anno.addItem("Fit Quality / ndf ", s , false);  
00264   std::vector<std::string>  parNames = f->parameterNames(); 
00265   std::vector<double>  parValues = f->parameters(); 
00266   for (int i = 0; i < f->numberOfParameters() ; ++ i) { 
00267     std::string txt = Util::to_string( parValues[i] ) + " +/- " +  Util::to_string( errors()[i] );
00268     anno.setValue( parNames[i], txt ); 
00269   }
00270  
00271 }
00272 
00273 
00274   }     // end of namespace Anaphe::AIDA_Fitter_FML
00275 } 

Generated on Tue May 20 14:49:01 2003 for AIDA_Fitter_FML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002