Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > eebc325dc36bd6e3b09b9b45133e42f8 > files > 1004

HippoDraw-devel-docs-1.21.1-10.fc13.i686.rpm

<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>HippoDraw Class Library</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="hippoApp.ico">
</head><body>
<!-- Generated by Doxygen 1.6.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_6633238f5107fd0d748d9093e08c459d.html">minimizers</a>
  </div>
</div>
<div class="contents">
<h1>FitterFactory.cxx</h1><a href="FitterFactory_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00012"></a>00012 <span class="comment">// for have minuit</span>
<a name="l00013"></a>00013 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#include &quot;config.h&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#endif</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span>
<a name="l00017"></a>00017 <span class="comment">// for truncation warning in debug mode</span>
<a name="l00018"></a>00018 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#include &quot;msdevstudio/MSconfig.h&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#endif</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="FitterFactory_8h.html" title="FitterFactory class interface.">FitterFactory.h</a>&quot;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="comment">// List of default fitters</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="LMFitter_8h.html" title="LMFitter class interface.">LMFitter.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="BFGSFitter_8h.html" title="BFGSFitter class interface.">BFGSFitter.h</a>&quot;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#if HAVE_MINUIT || HAVE_MINUIT2</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="MinuitMigrad_8h.html" title="hippodraw::MinuitMigrad class interface">MinuitMigrad.h</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="comment">// List of default objective functions</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="NTupleChiSqFCN_8h.html" title="hippodraw::NTupleChiSqFCN class interface">NTupleChiSqFCN.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="NTupleLikeliHoodFCN_8h.html" title="hippodraw::NTupleLikeliHoodFCN class interface">NTupleLikeliHoodFCN.h</a>&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="NTuplePearsonFCN_8h.html" title="hippodraw::NTuplePearsonFCN class interface">NTuplePearsonFCN.h</a>&quot;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">using</span> std::string;
<a name="l00040"></a>00040 <span class="keyword">using</span> std::vector;
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="keyword">using namespace </span>hippodraw;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <a class="code" href="classhippodraw_1_1FitterFactory.html" title="A Factory singleton class for creating objects whose class derives from Fitter.">FitterFactory</a> * FitterFactory::s_instance = 0;
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="classhippodraw_1_1FitterFactory.html#afe9f9648de9891c99f73a99e92f2b1c5">00046</a> FitterFactory::FitterFactory ()
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 
<a name="l00050"></a><a class="code" href="classhippodraw_1_1FitterFactory.html#a74aa311b436741a7184b48b92b0eddf3">00050</a> <a class="code" href="classhippodraw_1_1FitterFactory.html" title="A Factory singleton class for creating objects whose class derives from Fitter.">FitterFactory</a> * <a class="code" href="classhippodraw_1_1FitterFactory.html#a74aa311b436741a7184b48b92b0eddf3" title="Returns a pointer to the singleton instance.">FitterFactory::instance</a> ()
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052   <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1FitterFactory.html#aec0d71f4a1ac26dfa0ddcb20aba3427a" title="A pointer to the singleton object.">s_instance</a> == 0 ) {
<a name="l00053"></a>00053     <a class="code" href="classhippodraw_1_1FitterFactory.html#aec0d71f4a1ac26dfa0ddcb20aba3427a" title="A pointer to the singleton object.">s_instance</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1FitterFactory.html#afe9f9648de9891c99f73a99e92f2b1c5" title="A default constructor for prevent creation except by the itself or the derived classes...">FitterFactory</a> ();
<a name="l00054"></a>00054     <a class="code" href="classhippodraw_1_1FitterFactory.html#aec0d71f4a1ac26dfa0ddcb20aba3427a" title="A pointer to the singleton object.">s_instance</a>-&gt;<a class="code" href="classhippodraw_1_1FitterFactory.html#a25a40b6614565f755233080a384c35f1" title="Initializes the factory with a set of default functions.">initialize</a> ();
<a name="l00055"></a>00055   }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitterFactory.html#aec0d71f4a1ac26dfa0ddcb20aba3427a" title="A pointer to the singleton object.">s_instance</a>;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a><a class="code" href="classhippodraw_1_1FitterFactory.html#a25a40b6614565f755233080a384c35f1">00060</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1FitterFactory.html#a25a40b6614565f755233080a384c35f1" title="Initializes the factory with a set of default functions.">FitterFactory::initialize</a> ()
<a name="l00061"></a>00061 {
<a name="l00062"></a>00062   <a class="code" href="classhippodraw_1_1Fitter.html" title="The base class for fitters.">Fitter</a> * fitter = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1LMFitter.html" title="A Fitter class.">LMFitter</a> ( <span class="stringliteral">&quot;ChiSq: Levenberg Marquart&quot;</span> );
<a name="l00063"></a>00063   <a class="code" href="classhippodraw_1_1StatedFCN.html" title="A derived class for FCNBase class.">StatedFCN</a> * chifcn = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTupleChiSqFCN.html" title="A Chi-squared functor class.">NTupleChiSqFCN</a> ();
<a name="l00064"></a>00064   fitter -&gt; setFCN ( chifcn );
<a name="l00065"></a>00065   <a class="code" href="classhippodraw_1_1Factory.html#a8aee137075d50e6fca916a1dbfd388c3" title="Adds a prototype object to the list of prototypes.">add</a> ( fitter  );
<a name="l00066"></a>00066 
<a name="l00067"></a>00067   fitter = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1LMFitter.html" title="A Fitter class.">LMFitter</a> ( <span class="stringliteral">&quot;Pearson: BFGS&quot;</span> );
<a name="l00068"></a>00068   <a class="code" href="classhippodraw_1_1StatedFCN.html" title="A derived class for FCNBase class.">StatedFCN</a> * pearsonfcn = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTuplePearsonFCN.html" title="A Pearson&amp;#39;s Chi-squared functor class.">NTuplePearsonFCN</a> ();
<a name="l00069"></a>00069   fitter -&gt; setFCN ( pearsonfcn );
<a name="l00070"></a>00070   <a class="code" href="classhippodraw_1_1Factory.html#a8aee137075d50e6fca916a1dbfd388c3" title="Adds a prototype object to the list of prototypes.">add</a> ( fitter  );
<a name="l00071"></a>00071 
<a name="l00072"></a>00072   fitter = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1BFGSFitter.html" title="The minimization algorithm used is a complementary quasi newton algorithm, with BFGS...">BFGSFitter</a>   ( <span class="stringliteral">&quot;MLEH: BFGS&quot;</span> );
<a name="l00073"></a>00073   <a class="code" href="classhippodraw_1_1StatedFCN.html" title="A derived class for FCNBase class.">StatedFCN</a> * likfcn = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTupleLikeliHoodFCN.html" title="A Likelihood functor class.">NTupleLikeliHoodFCN</a> ();
<a name="l00074"></a>00074   fitter -&gt; setFCN ( likfcn ); 
<a name="l00075"></a>00075   <a class="code" href="classhippodraw_1_1Factory.html#a8aee137075d50e6fca916a1dbfd388c3" title="Adds a prototype object to the list of prototypes.">add</a> ( fitter );
<a name="l00076"></a>00076  
<a name="l00077"></a>00077 <span class="preprocessor">#if HAVE_MINUIT || HAVE_MINUIT2</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>  fitter = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1MinuitMigrad.html" title="A Fitter class.">MinuitMigrad</a> ( <span class="stringliteral">&quot;ChiSq: Minuit(Migrad)&quot;</span> );
<a name="l00079"></a>00079   chifcn = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTupleChiSqFCN.html" title="A Chi-squared functor class.">NTupleChiSqFCN</a> ();
<a name="l00080"></a>00080   fitter -&gt; setFCN ( chifcn );
<a name="l00081"></a>00081   <a class="code" href="classhippodraw_1_1Factory.html#a8aee137075d50e6fca916a1dbfd388c3" title="Adds a prototype object to the list of prototypes.">add</a> ( fitter );
<a name="l00082"></a>00082 
<a name="l00083"></a>00083   fitter = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1MinuitMigrad.html" title="A Fitter class.">MinuitMigrad</a> ( <span class="stringliteral">&quot;MLEH: Minuit(Migrad)&quot;</span> );
<a name="l00084"></a>00084   likfcn = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTupleLikeliHoodFCN.html" title="A Likelihood functor class.">NTupleLikeliHoodFCN</a> ();
<a name="l00085"></a>00085   fitter -&gt; setFCN ( likfcn ); 
<a name="l00086"></a>00086   <a class="code" href="classhippodraw_1_1Factory.html#a8aee137075d50e6fca916a1dbfd388c3" title="Adds a prototype object to the list of prototypes.">add</a> ( fitter );
<a name="l00087"></a>00087 <span class="preprocessor">#endif</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span>  
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="keywordtype">void</span>
<a name="l00092"></a>00092 <a class="code" href="classhippodraw_1_1FitterFactory.html#a609ca20b783ec0f737beda1b2f5dd6f1" title="Sets the application&amp;#39;s default Fitter.">FitterFactory::</a>
<a name="l00093"></a><a class="code" href="classhippodraw_1_1FitterFactory.html#a609ca20b783ec0f737beda1b2f5dd6f1">00093</a> <a class="code" href="classhippodraw_1_1FitterFactory.html#a609ca20b783ec0f737beda1b2f5dd6f1" title="Sets the application&amp;#39;s default Fitter.">setDefault</a> ( <span class="keyword">const</span> std::string &amp; name )
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095   <span class="keywordtype">bool</span> yes = <a class="code" href="classhippodraw_1_1Factory.html#a49b478d74196111779fe0215e755348b" title="Returns true if prototype with name name exists in the factory, otherwise returns...">exists</a> ( name );
<a name="l00096"></a>00096 
<a name="l00097"></a>00097   <span class="keywordflow">if</span> ( yes == <span class="keyword">false</span> ) {
<a name="l00098"></a>00098     <span class="keywordtype">string</span> what ( <span class="stringliteral">&quot;FitterFactory: Fitter with name `&quot;</span> );
<a name="l00099"></a>00099     what += name;
<a name="l00100"></a>00100     what += <span class="stringliteral">&quot;&#39; does not exist.&quot;</span>;
<a name="l00101"></a>00101     <span class="keywordflow">throw</span> std::runtime_error ( what );
<a name="l00102"></a>00102   }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104   <a class="code" href="classhippodraw_1_1FitterFactory.html#a68643a9ff533e2d1da51b86acd428e57" title="The application&amp;#39;s default fitter, if non empty.">m_default</a> = name;
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;
<a name="l00108"></a>00108 <a class="code" href="classhippodraw_1_1FitterFactory.html#a452cd69f2039acb99d94724c28c2171b" title="Returns the default Fitter.">FitterFactory::</a>
<a name="l00109"></a><a class="code" href="classhippodraw_1_1FitterFactory.html#a452cd69f2039acb99d94724c28c2171b">00109</a> <a class="code" href="classhippodraw_1_1FitterFactory.html#a452cd69f2039acb99d94724c28c2171b" title="Returns the default Fitter.">getDefault</a> ()<span class="keyword"> const</span>
<a name="l00110"></a>00110 <span class="keyword"></span>{
<a name="l00111"></a>00111   <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1FitterFactory.html#a68643a9ff533e2d1da51b86acd428e57" title="The application&amp;#39;s default fitter, if non empty.">m_default</a>.empty () ) {
<a name="l00112"></a>00112     <span class="keyword">const</span> vector &lt; string &gt; &amp; fitters = <a class="code" href="classhippodraw_1_1Factory.html#ab375ca98328f5bd02d39169ca515ef9d" title="Returns the list of available prototype names.">names</a> ();
<a name="l00113"></a>00113     <span class="keywordflow">return</span> fitters.front ();
<a name="l00114"></a>00114   }
<a name="l00115"></a>00115   <span class="comment">//else</span>
<a name="l00116"></a>00116   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1FitterFactory.html#a68643a9ff533e2d1da51b86acd428e57" title="The application&amp;#39;s default fitter, if non empty.">m_default</a>;
<a name="l00117"></a>00117 }
</pre></div></div>
<hr size="1"><address style="align: right;"><small>
Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
</a> </small></address>
</body>
</html>