00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "TF1.h"
00011 #include <vector>
00012 #include <cassert>
00013
00014
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
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
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
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 }