#include "TUnuranEmpDist.h"
#include "TH1.h"
#include <cassert>
TUnuranEmpDist::TUnuranEmpDist (const TH1 * h1, bool useBuffer) :
fMin(0),
fMax(0)
{
fDim = h1->GetDimension();
bool unbin = useBuffer && h1->GetBufferLength() > 0 ;
fBinned = !unbin;
if (fBinned ) {
int nbins = h1->GetNbinsX();
fData.reserve(nbins);
for (int i =0; i < nbins; ++i)
fData.push_back( h1->GetBinContent(i+1) );
fMin = h1->GetXaxis()->GetXmin();
fMax = h1->GetXaxis()->GetXmax();
}
else {
int n = h1->GetBufferLength();
const double * bf = h1->GetBuffer();
fData.reserve(n);
for (int i = 0; i < n; ++i) {
int index = (fDim+1)*i + fDim + 1;
fData.push_back( bf[index] );
}
}
}
TUnuranEmpDist::TUnuranEmpDist (unsigned int n, double * x) :
fData(std::vector<double>(x,x+n) ),
fDim(1),
fMin(0), fMax(0),
fBinned(0)
{
}
TUnuranEmpDist::TUnuranEmpDist (unsigned int n, double * x, double * y) :
fData(std::vector<double>(2*n) ),
fDim(2),
fMin(0), fMax(0),
fBinned(0)
{
for (unsigned int i = 0; i < n; ++i) {
fData[i*2] = x[i];
fData[i*2+1] = y[i];
}
}
TUnuranEmpDist::TUnuranEmpDist (unsigned int n, double * x, double * y, double *z) :
fData(std::vector<double>(3*n) ),
fDim(3),
fMin(0), fMax(0),
fBinned(0)
{
for (unsigned int i = 0; i < n; ++i) {
fData[i*3] = x[i];
fData[i*3+1] = y[i];
fData[i*3+2] = z[i];
}
}
TUnuranEmpDist::TUnuranEmpDist(const TUnuranEmpDist & rhs) :
TUnuranBaseDist()
{
operator=(rhs);
}
TUnuranEmpDist & TUnuranEmpDist::operator = (const TUnuranEmpDist &rhs)
{
if (this == &rhs) return *this;
fData = rhs.fData;
fDim = rhs.fDim;
fMin = rhs.fMin;
fMax = rhs.fMax;
fBinned = rhs.fBinned;
return *this;
}
Last change: Fri Oct 31 16:21:15 2008
Last generated: 2008-10-31 16:21
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.