Sophie

Sophie

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

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_974d432048ef135a7d3fc83794dbf3e9.html">binners</a>
  </div>
</div>
<div class="contents">
<h1>Bins2DHist.cxx</h1><a href="Bins2DHist_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00016"></a>00016 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="comment">// Include max() and min() missing from MicroSoft Visual C++.</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;msdevstudio/MSconfig.h&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="Bins2DHist_8h.html" title="hippodraw::Bins2DHist class interface">Bins2DHist.h</a>&quot;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="BinnerAxis_8h.html" title="hippodraw::BinnerAxis class interface">BinnerAxis.h</a>&quot;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <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="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="NTuple_8h.html" title="hippodraw::NTuple class interface.">datasrcs/NTuple.h</a>&quot;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;cassert&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#ifdef ITERATOR_MEMBER_DEFECT</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="keyword">using namespace </span>std;
<a name="l00034"></a>00034 <span class="preprocessor">#else</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="keyword">using</span> std::fill;
<a name="l00036"></a>00036 <span class="keyword">using</span> std::list;
<a name="l00037"></a>00037 <span class="keyword">using</span> std::sqrt;
<a name="l00038"></a>00038 <span class="keyword">using</span> std::vector;
<a name="l00039"></a>00039 <span class="preprocessor">#endif</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="keyword">using namespace </span>hippodraw;
<a name="l00042"></a>00042 
<a name="l00043"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a51f3f94874a1b78679cdf7f961ef4151">00043</a> Bins2DHist::Bins2DHist ( )
<a name="l00044"></a>00044   : <a class="code" href="classhippodraw_1_1Bins2DBase.html" title="The base class for the 2D binner hierarchy.">Bins2DBase</a> ( <span class="stringliteral">&quot;Bins2DHist&quot;</span> )
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#ac2a9b4065131a4b1449c0d15ce8b6690">00048</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a51f3f94874a1b78679cdf7f961ef4151" title="The default constructor.">Bins2DHist::Bins2DHist</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Bins2DHist.html" title="The class for the 2D histogram binning.">Bins2DHist</a> &amp; binner )
<a name="l00049"></a>00049   : <a class="code" href="classhippodraw_1_1Bins2DBase.html" title="The base class for the 2D binner hierarchy.">Bins2DBase</a>( binner ),
<a name="l00050"></a>00050     m_variance( binner.m_variance )
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052   <a class="code" href="classhippodraw_1_1Bins2DBase.html#af113be2bbd858bb78acf33de386fac3a" title="Total number of bins not including overflow and underflow.">m_num_bins</a> = binner.<a class="code" href="classhippodraw_1_1Bins2DBase.html#af113be2bbd858bb78acf33de386fac3a" title="Total number of bins not including overflow and underflow.">m_num_bins</a>;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054   <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i &lt; 3; i++ ) {
<a name="l00055"></a>00055     <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>[i] = binner.<a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>[i];
<a name="l00056"></a>00056     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>[i] = binner.<a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>[i];
<a name="l00057"></a>00057   }
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <a class="code" href="classhippodraw_1_1BinsBase.html" title="The base class for the binner hierarchy.">BinsBase</a> *
<a name="l00061"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a41d15e336355204fd336f7ef9bae6ced">00061</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a41d15e336355204fd336f7ef9bae6ced" title="The clone function returns an object of its own kind which is a copy of this object...">Bins2DHist::clone</a> ()<span class="keyword"> const</span>
<a name="l00062"></a>00062 <span class="keyword"></span>{
<a name="l00063"></a>00063   <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a51f3f94874a1b78679cdf7f961ef4151" title="The default constructor.">Bins2DHist</a> ( *<span class="keyword">this</span> );
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 
<a name="l00066"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a3a7b08e8a1b249cf62693a35e6c8622a">00066</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a3a7b08e8a1b249cf62693a35e6c8622a" title="The destructor.">Bins2DHist::~Bins2DHist</a> ()
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 <span class="keywordtype">void</span>
<a name="l00071"></a>00071 <a class="code" href="classhippodraw_1_1Bins2DHist.html#a2e834d6a95b427453d846d43949e87f7" title="Sets the number of bins on the the specified axis.">Bins2DHist::</a>
<a name="l00072"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a2e834d6a95b427453d846d43949e87f7">00072</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a2e834d6a95b427453d846d43949e87f7" title="Sets the number of bins on the the specified axis.">setNumberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7" title="Axes constants.">hippodraw::Axes::Type</a> axis, <span class="keywordtype">int</span> nb ) 
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074   assert ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> || axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<a name="l00075"></a>00075 
<a name="l00076"></a>00076   <span class="keywordflow">if</span> ( axis == <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) {
<a name="l00077"></a>00077     <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>.resize ( nb + 2 ); <span class="comment">//GB</span>
<a name="l00078"></a>00078     <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>.resize ( nb ); <span class="comment">//GB</span>
<a name="l00079"></a>00079     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a2e834d6a95b427453d846d43949e87f7" title="Sets the number of bins on the the specified axis.">Bins2DBase::setNumberOfBins</a> ( axis, nb );
<a name="l00080"></a>00080   }
<a name="l00081"></a>00081   <span class="keywordflow">else</span> { <span class="comment">// Y</span>
<a name="l00082"></a>00082     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a2e834d6a95b427453d846d43949e87f7" title="Sets the number of bins on the the specified axis.">Bins2DBase::setNumberOfBins</a> ( axis, nb );  
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     <span class="keywordtype">int</span> number_y = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<a name="l00085"></a>00085     
<a name="l00086"></a>00086     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; <span class="comment">// For Visual Studio C++ for scope bug</span>
<a name="l00087"></a>00087     <span class="keywordflow">for</span>( ; i &lt; <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>.size(); i++ ) {
<a name="l00088"></a>00088       <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i].resize( number_y + 2 );
<a name="l00089"></a>00089     }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091     <span class="keywordflow">for</span>( i = 0; i &lt; <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>.size(); i++ ) {
<a name="l00092"></a>00092       <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i].resize( number_y );
<a name="l00093"></a>00093     }
<a name="l00094"></a>00094   }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <a class="code" href="classhippodraw_1_1Bins2DHist.html#ad20897c5c8bd47f5d4005989bead0e55" title="Resets the accumulation to zero.">reset</a> ();
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#ad20897c5c8bd47f5d4005989bead0e55">00099</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Bins2DHist.html#ad20897c5c8bd47f5d4005989bead0e55" title="Resets the accumulation to zero.">Bins2DHist::reset</a> ()
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; <span class="comment">// For Visual Studio for scope bug.</span>
<a name="l00102"></a>00102   <span class="keywordflow">for</span> ( ; i &lt; <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>.size(); i++ ) {
<a name="l00103"></a>00103     fill ( <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i].begin(), <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i].end(), 0.0 );
<a name="l00104"></a>00104   }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106   <span class="keywordflow">for</span> ( i = 0; i &lt; <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>.size(); i++ ) {
<a name="l00107"></a>00107     fill ( <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i].begin(), <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i].end(), 0.0 );
<a name="l00108"></a>00108   }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   fill ( <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>, <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a> + 3, 0.0 );
<a name="l00111"></a>00111   fill ( <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>, <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a> + 3, 0.0 );
<a name="l00112"></a>00112 
<a name="l00113"></a>00113   <a class="code" href="classhippodraw_1_1BinsBase.html#ac21f18624d637a3e48f64730fb79c479" title="A flag set to true, when no accumulation has yet occurred, otherwise is set false...">m_empty</a> = <span class="keyword">true</span>;
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 
<a name="l00116"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#ab8e42c6f653d2c252e76e572b3e71ca7">00116</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab8e42c6f653d2c252e76e572b3e71ca7" title="Accumulates the data point (x, y) with weight w.">Bins2DHist::accumulate</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> wt, <span class="keywordtype">double</span> )
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118   <span class="keywordtype">int</span> i = <a class="code" href="classhippodraw_1_1Bins2DBase.html#aa5ec9a17c6690de20e10f864a77d8b1f" title="Returns the number of the bin in which the x value is situated.">binNumberX</a> ( x );
<a name="l00119"></a>00119   <span class="keywordtype">int</span> j = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a2136139233ef2ce24fdf6a90ce27713c" title="Returns the number of the bin in which the y value is situated.">binNumberY</a> ( y );
<a name="l00120"></a>00120 
<a name="l00121"></a>00121   <span class="keywordflow">if</span>( i &gt; 0 &amp;&amp; i &lt;= <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) &amp;&amp; 
<a name="l00122"></a>00122       j &gt; 0 &amp;&amp; j &lt;= <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> ) ) {
<a name="l00123"></a>00123     <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i-1][j-1] += wt * wt;
<a name="l00124"></a>00124     <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>[0] += wt;
<a name="l00125"></a>00125     <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>[1] += wt * x;
<a name="l00126"></a>00126     <a class="code" href="classhippodraw_1_1Bins2DHist.html#aa50b1180d58ffed0c5cdd579ef5d3681" title="The X moments.">m_x_moments</a>[2] += wt * x * x;
<a name="l00127"></a>00127     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>[0] += wt;
<a name="l00128"></a>00128     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>[1] += wt * y;
<a name="l00129"></a>00129     <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6f8dc48c722d594b69578249a40408ca" title="The Y moments.">m_y_moments</a>[2] += wt * y * y;
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131   <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i][j] += wt;
<a name="l00132"></a>00132 
<a name="l00133"></a>00133   <a class="code" href="classhippodraw_1_1BinsBase.html#ac21f18624d637a3e48f64730fb79c479" title="A flag set to true, when no accumulation has yet occurred, otherwise is set false...">m_empty</a> = <span class="keyword">false</span>;
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 
<a name="l00136"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a6d8a76cf5463d7850ba13bec75873deb">00136</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a6d8a76cf5463d7850ba13bec75873deb" title="Get the z value at the specified point (x,y).">Bins2DHist::getZValue</a> ( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y )<span class="keyword"> const</span>
<a name="l00137"></a>00137 <span class="keyword"></span>{
<a name="l00138"></a>00138   <span class="keywordtype">int</span> i = <a class="code" href="classhippodraw_1_1Bins2DBase.html#aa5ec9a17c6690de20e10f864a77d8b1f" title="Returns the number of the bin in which the x value is situated.">binNumberX</a>( x );
<a name="l00139"></a>00139   <span class="keywordtype">int</span> j = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a2136139233ef2ce24fdf6a90ce27713c" title="Returns the number of the bin in which the y value is situated.">binNumberY</a>( y );
<a name="l00140"></a>00140   <span class="keywordtype">double</span> widthX = <a class="code" href="classhippodraw_1_1Bins2DBase.html#abc1c0e24625021b07d639fd4fa233a9c" title="Gets the bin width of the X bin for the i bin.">binWidthX</a> ( i-1 );
<a name="l00141"></a>00141   <span class="keywordtype">double</span> widthY = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a68dab17e98e29ed3da931b30efa5a9ac" title="Gets the bin width of the Y bin for the i bin.">binWidthY</a> ( j-1 );
<a name="l00142"></a>00142   <span class="keywordtype">double</span> v = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i][j] / ( widthX * widthY );
<a name="l00143"></a>00143   <span class="keywordflow">return</span> v;
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&amp;lt;double&amp;gt; to store the column...">NTuple</a> *
<a name="l00147"></a>00147 <a class="code" href="classhippodraw_1_1Bins2DHist.html#a68e4ca34a0c4aa4d4eeaa0e521fe6386" title="Creates an NTuple.">Bins2DHist::</a>
<a name="l00148"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a68e4ca34a0c4aa4d4eeaa0e521fe6386">00148</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a68e4ca34a0c4aa4d4eeaa0e521fe6386" title="Creates an NTuple.">createNTuple</a> ()<span class="keyword"> const</span>
<a name="l00149"></a>00149 <span class="keyword"></span>{
<a name="l00150"></a>00150   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> ) * <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<a name="l00151"></a>00151   <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&amp;lt;double&amp;gt; to store the column...">NTuple</a> * ntuple = <a class="code" href="classhippodraw_1_1Bins2DBase.html#af67b204e810ea7f82cfe60d9cd8f9455" title="Prepares the NTuple.">prepareNTuple</a> ( size );
<a name="l00152"></a>00152 
<a name="l00153"></a>00153   <a class="code" href="classhippodraw_1_1Bins2DHist.html#a8442b1eaff8330d90497659f2853c5aa" title="Fills the DataSource.">fillDataSource</a> ( ntuple );
<a name="l00154"></a>00154 
<a name="l00155"></a>00155   <span class="keywordflow">return</span> ntuple;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 
<a name="l00158"></a>00158 <span class="keyword">namespace </span>dp = hippodraw::DataPoint3DTuple;
<a name="l00159"></a>00159 
<a name="l00160"></a>00160 <span class="keywordtype">void</span>
<a name="l00161"></a>00161 <a class="code" href="classhippodraw_1_1Bins2DHist.html#a8442b1eaff8330d90497659f2853c5aa" title="Fills the DataSource.">Bins2DHist::</a>
<a name="l00162"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#a8442b1eaff8330d90497659f2853c5aa">00162</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#a8442b1eaff8330d90497659f2853c5aa" title="Fills the DataSource.">fillDataSource</a> ( <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple )<span class="keyword"> const</span>
<a name="l00163"></a>00163 <span class="keyword"></span>{
<a name="l00164"></a>00164   ntuple -&gt; clear ();
<a name="l00165"></a>00165 
<a name="l00166"></a>00166   <span class="keywordtype">double</span> total = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a8e2544f7315631c6c4357d2f09bdcafc" title="Returns the true number of entries.">getNumberOfEntries</a> ();
<a name="l00167"></a>00167   <span class="keywordtype">double</span> factor = <a class="code" href="classhippodraw_1_1BinsBase.html#aa3fe89c038fc4349d4d9f41d20b2fe01" title="A flag which is set true to enable scaling the output.">m_is_scaling</a> ? <a class="code" href="classhippodraw_1_1BinsBase.html#a3fba3a52c08a77ff1127828800f5c8a3" title="The scale factor.">m_scale_factor</a> / total : 1.0;
<a name="l00168"></a>00168 
<a name="l00169"></a>00169   vector &lt; double &gt; row ( <a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15a4aa71180778b711338785695df5d7c52" title="number of columns">dp::SIZE</a> );
<a name="l00170"></a>00170 
<a name="l00171"></a>00171   <span class="keywordtype">double</span> x = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a338cb7f6876cb3c4a8cbbb5c8990642c" title="Returns the low value of the bins on the specified axis.">getLow</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> );
<a name="l00172"></a>00172 
<a name="l00173"></a>00173   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_x = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> );
<a name="l00174"></a>00174   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_y = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<a name="l00175"></a>00175 
<a name="l00176"></a>00176   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; num_x; i++ ) {
<a name="l00177"></a>00177 
<a name="l00178"></a>00178     <span class="keywordtype">double</span> widthX = <a class="code" href="classhippodraw_1_1Bins2DBase.html#abc1c0e24625021b07d639fd4fa233a9c" title="Gets the bin width of the X bin for the i bin.">binWidthX</a> ( i );
<a name="l00179"></a>00179     <span class="keywordtype">double</span> half_widthX = 0.5 * widthX;
<a name="l00180"></a>00180     x += half_widthX;
<a name="l00181"></a>00181 
<a name="l00182"></a>00182     <span class="keywordtype">double</span> y = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a338cb7f6876cb3c4a8cbbb5c8990642c" title="Returns the low value of the bins on the specified axis.">getLow</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<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> j = 0; j &lt; num_y; j++ ) {
<a name="l00185"></a>00185       <span class="keywordtype">double</span> widthY = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a68dab17e98e29ed3da931b30efa5a9ac" title="Gets the bin width of the Y bin for the i bin.">binWidthY</a> ( j ); 
<a name="l00186"></a>00186       <span class="keywordtype">double</span> half_widthY = 0.5 * widthY;
<a name="l00187"></a>00187       y += half_widthY;
<a name="l00188"></a>00188 
<a name="l00189"></a>00189       <span class="keywordtype">double</span> v = factor * ( <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i+1][j+1] / ( widthX * widthY ) );
<a name="l00190"></a>00190       <span class="keywordtype">double</span> verr = factor * ( sqrt ( <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i][j] ) );
<a name="l00191"></a>00191 
<a name="l00192"></a>00192       row[<a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">dp::X</a>] = x;
<a name="l00193"></a>00193       row[<a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">dp::Y</a>] = y;
<a name="l00194"></a>00194       row[<a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7aa70478ce277ffc322f8e1e3418e07355" title="Z axis.">dp::Z</a>] = v;
<a name="l00195"></a>00195       row [<a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15ac577aa01d3f00f9cfae6e981756f5402" title="error on X or half bin width">dp::XERR</a>] = half_widthX;
<a name="l00196"></a>00196       row [<a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15a877f1ecdc13e795de8b440216711b10d" title="error on Y">dp::YERR</a>] = half_widthY;
<a name="l00197"></a>00197       row [<a class="code" href="namespacehippodraw_1_1DataPoint3DTuple.html#ae78e6e11a40e6dba1bae097358f97d15add01b24f343be1cc937a121b6bb57f66" title="error on Z">dp::ZERR</a>] = verr;
<a name="l00198"></a>00198 
<a name="l00199"></a>00199       ntuple -&gt; addRow ( row );
<a name="l00200"></a>00200 
<a name="l00201"></a>00201       y += half_widthY;
<a name="l00202"></a>00202     }
<a name="l00203"></a>00203     x += half_widthX;
<a name="l00204"></a>00204   }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206   vector &lt; unsigned int &gt; <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a> ( 3 );
<a name="l00207"></a>00207   shape[0] = num_x;
<a name="l00208"></a>00208   shape[1] = num_y;
<a name="l00209"></a>00209   shape[2] = <a class="code" href="namespacehippodraw_1_1DataPoint2DTuple.html#ae78e6e11a40e6dba1bae097358f97d15a4aa71180778b711338785695df5d7c52" title="number of columns">dp::SIZE</a>;
<a name="l00210"></a>00210 
<a name="l00211"></a>00211   ntuple -&gt; setShape ( shape );
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214 <span class="keywordtype">void</span>
<a name="l00215"></a>00215 <a class="code" href="classhippodraw_1_1Bins2DHist.html#ac667673ef9254d312f398893f7bf2c53" title="Sets the contents of the bins from the ntuple.">Bins2DHist::</a>
<a name="l00216"></a><a class="code" href="classhippodraw_1_1Bins2DHist.html#ac667673ef9254d312f398893f7bf2c53">00216</a> <a class="code" href="classhippodraw_1_1Bins2DHist.html#ac667673ef9254d312f398893f7bf2c53" title="Sets the contents of the bins from the ntuple.">setBinContents</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ntuple )
<a name="l00217"></a>00217 {
<a name="l00218"></a>00218   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_x = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a58833a3110c570fb05130d40c365d1e4" title="X axis.">Axes::X</a> );
<a name="l00219"></a>00219   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_y = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a7fbec12f37a3148838ecd507a0d6f5b9" title="Returns the number of bins.">numberOfBins</a> ( <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a5596231eabd6cf29050967d5ac83ad84" title="Y axis.">Axes::Y</a> );
<a name="l00220"></a>00220   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> r = 0;
<a name="l00221"></a>00221   <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; num_x; i++ ) {
<a name="l00222"></a>00222     <span class="keywordtype">double</span> widthX = <a class="code" href="classhippodraw_1_1Bins2DBase.html#abc1c0e24625021b07d639fd4fa233a9c" title="Gets the bin width of the X bin for the i bin.">binWidthX</a> ( i );
<a name="l00223"></a>00223     <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; num_y; j++ ) {
<a name="l00224"></a>00224       <span class="keywordtype">double</span> widthY = <a class="code" href="classhippodraw_1_1Bins2DBase.html#a68dab17e98e29ed3da931b30efa5a9ac" title="Gets the bin width of the Y bin for the i bin.">binWidthY</a> ( j );
<a name="l00225"></a>00225       <span class="keyword">const</span> vector &lt; double &gt; &amp; row = ntuple -&gt; getRow ( r++ );
<a name="l00226"></a>00226       <span class="keywordtype">double</span> value = row [ <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7aa70478ce277ffc322f8e1e3418e07355" title="Z axis.">dp::Z</a> ];
<a name="l00227"></a>00227       <span class="keywordtype">double</span> verr = row [ <a class="code" href="namespacehippodraw_1_1DataPoint3DTuple.html#ae78e6e11a40e6dba1bae097358f97d15add01b24f343be1cc937a121b6bb57f66" title="error on Z">dp::ZERR</a> ];
<a name="l00228"></a>00228       <a class="code" href="classhippodraw_1_1Bins2DBase.html#a287a9a0d703b83be85508774314e8073" title="The accumulated sum of weights.">m_data</a>[i+1][j+1] = value * ( widthX * widthY );
<a name="l00229"></a>00229       <a class="code" href="classhippodraw_1_1Bins2DHist.html#ab59bf72488b8afdf39361d289b9e9232" title="The accumulated square of the weights.">m_variance</a>[i][j] = verr * verr;
<a name="l00230"></a>00230     }
<a name="l00231"></a>00231   }
<a name="l00232"></a>00232 }
</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>