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

AIDA_Histogram2DIterator.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_Histogram2DIterator
00024 // 
00025 // Authors  : Lorenzo Moneta , Jakub Moscicki
00026 // Created  : Fri Oct  4 16:30:41 2002
00027 // 
00028 // Last update: Fri Oct  4 16:30:41 2002
00029 // 
00030 
00031 #include "AIDA_Histogram2DIterator.h"
00032 #include "AIDA_Function_FML/AIDA_RangeSet.h"
00033 
00034 # include "AIDA/IAxis.h"
00035 # include "AIDA/IHistogram2D.h"
00036 
00037 # include "FML/debug.h"
00038 
00039 
00040 namespace Anaphe  { 
00041   namespace AIDA_Fitter_FML { 
00042 
00043 
00044     AIDA_Histogram2DIterator::AIDA_Histogram2DIterator(const AIDA::IHistogram2D& h, int ix, int iy) : m_hist(&h), m_dim(h.dimension()), xIndex(ix), yIndex(iy)
00045     { 
00046     }
00047 
00048     AIDA_Histogram2DIterator::~AIDA_Histogram2DIterator() 
00049     {
00050     }
00051 
00052     AIDA_Histogram2DIterator::AIDA_Histogram2DIterator(const AIDA_Histogram2DIterator &) 
00053     {
00054     }
00055 
00056     AIDA_Histogram2DIterator & AIDA_Histogram2DIterator::operator = (const AIDA_Histogram2DIterator &rhs) 
00057     {
00058       if (this == &rhs) return *this;  // time saving self-test
00059       
00060       return *this;
00061     }
00062 
00063     // fill the data in the vector
00064 
00065     void AIDA_Histogram2DIterator::fillData(const std::vector<Anaphe::AIDA_Function_FML::AIDA_RangeSet * > & ranges ) 
00066     { 
00067       int n = ranges.size();
00068       if (n != m_dim) {
00069         INFO_MSG(" AIDA_Histogram2DIterator::fillData  invalid dimension for rangeset - cannot feed data in FNL"); 
00070         return; 
00071       }
00072       if (!ranges[0]) { 
00073         INFO_MSG(" AIDA_Histogram2DIterator::fillData  invalid rangeset - cannot feed data in FNL"); 
00074         return; 
00075       }
00076       if (xIndex >= m_dim || yIndex >= m_dim) { 
00077         INFO_MSG(" AIDA_Histogram2DIterator::fillData  invalid indices - cannot feed data in FNL"); 
00078         return; 
00079       }
00080                 
00081         
00082       std::auto_ptr<FML::DataVector> vptr (new FML::DataVector());
00083 
00084       std::vector<double> x(m_dim);
00085 
00086       int nPoints = 0; 
00087       for(int i = 0; i<m_hist->xAxis().bins(); ++i)
00088         {
00089           for(int j = 0; j<m_hist->yAxis().bins(); ++j)
00090             {
00091               x[xIndex] = m_hist->binMeanX(i,j);
00092               x[yIndex] = m_hist->binMeanY(i,j);
00093               if (ranges[0]->isInRange(x[0]) && ranges[1]->isInRange(x[1])) 
00094                 { 
00095                   vptr->push_back(x, m_hist->binHeight(i,j), m_hist->binError(i,j), m_hist->binError(i,j));
00096                   nPoints++;
00097                 }
00098               
00099             }
00100         }
00101       // set the range (size is number of bins) 
00102       vptr->setRange(FML::DataRange( nPoints ));
00103 
00104       setVector(vptr);
00105 
00106     }
00107   }     // end of namespace Anaphe::AIDA_Fitter_FML
00108 } 

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