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

AIDA_DataPointSetIterator.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_DataPointSetIterator
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_DataPointSetIterator.h"
00032 #include "AIDA_Function_FML/AIDA_RangeSet.h"
00033 
00034 # include "AIDA/IAxis.h"
00035 # include "AIDA/IDataPointSet.h"
00036 # include "AIDA/IDataPoint.h"
00037 # include "AIDA/IMeasurement.h"
00038 
00039 # include "FML/debug.h"
00040 
00041 #ifdef __sun
00042 #include <assert.h>
00043 #endif
00044 
00045 
00046 
00047 namespace Anaphe  { 
00048   namespace AIDA_Fitter_FML { 
00049 
00050 
00051     AIDA_DataPointSetIterator::AIDA_DataPointSetIterator(const AIDA::IDataPointSet& dps, std::vector<int>  indeces, int valIndex) : 
00052       m_data(&dps) , 
00053       m_indeces(indeces), 
00054       m_val_index(valIndex)
00055     { 
00056       m_dim = indeces.size();
00057       assert (m_dim < m_data->dimension() ); 
00058     }
00059 
00060     AIDA_DataPointSetIterator::~AIDA_DataPointSetIterator() 
00061     {
00062     }
00063 
00064     AIDA_DataPointSetIterator::AIDA_DataPointSetIterator(const AIDA_DataPointSetIterator &) 
00065     {
00066     }
00067 
00068     AIDA_DataPointSetIterator & AIDA_DataPointSetIterator::operator = (const AIDA_DataPointSetIterator &rhs) 
00069     {
00070       if (this == &rhs) return *this;  // time saving self-test
00071       
00072       return *this;
00073     }
00074 
00075     // fill the data in the vector
00076 
00077     void AIDA_DataPointSetIterator::fillData(const std::vector<Anaphe::AIDA_Function_FML::AIDA_RangeSet * > & ranges) 
00078     { 
00079       int n = ranges.size();
00080       if (n != m_dim) {
00081         INFO_MSG(" AIDA_DataPointSetIterator::fillData  invalid dimension for rangeset - cannot feed data in FNL"); 
00082         return; 
00083       }
00084       // check calidity of range pointers  
00085       for (int i = 0; i < m_dim; ++i) { 
00086         if (!ranges[i]) { 
00087           INFO_MSG(" AIDA_DataPointSetIterator::fillData  invalid rangeset - cannot feed data in FNL"); 
00088           return; 
00089         }
00090       }
00091         
00092       std::auto_ptr<FML::DataVector> vptr (new FML::DataVector());
00093 
00094       std::vector<double> x(m_dim);
00095 
00096           
00097       // loop on points in the set 
00098       int nPointsInRange = 0; 
00099       for(int ipoint = 0; ipoint < m_data->size(); ++ipoint)
00100         {
00101           const AIDA::IDataPoint* p = m_data->point( ipoint ); 
00102           // loop on dimension to get coordinates 
00103           bool validPoint = true; 
00104           for (int idim = 0; idim < m_dim; ++idim) 
00105             {
00106               const AIDA::IMeasurement* m = p->coordinate( m_indeces[idim] );
00107               x[idim] = m->value(); 
00108               validPoint = validPoint && ranges[idim]->isInRange(x[idim]);
00109             }
00110           // if range is OK for all points ...
00111           if (validPoint) { 
00112             // now get values to be fitter and errors 
00113             const AIDA::IMeasurement* m = p->coordinate(m_val_index); 
00114             double value = m->value(); 
00115             double eplus = m->errorPlus(); 
00116             double eminus = m->errorMinus(); 
00117             
00118             vptr->push_back(x, value, eplus, eminus);
00119             nPointsInRange++;
00120           }
00121               
00122         }
00123 
00124       // set the FML range (size is number of points in range) 
00125       vptr->setRange(FML::DataRange( nPointsInRange ));
00126 
00127       setVector(vptr);
00128 
00129     }
00130   }     // end of namespace Anaphe::AIDA_Fitter_FML
00131 } 

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