TChi2ExtendedFitData.cxx

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: TChi2ExtendedFitData.cxx 20880 2007-11-19 11:23:41Z rdm $
00002 // Author: L. Moneta    10/2005  
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2005 ROOT Foundation,  CERN/PH-SFT                   *
00007  *                                                                    *
00008  **********************************************************************/
00009 
00010 #include <cassert>
00011 
00012 #include "RConfig.h"
00013 #include "TChi2ExtendedFitData.h"
00014 
00015 #include "TVirtualFitter.h" 
00016 
00017 
00018 #include <iostream>
00019 
00020 #include "TGraph.h"
00021 #include "TF1.h"
00022 
00023 
00024 
00025 TChi2ExtendedFitData::TChi2ExtendedFitData(const TVirtualFitter & fitter )  {
00026    // constructor - create fit data from Histogram content
00027    fSize = 0;
00028    
00029    TF1 * func = dynamic_cast<TF1 *> ( fitter.GetUserFunc() );  
00030    assert( func != 0);
00031    
00032    TObject * obj = fitter.GetObjectFit(); 
00033    
00034    // case of TGraph
00035    TGraph * graph = dynamic_cast<TGraph*> ( obj );
00036    if (graph) { 
00037       GetExtendedFitData(graph, func, &fitter);    
00038    } 
00039    else { 
00040       std::cout << "other fit on different object than TGraf not yet supported- assert" << std::endl;
00041       assert(graph != 0); 
00042    }
00043 }
00044 
00045 
00046 
00047 void TChi2ExtendedFitData::GetExtendedFitData(const TGraph * gr, const TF1 * func, const TVirtualFitter * /*hFitter*/ ) {
00048    // get data for graf with errors 
00049    
00050    // fit options
00051    //Foption_t fitOption = hFitter->GetFitOption();
00052    
00053    int  nPoints = gr->GetN();
00054    double *gx = gr->GetX();
00055    double *gy = gr->GetY();
00056    // return 0 pointer for some graphs, cannot be used 
00057    //    double *ey = gr->GetEY();
00058    //    double *exl = gr->GetEXlow();
00059    //    double *exh = gr->GetEXhigh();
00060    
00061    CoordData x = CoordData( 1 );  // 1D graph
00062    
00063    //   std::cout << exl << "  " << ey << std::endl;
00064    //std::cout << "creating data with size " << nPoints << std::endl;
00065    
00066    for (int  i = 0; i < nPoints; ++i) { 
00067       
00068       x[0] = gx[i];
00069       if (func->IsInside(&x.front() ) )
00070          SetDataPoint( x, gy[i], gr->GetErrorY(i),  gr->GetErrorXlow(i), gr->GetErrorXhigh(i) );
00071       
00072    }
00073 }
00074 
00075 
00076 void TChi2ExtendedFitData::SetDataPoint( const CoordData & x, double y, double ey, double exl, double exh) { 
00077    // set the new data point info in the internal vectors and count them
00078    
00079    fCoordinates.push_back(x);
00080    fValues.push_back(y);
00081    fErrorsY.push_back(ey);
00082    fErrorsXLow.push_back(exl);
00083    fErrorsXUp.push_back(exh);
00084    fSize++;
00085 }

Generated on Tue Jul 5 14:37:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1