Newer
Older
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta
committed
TH2D* h2 = new TH2D("d2D1_h2", "h2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t x,y;
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, 1.0);
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h2->Fill(x, y, 1.0);
Lorenzo Moneta
committed
TH2D* h3 = new TH2D("d2D1_h3", "h3=(c1*h1)/(c2*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h3->Divide(h1, h2, c1, c2);
Lorenzo Moneta
committed
TH2D* h4 = new TH2D("d2D1_h4", "h4=h3*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h4->Multiply(h2, h3, c2/c1, 1);
for ( Int_t i = 0; i <= h4->GetNbinsX() + 1; ++i ) {
for ( Int_t j = 0; j <= h4->GetNbinsY() + 1; ++j ) {
Double_t error = h4->GetBinError(i,j) * h4->GetBinError(i,j);
error -= (2*(c2*c2)/(c1*c1)) * h3->GetBinContent(i,j)*h3->GetBinContent(i,j)*h2->GetBinError(i,j)*h2->GetBinError(i,j);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
if (cleanHistos) delete h2;
if (cleanHistos) delete h3;
return ret;
}
Lorenzo Moneta
committed
TH2D* h1 = new TH2D("d2D2_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta
committed
TH2D* h2 = new TH2D("d2D2_h2", "h2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t x,y;
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, 1.0);
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h2->Fill(x, y, 1.0);
}
// avoid bins in h2 with zero content
TH2D* h3 = static_cast<TH2D*>( h1->Clone() );
h3->Divide(h2);
Lorenzo Moneta
committed
TH2D* h4 = new TH2D("d2D2_h4", "h4=h3*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h4->Multiply(h2, h3, 1.0, 1.0);
for ( Int_t i = 0; i <= h4->GetNbinsX() + 1; ++i ) {
for ( Int_t j = 0; j <= h4->GetNbinsY() + 1; ++j ) {
Double_t error = h4->GetBinError(i,j) * h4->GetBinError(i,j);
error -= 2 * h3->GetBinContent(i,j)*h3->GetBinContent(i,j)*h2->GetBinError(i,j)*h2->GetBinError(i,j);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
if (cleanHistos) delete h2;
if (cleanHistos) delete h3;
return ret;
}
Double_t c1 = r.Rndm() + 1;
Double_t c2 = r.Rndm() + 1;
Lorenzo Moneta
committed
TH3D* h1 = new TH3D("d3D1_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta
committed
TH3D* h2 = new TH3D("d3D1_h2", "h2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t x,y,z;
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, z, 1.0);
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h2->Fill(x, y, z, 1.0);
Lorenzo Moneta
committed
TH3D* h3 = new TH3D("d3D1_h3", "h3=(c1*h1)/(c2*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h3->Divide(h1, h2, c1, c2);
Lorenzo Moneta
committed
TH3D* h4 = new TH3D("d3D1_h4", "h4=h3*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h4->Multiply(h2, h3, c2/c1, 1.0);
for ( Int_t i = 0; i <= h4->GetNbinsX() + 1; ++i ) {
for ( Int_t j = 0; j <= h4->GetNbinsY() + 1; ++j ) {
for ( Int_t h = 0; h <= h4->GetNbinsZ() + 1; ++h ) {
Double_t error = h4->GetBinError(i,j,h) * h4->GetBinError(i,j,h);
//error -= 2 * h3->GetBinContent(i,j,h)*h3->GetBinContent(i,j,h)*h2->GetBinError(i,j,h)*h2->GetBinError(i,j,h);
error -= (2*(c2*c2)/(c1*c1)) *
h3->GetBinContent(i,j,h)*h3->GetBinContent(i,j,h)*h2->GetBinError(i,j,h)*h2->GetBinError(i,j,h);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
if (cleanHistos) delete h2;
if (cleanHistos) delete h3;
return ret;
}
Lorenzo Moneta
committed
TH3D* h1 = new TH3D("d3D2_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta
committed
TH3D* h2 = new TH3D("d3D2_h2", "h2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t x,y,z;
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, z, 1.0);
x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h2->Fill(x, y, z, 1.0);
TH3D* h3 = static_cast<TH3D*>( h1->Clone() );
h3->Divide(h2);
Lorenzo Moneta
committed
TH3D* h4 = new TH3D("d3D2_h4", "h4=h3*h2)",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h4->Multiply(h2, h3, 1.0, 1.0);
for ( Int_t i = 0; i <= h4->GetNbinsX() + 1; ++i ) {
for ( Int_t j = 0; j <= h4->GetNbinsY() + 1; ++j ) {
for ( Int_t h = 0; h <= h4->GetNbinsZ() + 1; ++h ) {
Double_t error = h4->GetBinError(i,j,h) * h4->GetBinError(i,j,h);
error -= 2 * h3->GetBinContent(i,j,h)*h3->GetBinContent(i,j,h)*h2->GetBinError(i,j,h)*h2->GetBinError(i,j,h);
h4->SetBinError( i, j, h, sqrt(error) );
}
}
}
bool ret = equals("Divide3D2", h1, h4, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
if (cleanHistos) delete h2;
if (cleanHistos) delete h3;
return ret;
}
template <typename HIST>
bool testDivHn1()
Int_t bsize[] = { TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) )};
Double_t xmin[] = {minRange, minRange, minRange};
Double_t xmax[] = {maxRange, maxRange, maxRange};
HIST* s1 = new HIST("dND1-s1", "s1-Title", 3, bsize, xmin, xmax);
HIST* s2 = new HIST("dND1-s2", "s2-Title", 3, bsize, xmin, xmax);
HIST* s4 = new HIST("dND1-s4", "s4=s3*s2)", 3, bsize, xmin, xmax);
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t points[3];
points[0] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[1] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[2] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
s1->Fill(points, 1.0);
points[0] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[1] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[2] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
s2->Fill(points, 1.0);
s4->Fill(points, 1.0);
}
HIST* s3 = new HIST("dND1-s3", "s3=(c1*s1)/(c2*s2)", 3, bsize, xmin, xmax);
// No the bin contents has to be reduced, as it was filled twice!
for ( Long64_t i = 0; i < s3->GetNbins(); ++i ) {
Int_t coord[3];
s3->GetBinContent(i, coord);
Double_t s4BinError = s4->GetBinError(coord);
Double_t s2BinError = s2->GetBinError(coord);
Double_t s3BinContent = s3->GetBinContent(coord);
Double_t error = s4BinError * s4BinError;
error -= (2*(c2*c2)/(c1*c1)) * s3BinContent * s3BinContent * s2BinError * s2BinError;
s4->SetBinError(coord, sqrt(error));
bool ret = equals(TString::Format("DivideND1<%s>", HIST::Class()->GetName()), s1, s4, cmpOptStats, 1E-6);
return ret;
}
template <typename HIST>
bool testDivHn2()
Int_t bsize[] = { TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) )};
Double_t xmin[] = {minRange, minRange, minRange};
Double_t xmax[] = {maxRange, maxRange, maxRange};
HIST* s1 = new HIST("dND2-s1", "s1-Title", 3, bsize, xmin, xmax);
HIST* s2 = new HIST("dND2-s2", "s2-Title", 3, bsize, xmin, xmax);
HIST* s4 = new HIST("dND2-s4", "s4=s3*s2)", 3, bsize, xmin, xmax);
s1->Sumw2();s2->Sumw2();s4->Sumw2();
UInt_t seed = r.GetSeed();
// For possible problems
r.SetSeed(seed);
for ( Int_t e = 0; e < nEvents*nEvents; ++e ) {
Double_t points[3];
points[0] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[1] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[2] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
s1->Fill(points, 1.0);
points[0] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[1] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
points[2] = r.Uniform(0.9 * minRange, 1.1 * maxRange);
s2->Fill(points, 1.0);
s4->Fill(points, 1.0);
HIST* s3 = static_cast<HIST*>( s1->Clone() );
HIST* s5 = new HIST("dND2-s5", "s5=(c1*s1)/(c2*s2)", 3, bsize, xmin, xmax);
// No the bin contents has to be reduced, as it was filled twice!
for ( Long64_t i = 0; i < s3->GetNbins(); ++i ) {
Int_t coord[3];
s3->GetBinContent(i, coord);
Double_t s4BinError = s4->GetBinError(coord);
Double_t s2BinError = s2->GetBinError(coord);
Double_t s3BinContent = s3->GetBinContent(coord);
Double_t error = s4BinError * s4BinError;
error -= (2*(c2*c2)/(c1*c1)) * s3BinContent * s3BinContent * s2BinError * s2BinError;
s4->SetBinError(coord, sqrt(error));
}
bool ret = equals(TString::Format("DivideND2<%s>", HIST::Class()->GetName()), s1, s4, cmpOptStats, 1E-6);
return ret;
}
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("=1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
Lorenzo Moneta
committed
TH1D* h2 = new TH1D("=1D_h2", "h2-Title", numberOfBins, minRange, maxRange);
bool ret = equals("Assign Oper Hist '=' 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
// Tests the operator=() method for 1D Histograms with variable bin size
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("=1D_h1", "h1-Title", numberOfBins, v);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
}
Lorenzo Moneta
committed
TH1D* h2 = new TH1D("=1D_h2", "h2-Title", numberOfBins, v);
*h2 = *h1;
bool ret = equals("Assign Oper VarH '=' 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
bool testAssignProfile1D()
{
// Tests the operator=() method for 1D Profiles
TProfile* p1 = new TProfile("=1D_p1", "p1-Title", numberOfBins, minRange, maxRange);
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
TProfile* p2 = new TProfile("=1D_p2", "p2-Title", numberOfBins, minRange, maxRange);
bool ret = equals("Assign Oper Prof '=' 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
Lorenzo Moneta
committed
{
// Tests the operator=() method for 1D Profiles with variable bin size
Lorenzo Moneta
committed
TProfile* p1 = new TProfile("=1D_p1", "p1-Title", numberOfBins, v);
Lorenzo Moneta
committed
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, 1.0);
Lorenzo Moneta
committed
}
TProfile* p2 = new TProfile("=1D_p2", "p2-Title", numberOfBins, v);
Lorenzo Moneta
committed
bool ret = equals("Assign Oper VarP '=' 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
Lorenzo Moneta
committed
return ret;
}
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("cc1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
bool ret = equals("Copy Constructor Hist 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
bool testCopyConstructorVar1D()
{
// Tests the copy constructor for 1D Histograms with variable bin size
Double_t v[numberOfBins+1];
FillVariableRange(v);
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("cc1D_h1", "h1-Title", numberOfBins, v);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
}
TH1D* h2 = new TH1D(*h1);
bool ret = equals("Copy Constructor VarH 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
TProfile* p1 = new TProfile("cc1D_p1", "p1-Title", numberOfBins, minRange, maxRange);
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, 1.0);
bool ret = equals("Copy Constructor Prof 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
// Tests the copy constructor for 1D Profiles with variable bin size
TProfile* p1 = new TProfile("cc1D_p1", "p1-Title", numberOfBins, v);
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
bool ret = equals("Copy Constructor VarP 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("cl1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
}
bool ret = equals("Clone Function Hist 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
// Tests the clone method for 1D Histograms with variable bin size
Double_t v[numberOfBins+1];
FillVariableRange(v);
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("cl1D_h1", "h1-Title", numberOfBins, v);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
bool ret = equals("Clone Function VarH 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
TProfile* p1 = new TProfile("cl1D_p1", "p1-Title", numberOfBins, minRange, maxRange);
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
bool ret = equals("Clone Function Prof 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
Lorenzo Moneta
committed
{
// Tests the clone method for 1D Profiles with variable bin size
Lorenzo Moneta
committed
TProfile* p1 = new TProfile("cl1D_p1", "p1-Title", numberOfBins, v);
Lorenzo Moneta
committed
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, 1.0);
}
Lorenzo Moneta
committed
Lorenzo Moneta
committed
bool ret = equals("Clone Function VarP 1D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
Lorenzo Moneta
committed
return ret;
}
Lorenzo Moneta
committed
TH2D* h1 = new TH2D("=2D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, 1.0);
Lorenzo Moneta
committed
TH2D* h2 = new TH2D("=2D_h2", "h2-Title",
bool ret = equals("Assign Oper Hist '=' 2D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
TProfile2D* p1 = new TProfile2D("=2D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, z, 1.0);
TProfile2D* p2 = new TProfile2D("=2D_p2", "p2-Title",
bool ret = equals("Assign Oper Prof '=' 2D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
Lorenzo Moneta
committed
TH2D* h1 = new TH2D("cc2D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, 1.0);
}
bool ret = equals("Copy Constructor Hist 2D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
TProfile2D* p1 = new TProfile2D("cc2D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, z, 1.0);
}
TProfile2D* p2 = new TProfile2D(*p1);
bool ret = equals("Copy Constructor Prof 2D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
return ret;
}
bool testClone2D()
{
// Tests the clone method for 2D Histograms
Lorenzo Moneta
committed
TH2D* h1 = new TH2D("cl2D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
TH2D* h2 = static_cast<TH2D*> ( h1->Clone() );
bool ret = equals("Clone Function Hist 2D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
bool testCloneProfile2D()
{
// Tests the clone method for 2D Profiles
TProfile2D* p1 = new TProfile2D("cl2D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
TProfile2D* p2 = static_cast<TProfile2D*> ( p1->Clone() );
bool ret = equals("Clone Function Prof 2D", p1, p2, cmpOptStats);
if (cleanHistos) delete p1;
Lorenzo Moneta
committed
TH3D* h1 = new TH3D("=3D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, z, 1.0);
}
Lorenzo Moneta
committed
TH3D* h2 = new TH3D("=3D_h2", "h2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
*h2 = *h1;
bool ret = equals("Assign Oper Hist '=' 3D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
bool testAssignProfile3D()
{
// Tests the operator=() method for 3D Profiles
TProfile3D* p1 = new TProfile3D("=3D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t t = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, z, t, 1.0);
TProfile3D* p2 = new TProfile3D("=3D_p2", "p2-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
if (cleanHistos) delete p1;
bool testCopyConstructor3D()
{
// Tests the copy constructor for 3D Histograms
Lorenzo Moneta
committed
TH3D* h1 = new TH3D("cc3D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(x, y, z, 1.0);
}
TH3D* h2 = new TH3D(*h1);
bool ret = equals("Copy Constructor Hist 3D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
TProfile3D* p1 = new TProfile3D("cc3D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t t = r.Uniform(0.9 * minRange, 1.1 * maxRange);
p1->Fill(x, y, z, t, 1.0);
}
TProfile3D* p2 = new TProfile3D(*p1);
bool ret = equals("Copy Constructor Prof 3D", p1, p2/*, cmpOptStats*/);
if (cleanHistos) delete p1;
return ret;
}
bool testClone3D()
{
// Tests the clone method for 3D Histograms
Lorenzo Moneta
committed
TH3D* h1 = new TH3D("cl3D_h1", "h1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
h1->Sumw2();
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
TH3D* h2 = static_cast<TH3D*> ( h1->Clone() );
bool ret = equals("Clone Function Hist 3D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
return ret;
}
bool testCloneProfile3D()
{
// Tests the clone method for 3D Profiles
TProfile3D* p1 = new TProfile3D("cl3D_p1", "p1-Title",
numberOfBins, minRange, maxRange,
numberOfBins + 1, minRange, maxRange,
numberOfBins + 2, minRange, maxRange);
for ( Int_t e = 0; e < nEvents * nEvents; ++e ) {
Double_t x = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t y = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t z = r.Uniform(0.9 * minRange, 1.1 * maxRange);
Double_t t = r.Uniform(0.9 * minRange, 1.1 * maxRange);
TProfile3D* p2 = static_cast<TProfile3D*> ( p1->Clone() );
if (cleanHistos) delete p1;
template <typename HIST>
bool testCloneHn()
Int_t bsize[] = { TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) ),
TMath::Nint( r.Uniform(1, 5) )
};
Double_t xmin[] = {minRange, minRange, minRange};
Double_t xmax[] = {maxRange, maxRange, maxRange};
HIST* s1 = new HIST("clS-s1","s1-Title", 3, bsize, xmin, xmax);
Double_t points[3];
points[0] = r.Uniform( minRange * .9, maxRange * 1.1);
points[1] = r.Uniform( minRange * .9, maxRange * 1.1);
points[2] = r.Uniform( minRange * .9, maxRange * 1.1);
HIST* s2 = (HIST*) s1->Clone();
bool ret = equals(TString::Format("Clone Function %s", HIST::Class()->GetName()), s1, s2);
delete s1;
return ret;
}
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("wr1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
TFile f("tmpHist.root", "RECREATE");
h1->Write();
f.Close();
Lorenzo Moneta
committed
TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );
bool ret = equals("Read/Write Hist 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;
// Tests the write and read methods for 1D Histograms with variable bin size
Lorenzo Moneta
committed
TH1D* h1 = new TH1D("wr1D_h1", "h1-Title", numberOfBins, v);
for ( Int_t e = 0; e < nEvents; ++e ) {
Double_t value = r.Uniform(0.9 * minRange, 1.1 * maxRange);
h1->Fill(value, 1.0);
TFile f("tmpHist.root", "RECREATE");
h1->Write();
f.Close();
Lorenzo Moneta
committed
TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );
bool ret = equals("Read/Write VarH 1D", h1, h2, cmpOptStats);
Lorenzo Moneta
committed
if (cleanHistos) delete h1;