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

AIDA_FitData.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_FitData
00024 // 
00025 // Authors  : Lorenzo Moneta , Jakub Moscicki
00026 // Created  : Fri Oct  4 14:53:45 2002
00027 // 
00028 // Last update: Fri Oct  4 14:53:45 2002
00029 // 
00030 
00031 
00032 #include "AIDA_FitData.h"
00033 #include "AIDA_Dev/IDevFitDataIterator.h"
00034 #include "AIDA_Dev/IDevFitter.h"
00035 
00036 #include "AIDA/IHistogram1D.h"
00037 #include "AIDA/IProfile1D.h"
00038 #include "AIDA/IDataPointSet.h"
00039 
00040 #include "AIDA_Histogram1DIterator.h"
00041 #include "AIDA_Histogram2DIterator.h"
00042 #include "AIDA_Histogram3DIterator.h"
00043 #include "AIDA_Profile1DIterator.h"
00044 #include "AIDA_Profile2DIterator.h"
00045 #include "AIDA_Cloud1DIterator.h"
00046 #include "AIDA_Cloud2DIterator.h"
00047 #include "AIDA_Cloud3DIterator.h"
00048 #include "AIDA_TupleIterator.h"
00049 #include "AIDA_DataPointSetIterator.h"
00050 #include "AIDA_Function_FML/AIDA_RangeSet.h"
00051 
00052 //# include "AIDA/ITuple.h"
00053 #include "AIDA/IEvaluator.h"
00054 
00055 #include "FML/debug.h"
00056 
00057 
00058 namespace Anaphe  { 
00059   namespace AIDA_Fitter_FML { 
00060 
00061 
00062     AIDA_FitData::AIDA_FitData() 
00063     {
00064       // initialize pointer 
00065       m_data_itr = 0; 
00066       m_fitType = 0; 
00067     }
00068 
00069     AIDA_FitData::~AIDA_FitData() 
00070     {
00071       // call reset before 
00072       reset(); 
00073     }
00074 
00075     AIDA_FitData::AIDA_FitData(const AIDA_FitData &) 
00076     {
00077     }
00078 
00079     AIDA_FitData & AIDA_FitData::operator = (const AIDA_FitData &rhs) 
00080     {
00081       if (this == &rhs) return *this;  // time saving self-test
00082       
00083       return *this;
00084     }
00085 
00086 
00087     bool AIDA_FitData::create1DConnection(const AIDA::IHistogram1D & h)
00088     {
00089       // reset existing connections before creating new one
00090       reset();
00091       
00092       m_dim = 1;
00093       m_data_itr =  new AIDA_Histogram1DIterator(h); 
00094 
00095       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00096  
00097       m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00098 
00099       return true; 
00100     }
00101 
00102     bool AIDA_FitData::create1DConnection(const AIDA::ICloud1D & c)
00103     { 
00104       // reset existing connections before creating new one
00105       reset();
00106       
00107       m_dim = 1;
00108       m_data_itr =  new AIDA_Cloud1DIterator(c); 
00109 
00110       m_fitType = AIDA::Dev::IDevFitter::UNBINNED_FIT;
00111  
00112       m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00113 
00114       return true; 
00115     }
00116 
00117     bool AIDA_FitData::create1DConnection(const AIDA::IProfile1D & p)
00118     { 
00119       // reset existing connections before creating new one
00120       reset();
00121       
00122       m_dim = 1;
00123       m_data_itr =  new AIDA_Profile1DIterator(p); 
00124       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00125  
00126       m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet());      
00127       return true; 
00128     }
00129 
00130     bool AIDA_FitData::create1DConnection(const AIDA::IDataPointSet & dp, int xIndex, int valIndex)
00131     {
00132       std::vector<int> indeces(1); 
00133       indeces[0] = xIndex; 
00134       return createConnection(dp,indeces,valIndex); 
00135     }
00136     
00137     bool AIDA_FitData::create2DConnection(const AIDA::IHistogram2D & h)
00138     { 
00139       return create2DConnection(h,0,1); 
00140     }
00141     bool AIDA_FitData::create2DConnection(const AIDA::IHistogram2D & h, int xIndex, int yIndex)
00142     { 
00143       // reset existing connections before creating new one
00144       reset();
00145       
00146       m_dim = 2;
00147       m_data_itr =  new AIDA_Histogram2DIterator(h, xIndex, yIndex); 
00148       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00149 
00150       for (int i = 0; i < m_dim; ++i) 
00151         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00152      
00153       return true; 
00154 
00155     }
00156     bool AIDA_FitData::create2DConnection(const AIDA::ICloud2D & c)
00157     {
00158       return create2DConnection(c,0,1); 
00159     }
00160     bool AIDA_FitData::create2DConnection(const AIDA::ICloud2D & c, int xIndex, int yIndex)
00161     { 
00162       reset();
00163       
00164       m_dim = 2;
00165       m_data_itr =  new AIDA_Cloud2DIterator(c, xIndex, yIndex); 
00166       m_fitType = AIDA::Dev::IDevFitter::UNBINNED_FIT;
00167 
00168       for (int i = 0; i < m_dim; ++i) 
00169         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00170      
00171       return true; 
00172     }
00173     bool AIDA_FitData::create2DConnection(const AIDA::IProfile2D & p)
00174     { 
00175       return create2DConnection(p,0,1); 
00176     }
00177     bool AIDA_FitData::create2DConnection(const AIDA::IProfile2D & p, int xIndex, int yIndex)
00178     {
00179       reset();
00180       
00181       m_dim = 2;
00182       m_data_itr =  new AIDA_Profile2DIterator(p, xIndex, yIndex); 
00183       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00184 
00185       for (int i = 0; i < m_dim; ++i) 
00186         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00187      
00188       return true; 
00189     }
00190     bool AIDA_FitData::create2DConnection(const AIDA::IDataPointSet & dp, int xIndex, int yIndex, int valIndex)
00191     {
00192       std::vector<int> indeces(2); 
00193       indeces[0] = xIndex; 
00194       indeces[1] = yIndex; 
00195       return createConnection(dp,indeces,valIndex); 
00196     }
00197     
00198     bool AIDA_FitData::create3DConnection(const AIDA::IHistogram3D & h)
00199     { 
00200       return create3DConnection(h,0,1,2); 
00201     }
00202     bool AIDA_FitData::create3DConnection(const AIDA::IHistogram3D & h, int xIndex, int yIndex, int zIndex)
00203     { 
00204       reset();
00205       
00206       m_dim = 3;
00207       m_data_itr =  new AIDA_Histogram3DIterator(h, xIndex, yIndex, zIndex); 
00208       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00209 
00210       for (int i = 0; i < m_dim; ++i) 
00211         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00212      
00213       return true; 
00214     }
00215     bool AIDA_FitData::create3DConnection(const AIDA::ICloud3D & c)
00216     { 
00217       return create3DConnection(c,0,1,2); 
00218     }
00219     bool AIDA_FitData::create3DConnection(const AIDA::ICloud3D & c, int xIndex, int yIndex, int zIndex)
00220     {
00221       reset();
00222       
00223       m_dim = 3;
00224       m_data_itr =  new AIDA_Cloud3DIterator(c, xIndex, yIndex, zIndex); 
00225       m_fitType = AIDA::Dev::IDevFitter::UNBINNED_FIT;
00226 
00227       for (int i = 0; i < m_dim; ++i) 
00228         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00229      
00230       return true; 
00231     }
00232     bool AIDA_FitData::create3DConnection(const AIDA::IDataPointSet & dp, int xIndex, int yIndex, int zIndex, int valIndex)
00233     {  
00234       std::vector<int> indeces(3); 
00235       indeces[0] = xIndex; 
00236       indeces[1] = yIndex; 
00237       indeces[2] = zIndex; 
00238       return createConnection(dp,indeces,valIndex); 
00239     }
00240       
00241     
00242     bool AIDA_FitData::createConnection(const AIDA::ITuple & t, std::vector<std::string>  colNames)
00243     { 
00244       reset();
00245       
00246       m_dim = colNames.size();
00247       m_data_itr =  new AIDA_TupleIterator(t, colNames); 
00248       m_fitType = AIDA::Dev::IDevFitter::UNBINNED_FIT;
00249 
00250       for (int i = 0; i < m_dim; ++i) 
00251         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00252      
00253       return true; 
00254     }
00255     bool AIDA_FitData::createConnection(const AIDA::ITuple & t, std::vector<AIDA::IEvaluator * > &  evals)
00256     { 
00257       reset();
00258       
00259       m_dim = evals.size();
00260 
00261       m_data_itr =  new AIDA_TupleIterator(t, evals); 
00262       m_fitType = AIDA::Dev::IDevFitter::UNBINNED_FIT;
00263 
00264       for (int i = 0; i < m_dim; ++i) 
00265         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00266      
00267       return true; 
00268     }
00269 
00270     bool AIDA_FitData::createConnection(const AIDA::IDataPointSet & dp, std::vector<int>  indeces, int valIndex)
00271     { 
00272       // reset existing connections before creating new one
00273       reset();
00274       
00275       m_dim = indeces.size();
00276       m_data_itr =  new AIDA_DataPointSetIterator(dp,indeces,valIndex); 
00277       m_fitType = AIDA::Dev::IDevFitter::BINNED_FIT;
00278 
00279       for (int i = 0; i < m_dim; ++i) 
00280         m_ranges.push_back(new Anaphe::AIDA_Function_FML::AIDA_RangeSet()); 
00281      
00282       return true; 
00283     }
00284     
00285     void AIDA_FitData::reset()
00286     {  
00287       // delete ranges
00288       for (std::vector<Anaphe::AIDA_Function_FML::AIDA_RangeSet *>::iterator i = m_ranges.begin(); i != m_ranges.end(); ++i)
00289         delete *i; 
00290 
00291       m_ranges.clear(); 
00292 
00293       //delete data iterator 
00294       if (m_data_itr) delete m_data_itr;  
00295 
00296     }
00297     
00298     int AIDA_FitData::dimension() const
00299     { return m_dim; }
00300     
00301     std::string AIDA_FitData::dataDescription() const
00302     { 
00303       return ""; 
00304     }
00305     
00306     // return range 
00307     AIDA::IRangeSet & AIDA_FitData::range(int index) const
00308     {
00309       if(index <0 || index >= dimension())
00310         {
00311           INFO_MSG("AIDA_FitData: warning : range index out of bounds ");
00312           // here I need to return something - return the first 
00313           index = 0; 
00314         }
00315 
00316       return *m_ranges[index];
00317 
00318     }
00319 
00320     // methods from Developer interface
00321     
00322     // return data iterator
00323 
00324     AIDA::Dev::IDevFitDataIterator * AIDA_FitData::dataIterator() const
00325     {
00326       if (!m_data_itr) {   
00327         INFO_MSG("AIDA_FitData is empty - returning a null pointer");
00328         return 0; 
00329       } 
00330       // fill data (here I have to do) 
00331       // I might to do a check if ranges have changed and is not empty...
00332       // to avoid to copy the data again.  
00333       m_data_itr->fillData(m_ranges); 
00334 
00335       return m_data_itr;  
00336     }
00337 
00338     int AIDA_FitData::fitType() const { return m_fitType; }
00339     
00340 
00341 
00342   }     // end of namespace Anaphe::AIDA_Fitter_FML
00343 } 

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