FitterUtil.cxx

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: FitterUtil.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 "TF1.h"
00011 #include <vector>
00012 #include <cassert>
00013 
00014 /// utility functions to be used in the fitter classes 
00015 
00016 namespace FitterUtil { 
00017    
00018    
00019    double EvalIntegral(TF1 * func, const std::vector<double> & x1, const std::vector<double> & x2, const std::vector<double> & par) {  
00020       // evaluate integral of fit functions from x1 and x2 and divide by dx
00021       
00022       double fval;
00023       unsigned int ndim = x1.size();
00024       double dx = x2[0]-x1[0];
00025       assert (dx != 0);
00026       if ( ndim == 1) { 
00027          fval =  func->Integral( x1[0],x2[0], &par.front() )/dx;
00028          return fval;
00029       }
00030       // dim > 1
00031       double dy = x2[1]-x1[1];
00032       assert (dy != 0);
00033       func->SetParameters(&par.front() );
00034       if ( ndim == 2) { 
00035          fval = func->Integral( x1[0],x2[0],x1[1],x2[1] )/(dx*dy);
00036          return fval;
00037       }
00038       // dim = 3 
00039       double dz = x2[2]-x1[2];
00040       assert (dz != 0);
00041       fval = func->Integral( x1[0],x2[0],x1[1],x2[1],x1[2],x2[2])/(dx*dy*dz);
00042       return fval;
00043       
00044    }
00045 
00046 
00047 
00048 } // end namespace FitterUtil

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