Sophie

Sophie

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

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>NTupleFCN.cxx</h1><a href="NTupleFCN_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="preprocessor">#ifdef _MSC_VER</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#include &quot;msdevstudio/MSconfig.h&quot;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#endif</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="NTupleFCN_8h.html" title="hippodraw::NTupleFCN class interface">NTupleFCN.h</a>&quot;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="DataPointTuple_8h.html" title="hippodraw::DataPointTuple namespace interface">datasrcs/DataPointTuple.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="DataSource_8h.html" title="hippodraw::DataSource class interface.">datasrcs/DataSource.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="TupleCut_8h.html" title="hippodraw::TupleCut class interface">datasrcs/TupleCut.h</a>&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="FunctionBase_8h.html" title="hippodraw::FunctionBase class interface">functions/FunctionBase.h</a>&quot;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;functional&gt;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">using</span> std::bind2nd;
<a name="l00028"></a>00028 <span class="keyword">using</span> std::count;
<a name="l00029"></a>00029 <span class="keyword">using</span> std::find_if;
<a name="l00030"></a>00030 <span class="keyword">using</span> std::not_equal_to;
<a name="l00031"></a>00031 <span class="keyword">using</span> std::vector;
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">using namespace </span>hippodraw;
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 NTupleFCN::
<a name="l00036"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#af09a45c3d1e12e895079669fe4e835de">00036</a> NTupleFCN ( )
<a name="l00037"></a>00037   :  m_fit_cut ( 0 ),
<a name="l00038"></a>00038      m_ntuple ( 0 ),
<a name="l00039"></a>00039      m_has_errors ( false ),
<a name="l00040"></a>00040      m_fit_range ( false )
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <a class="code" href="classhippodraw_1_1NTupleFCN.html#af09a45c3d1e12e895079669fe4e835de" title="The default constructor.">NTupleFCN::</a>
<a name="l00045"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a5bc504b6697f54dcb2308195c6ebfde9">00045</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#af09a45c3d1e12e895079669fe4e835de" title="The default constructor.">NTupleFCN</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1NTupleFCN.html" title="A derived class of StatedFCN This class gets its data points from a DataSource.">NTupleFCN</a> &amp; fcn )
<a name="l00046"></a>00046   : <a class="code" href="classhippodraw_1_1StatedFCN.html" title="A derived class for FCNBase class.">StatedFCN</a> ( fcn ),
<a name="l00047"></a>00047     m_fit_cut ( 0 ),
<a name="l00048"></a>00048     m_ntuple ( fcn.m_ntuple ),
<a name="l00049"></a>00049     m_has_errors ( fcn.m_has_errors ),
<a name="l00050"></a>00050     m_fit_range ( fcn.m_fit_range )
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="keywordtype">void</span>
<a name="l00055"></a>00055 <a class="code" href="classhippodraw_1_1NTupleFCN.html#a02ce45a9049afed1faf35b2f9159f6c6" title="Makes a copy of the relevant attributes from other object.">NTupleFCN::</a>
<a name="l00056"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a02ce45a9049afed1faf35b2f9159f6c6">00056</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#a02ce45a9049afed1faf35b2f9159f6c6" title="Makes a copy of the relevant attributes from other object.">copyFrom</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1StatedFCN.html" title="A derived class for FCNBase class.">StatedFCN</a> * base )
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058   <a class="code" href="classhippodraw_1_1NTupleFCN.html#a02ce45a9049afed1faf35b2f9159f6c6" title="Makes a copy of the relevant attributes from other object.">StatedFCN::copyFrom</a> ( base );
<a name="l00059"></a>00059 
<a name="l00060"></a>00060   <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1NTupleFCN.html" title="A derived class of StatedFCN This class gets its data points from a DataSource.">NTupleFCN</a> * fcn = dynamic_cast &lt; <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1NTupleFCN.html" title="A derived class of StatedFCN This class gets its data points from a DataSource.">NTupleFCN</a> * &gt; ( base );
<a name="l00061"></a>00061   <span class="keywordflow">if</span> ( fcn != 0 ) {
<a name="l00062"></a>00062     <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a>    = fcn -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a>;
<a name="l00063"></a>00063     <a class="code" href="classhippodraw_1_1NTupleFCN.html#a6023ee56bf081c5af1008dbbf9be9bea" title="Set to true if the fitting range is turn on.">m_fit_range</a>  = fcn -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#a6023ee56bf081c5af1008dbbf9be9bea" title="Set to true if the fitting range is turn on.">m_fit_range</a>;
<a name="l00064"></a>00064     <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a>    = fcn -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a>;
<a name="l00065"></a>00065     <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a>     = fcn -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a>;
<a name="l00066"></a>00066     <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> = fcn -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a>;
<a name="l00067"></a>00067   }
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 <span class="keyword">namespace </span>dp2 = hippodraw::DataPoint2DTuple;
<a name="l00071"></a>00071 <span class="keyword">namespace </span>dp3 = hippodraw::DataPoint3DTuple;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="keywordtype">void</span>
<a name="l00074"></a>00074 <a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91" title="Sets the data source.">NTupleFCN::</a>
<a name="l00075"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91">00075</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91" title="Sets the data source.">setDataSource</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple )
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = ntuple -&gt; columns ();
<a name="l00078"></a>00078   vector &lt; int &gt; indices ( size );
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; size; i++ ) {
<a name="l00081"></a>00081     indices [i] = i;
<a name="l00082"></a>00082   }
<a name="l00083"></a>00083 
<a name="l00084"></a>00084   <a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91" title="Sets the data source.">setDataSource</a> ( ntuple, -1, indices );
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="keywordtype">void</span>
<a name="l00088"></a>00088 <a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91" title="Sets the data source.">NTupleFCN::</a>
<a name="l00089"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a373abd043d2fb5e4debf05178bf61145">00089</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#af5e61f87813b72805dbd38266f4d5a91" title="Sets the data source.">setDataSource</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple, 
<a name="l00090"></a>00090                 <span class="keywordtype">int</span> dimension,
<a name="l00091"></a>00091                 <span class="keyword">const</span> std::vector &lt; int &gt; &amp; indices )
<a name="l00092"></a>00092 {
<a name="l00093"></a>00093   <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> = ntuple;
<a name="l00094"></a>00094   <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> = indices;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="keywordtype">int</span>
<a name="l00098"></a>00098 <a class="code" href="classhippodraw_1_1NTupleFCN.html#a3275594690ef932cc5ae37cdda51afab" title="Returns the index to the column containing error on the value coordinate.">NTupleFCN::</a>
<a name="l00099"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a3275594690ef932cc5ae37cdda51afab">00099</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#a3275594690ef932cc5ae37cdda51afab" title="Returns the index to the column containing error on the value coordinate.">getErrorColumn</a> ()<span class="keyword"> const</span>
<a name="l00100"></a>00100 <span class="keyword"></span>{
<a name="l00101"></a>00101   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dim = ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a>.size() -2 ) / 2;
<a name="l00102"></a>00102   <span class="keywordtype">int</span> ie = <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> [ 2 * dim + 1 ];
<a name="l00103"></a>00103 
<a name="l00104"></a>00104   <span class="keywordflow">return</span> ie;
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 <span class="keywordtype">bool</span>
<a name="l00108"></a>00108 <a class="code" href="classhippodraw_1_1NTupleFCN.html#adb98076564836c612034e8ab510afc4e" title="Examines state of error bars.">NTupleFCN::</a>
<a name="l00109"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#adb98076564836c612034e8ab510afc4e">00109</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#adb98076564836c612034e8ab510afc4e" title="Examines state of error bars.">hasErrors</a> ( )<span class="keyword"> const</span>
<a name="l00110"></a>00110 <span class="keyword"></span>{
<a name="l00111"></a>00111   <span class="keywordtype">bool</span> yes = <span class="keyword">false</span>;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ie = <a class="code" href="classhippodraw_1_1NTupleFCN.html#a3275594690ef932cc5ae37cdda51afab" title="Returns the index to the column containing error on the value coordinate.">getErrorColumn</a> ();
<a name="l00114"></a>00114   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> cols = <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> -&gt; columns ();
<a name="l00115"></a>00115   <span class="keywordflow">if</span> ( ie &lt; cols ) {
<a name="l00116"></a>00116     <span class="keyword">const</span> vector &lt; double &gt; &amp; errors = <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> -&gt; getColumn ( ie );
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     <span class="keywordflow">if</span> ( errors.empty() ) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120     vector &lt; double &gt;::const_iterator first
<a name="l00121"></a>00121       = find_if ( errors.begin(), errors.end (),
<a name="l00122"></a>00122                   bind2nd ( not_equal_to &lt; double &gt; (), 0.0 ) );
<a name="l00123"></a>00123     
<a name="l00124"></a>00124     yes = first != errors.end ();
<a name="l00125"></a>00125   }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127   <span class="keywordflow">return</span> yes;
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 <span class="keywordtype">bool</span>
<a name="l00131"></a>00131 <a class="code" href="classhippodraw_1_1NTupleFCN.html#ab16b2e55114812f533fd0259c8f72084" title="Sets the use of errors on the data point.">NTupleFCN::</a>
<a name="l00132"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#ab16b2e55114812f533fd0259c8f72084">00132</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#ab16b2e55114812f533fd0259c8f72084" title="Sets the use of errors on the data point.">setUseErrors</a> ( <span class="keywordtype">bool</span> yes )
<a name="l00133"></a>00133 {
<a name="l00134"></a>00134   <span class="keywordtype">bool</span> didit = <span class="keyword">false</span>;
<a name="l00135"></a>00135   <span class="keywordflow">if</span> ( yes ) {
<a name="l00136"></a>00136     <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#adb98076564836c612034e8ab510afc4e" title="Examines state of error bars.">hasErrors</a> () ) {
<a name="l00137"></a>00137       <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> = <span class="keyword">true</span>;
<a name="l00138"></a>00138       didit = <span class="keyword">true</span>;
<a name="l00139"></a>00139     }
<a name="l00140"></a>00140     <span class="keywordflow">else</span> <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> = <span class="keyword">false</span>;
<a name="l00141"></a>00141   }
<a name="l00142"></a>00142   <span class="keywordflow">else</span> {
<a name="l00143"></a>00143     <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> = <span class="keyword">false</span>;
<a name="l00144"></a>00144       didit = <span class="keyword">true</span>;
<a name="l00145"></a>00145   }
<a name="l00146"></a>00146   <span class="keywordflow">return</span> didit;
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149 <span class="keywordtype">bool</span>
<a name="l00150"></a>00150 <a class="code" href="classhippodraw_1_1NTupleFCN.html#a5db61f264b6fbebf40b61faedae06dc6" title="Gets the use of errors.">NTupleFCN::</a>
<a name="l00151"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a5db61f264b6fbebf40b61faedae06dc6">00151</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#a5db61f264b6fbebf40b61faedae06dc6" title="Gets the use of errors.">getUseErrors</a> ()<span class="keyword"> const</span>
<a name="l00152"></a>00152 <span class="keyword"></span>{
<a name="l00153"></a>00153   <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a>;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 
<a name="l00156"></a>00156 <span class="keywordtype">int</span>
<a name="l00157"></a>00157 <a class="code" href="classhippodraw_1_1NTupleFCN.html#a4fd39d150f1dc0c6313d5c633aa3137a" title="Calculates the number of degrees of freedom.">NTupleFCN::</a>
<a name="l00158"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a4fd39d150f1dc0c6313d5c633aa3137a">00158</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#a4fd39d150f1dc0c6313d5c633aa3137a" title="Calculates the number of degrees of freedom.">degreesOfFreedom</a> ()<span class="keyword"> const</span>
<a name="l00159"></a>00159 <span class="keyword"></span>{
<a name="l00160"></a>00160   <span class="keywordtype">int</span> ie = <a class="code" href="classhippodraw_1_1NTupleFCN.html#a3275594690ef932cc5ae37cdda51afab" title="Returns the index to the column containing error on the value coordinate.">getErrorColumn</a> ();
<a name="l00161"></a>00161 
<a name="l00162"></a>00162   <span class="keyword">const</span> vector &lt; double &gt; &amp; errors = <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> -&gt; getColumn ( ie );
<a name="l00163"></a>00163   <span class="keywordtype">int</span> number_points = errors.size();
<a name="l00164"></a>00164   <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> ) {
<a name="l00165"></a>00165     <span class="keywordtype">int</span> zeros = count ( errors.begin(), errors.end(), 0.0 );
<a name="l00166"></a>00166     number_points -= zeros;
<a name="l00167"></a>00167   }
<a name="l00168"></a>00168 
<a name="l00169"></a>00169   vector&lt; double &gt; free_parms;
<a name="l00170"></a>00170   <span class="keywordflow">return</span> number_points - <a class="code" href="classhippodraw_1_1StatedFCN.html#ac9e48046c9ded89ff309004c57189984" title="Returns the number of free parameters.">getNumberFreeParms</a> ();
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="keywordtype">void</span> 
<a name="l00174"></a>00174 <a class="code" href="classhippodraw_1_1NTupleFCN.html#afafbfdc4f22ec4aa3fa7f06026886d9c" title="Resets the matrix alpha and the vector beta.">NTupleFCN::</a>
<a name="l00175"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#afafbfdc4f22ec4aa3fa7f06026886d9c">00175</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#afafbfdc4f22ec4aa3fa7f06026886d9c" title="Resets the matrix alpha and the vector beta.">reset</a> ( std::vector &lt; std::vector &lt; double &gt; &gt; &amp; alpha,
<a name="l00176"></a>00176         std::vector &lt; double &gt; &amp; beta,
<a name="l00177"></a>00177         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> )
<a name="l00178"></a>00178 {
<a name="l00179"></a>00179   beta.clear ();
<a name="l00180"></a>00180   beta.resize ( size, 0.0 );
<a name="l00181"></a>00181 
<a name="l00182"></a>00182   alpha.resize ( size );
<a name="l00183"></a>00183 
<a name="l00184"></a>00184   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; alpha.size (); i++ ) {
<a name="l00185"></a>00185     alpha[i].clear ();
<a name="l00186"></a>00186     alpha[i].resize ( size, 0.0 );
<a name="l00187"></a>00187   }
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 
<a name="l00192"></a>00192 <span class="keywordtype">void</span>
<a name="l00193"></a>00193 <a class="code" href="classhippodraw_1_1NTupleFCN.html#ac9f4cc0cbf8ed2377d6663e3d34c2ce7" title="Calculates alpha and beta.">NTupleFCN::</a>
<a name="l00194"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#ac9f4cc0cbf8ed2377d6663e3d34c2ce7">00194</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#ac9f4cc0cbf8ed2377d6663e3d34c2ce7" title="Calculates alpha and beta.">calcAlphaBeta</a> ( std::vector &lt; std::vector &lt; double &gt; &gt; &amp; alpha,
<a name="l00195"></a>00195                 std::vector &lt; double &gt; &amp; beta )
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197   <span class="keywordtype">int</span> ix = <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> [ <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">dp2::X</a> ];
<a name="l00198"></a>00198   <span class="keywordtype">int</span> iy = <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> [ <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">dp2::Y</a> ];
<a name="l00199"></a>00199   <span class="keywordtype">int</span> ie = <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> [ <a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15a877f1ecdc13e795de8b440216711b10d" title="error on Y">dp2::YERR</a> ];
<a name="l00200"></a>00200   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_parms = <a class="code" href="classhippodraw_1_1StatedFCN.html#ac9e48046c9ded89ff309004c57189984" title="Returns the number of free parameters.">getNumberFreeParms</a> ();
<a name="l00201"></a>00201   <a class="code" href="classhippodraw_1_1NTupleFCN.html#afafbfdc4f22ec4aa3fa7f06026886d9c" title="Resets the matrix alpha and the vector beta.">reset</a> ( alpha, beta, num_parms );
<a name="l00202"></a>00202 
<a name="l00203"></a>00203   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rows = <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> -&gt; rows ();
<a name="l00204"></a>00204   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; rows; i++ ) {
<a name="l00205"></a>00205     <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#a44e55e241a398543c0dc652efae34313" title="Returns true if the DataSource row row is within the fit Range.">acceptRow</a> ( i ) ) {
<a name="l00206"></a>00206       <span class="keyword">const</span> vector &lt; double &gt; &amp; row = <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a> -&gt; getRow ( i );
<a name="l00207"></a>00207 
<a name="l00208"></a>00208       <span class="keywordtype">double</span> err = ie &lt; 0 ? 0. : row [ ie ];
<a name="l00209"></a>00209       <span class="keywordflow">if</span> ( err == 0.0 &amp;&amp; <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> ) <span class="keywordflow">continue</span>;
<a name="l00210"></a>00210       <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#affc2bff497fb8adbfc7c3f2ed770f13e" title="Error use flag.">m_has_errors</a> == <span class="keyword">false</span> ) err = 1.0;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212       <span class="keywordtype">double</span> x = row [ ix ];
<a name="l00213"></a>00213       <span class="keywordtype">double</span> y = row [ iy ];
<a name="l00214"></a>00214 
<a name="l00215"></a>00215       <span class="keywordtype">double</span> y_diff = y - <a class="code" href="classhippodraw_1_1StatedFCN.html#a8dc0ee286cf84b5835db9b75cb771cf4" title="A pointer to the model function to be used in fitting.">m_function</a> -&gt; <a class="code" href="classhippodraw_1_1StatedFCN.html#a2c182d63f5d59fe955fb4b3376cc73b3" title="Sets the model function parameters to parms and returns the objective value.">operator () </a>( x );
<a name="l00216"></a>00216       vector &lt; double &gt; derives;
<a name="l00217"></a>00217       <a class="code" href="classhippodraw_1_1StatedFCN.html#a003a278024cb1697a7da7693cb173e13" title="Clears and fills the vector with the derivatives of the function a coordinate value...">fillFreeDerivatives</a> ( derives, x );
<a name="l00218"></a>00218 
<a name="l00219"></a>00219       <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; num_parms; j++ ) {
<a name="l00220"></a>00220         <span class="keywordtype">double</span> t = derives[j] / ( err * err );
<a name="l00221"></a>00221 
<a name="l00222"></a>00222         <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0; k &lt;= j; k++ ) {
<a name="l00223"></a>00223           alpha[j][k] = alpha[j][k] + t * derives[k];
<a name="l00224"></a>00224         }
<a name="l00225"></a>00225 
<a name="l00226"></a>00226         beta[j] += t * y_diff;
<a name="l00227"></a>00227       }
<a name="l00228"></a>00228     }
<a name="l00229"></a>00229   }
<a name="l00230"></a>00230 }
<a name="l00231"></a>00231 
<a name="l00234"></a>00234 <span class="keywordtype">void</span>
<a name="l00235"></a>00235 <a class="code" href="classhippodraw_1_1NTupleFCN.html#af6777101133629cf4ec9665cb87692bf" title="Sets the cut to limit range of fitting.">NTupleFCN::</a>
<a name="l00236"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#af6777101133629cf4ec9665cb87692bf">00236</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#af6777101133629cf4ec9665cb87692bf" title="Sets the cut to limit range of fitting.">setFitCut</a> ( <a class="code" href="classhippodraw_1_1TupleCut.html" title="The class expresses a cut on a DataSource, i.e.">TupleCut</a> * cut )
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238   <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a> = cut;
<a name="l00239"></a>00239 
<a name="l00240"></a>00240   <span class="keywordflow">if</span> ( cut != 0 ) {
<a name="l00241"></a>00241     <span class="keywordtype">int</span> ix = <a class="code" href="classhippodraw_1_1NTupleFCN.html#affcdb9f95b800be8ea6df2cb4041f31e" title="The indexes into the DataSource.">m_indices</a> [ <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">dp2::X</a> ];
<a name="l00242"></a>00242     cut -&gt; setColumn ( ix );
<a name="l00243"></a>00243   }
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 <span class="keywordtype">void</span>
<a name="l00247"></a>00247 <a class="code" href="classhippodraw_1_1NTupleFCN.html#ae9ffca067177b475c7b4d334a9e0ecec" title="Sets use of a fitting range on or off.">NTupleFCN::</a>
<a name="l00248"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#ae9ffca067177b475c7b4d334a9e0ecec">00248</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#ae9ffca067177b475c7b4d334a9e0ecec" title="Sets use of a fitting range on or off.">setFitRange</a> ( <span class="keywordtype">bool</span> yes )
<a name="l00249"></a>00249 {
<a name="l00250"></a>00250   <a class="code" href="classhippodraw_1_1NTupleFCN.html#a6023ee56bf081c5af1008dbbf9be9bea" title="Set to true if the fitting range is turn on.">m_fit_range</a> = yes;
<a name="l00251"></a>00251 }
<a name="l00252"></a>00252 
<a name="l00253"></a>00253 <span class="keywordtype">bool</span>
<a name="l00254"></a>00254 <a class="code" href="classhippodraw_1_1NTupleFCN.html#a44e55e241a398543c0dc652efae34313" title="Returns true if the DataSource row row is within the fit Range.">NTupleFCN::</a>
<a name="l00255"></a><a class="code" href="classhippodraw_1_1NTupleFCN.html#a44e55e241a398543c0dc652efae34313">00255</a> <a class="code" href="classhippodraw_1_1NTupleFCN.html#a44e55e241a398543c0dc652efae34313" title="Returns true if the DataSource row row is within the fit Range.">acceptRow</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> row )<span class="keyword"> const</span>
<a name="l00256"></a>00256 <span class="keyword"></span>{
<a name="l00257"></a>00257     <span class="keywordtype">bool</span> yes = <span class="keyword">true</span>;
<a name="l00258"></a>00258     <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a> != 0 &amp;&amp;
<a name="l00259"></a>00259          <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a> -&gt; isEnabled () &amp;&amp;
<a name="l00260"></a>00260          <a class="code" href="classhippodraw_1_1NTupleFCN.html#a6023ee56bf081c5af1008dbbf9be9bea" title="Set to true if the fitting range is turn on.">m_fit_range</a> ) {
<a name="l00261"></a>00261       yes = <a class="code" href="classhippodraw_1_1NTupleFCN.html#af7b43e96349221162471d4c8bd998bd9" title="The cut that manages the range on X to be used for fitting.">m_fit_cut</a> -&gt; <a class="code" href="classhippodraw_1_1NTupleFCN.html#a44e55e241a398543c0dc652efae34313" title="Returns true if the DataSource row row is within the fit Range.">acceptRow</a> ( <a class="code" href="classhippodraw_1_1NTupleFCN.html#aa4ce14472599ca738e3caba3e166be12" title="The data source containing the data points for the fitter.">m_ntuple</a>, row );
<a name="l00262"></a>00262     }
<a name="l00263"></a>00263 
<a name="l00264"></a>00264     <span class="keywordflow">return</span> yes;
<a name="l00265"></a>00265 }
</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>