Skip to content
Snippets Groups Projects
stressHistogram.cxx 423 KiB
Newer Older
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();h2->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      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's avatar
Lorenzo Moneta committed
   // avoid bins in h2 with zero content
Philippe Canal's avatar
Philippe Canal committed
   for (int i = 0; i < h2->GetSize(); ++i)
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      if (h2->GetBinContent(i) == 0) h2->SetBinContent(i,1);
   TH2D* h3 = new TH2D("d2D1_h3", "h3=(c1*h1)/(c2*h2)",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
   h3->Divide(h1, h2, c1, c2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Philippe Canal's avatar
Philippe Canal committed
         error -= (2*(c2*c2)/(c1*c1)) * h3->GetBinContent(i,j)*h3->GetBinContent(i,j)*h2->GetBinError(i,j)*h2->GetBinError(i,j);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
         h4->SetBinError( i, j, sqrt(error) );
      }
Philippe Canal's avatar
Philippe Canal committed
   h4->ResetStats();
   h1->ResetStats();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Divide2D1", h1, h4, cmpOptStats );
   if (cleanHistos) delete h1;
   if (cleanHistos) delete h2;
   if (cleanHistos) delete h3;
Philippe Canal's avatar
Philippe Canal committed
bool testDivide2D2()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the second Divide method for 2D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();h2->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      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
Philippe Canal's avatar
Philippe Canal committed
   for (int i = 0; i < h2->GetSize(); ++i)
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      if (h2->GetBinContent(i) == 0) h2->SetBinContent(i,1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH2D* h3 = static_cast<TH2D*>( h1->Clone() );
   h3->Divide(h2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Philippe Canal's avatar
Philippe Canal committed
         error -= 2 * h3->GetBinContent(i,j)*h3->GetBinContent(i,j)*h2->GetBinError(i,j)*h2->GetBinError(i,j);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
         h4->SetBinError( i, j, sqrt(error) );
      }
Philippe Canal's avatar
Philippe Canal committed
   h4->ResetStats();
   h1->ResetStats();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Divide2D2", h1, h4, cmpOptStats);
   if (cleanHistos) delete h1;
   if (cleanHistos) delete h2;
   if (cleanHistos) delete h3;
Philippe Canal's avatar
Philippe Canal committed
bool testDivide3D1()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the first Divide method for 3D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t c1 = r.Rndm() + 1;
   Double_t c2 = r.Rndm() + 1;

Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
                       numberOfBins, minRange, maxRange,
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();h2->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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's avatar
Lorenzo Moneta committed
   // avoid bins in h2 with zero content
Philippe Canal's avatar
Philippe Canal committed
   for (int i = 0; i < h2->GetSize(); ++i)
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      if (h2->GetBinContent(i) == 0) h2->SetBinContent(i,1);
   TH3D* h3 = new TH3D("d3D1_h3", "h3=(c1*h1)/(c2*h2)",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
   h3->Divide(h1, h2, c1, c2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Philippe Canal's avatar
Philippe Canal committed
            //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's avatar
Lorenzo Moneta committed
            h4->SetBinError( i, j, h, sqrt(error) );
         }
      }
Philippe Canal's avatar
Philippe Canal committed
   h4->ResetStats();
   h1->ResetStats();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Divide3D1", h1, h4, cmpOptStats);
   if (cleanHistos) delete h1;
   if (cleanHistos) delete h2;
   if (cleanHistos) delete h3;
Philippe Canal's avatar
Philippe Canal committed
bool testDivide3D2()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the second Divide method for 3D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();h2->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      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's avatar
Lorenzo Moneta committed
   // avoid bins in h2 with zero content
Philippe Canal's avatar
Philippe Canal committed
   for (int i = 0; i < h2->GetSize(); ++i)
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      if (h2->GetBinContent(i) == 0) h2->SetBinContent(i,1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH3D* h3 = static_cast<TH3D*>( h1->Clone() );
   h3->Divide(h2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Philippe Canal's avatar
Philippe Canal committed
            error -= 2 * h3->GetBinContent(i,j,h)*h3->GetBinContent(i,j,h)*h2->GetBinError(i,j,h)*h2->GetBinError(i,j,h);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
            h4->SetBinError( i, j, h, sqrt(error) );
         }
      }
   }
Philippe Canal's avatar
Philippe Canal committed
   h4->ResetStats();
   h1->ResetStats();
Lorenzo Moneta's avatar
Lorenzo Moneta committed

   bool ret = equals("Divide3D2", h1, h4, cmpOptStats);
   if (cleanHistos) delete h1;
   if (cleanHistos) delete h2;
   if (cleanHistos) delete h3;
template <typename HIST>
bool testDivHn1()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the first Divide method for 3D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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};
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // There is no multiply with coefficients!
Philippe Canal's avatar
Philippe Canal committed
   const Double_t c1 = 1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   const Double_t c2 = 1;
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s1->Sumw2();s2->Sumw2();s4->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   UInt_t seed = r.GetSeed();
   // For possible problems
   r.SetSeed(seed);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s3->Divide(s1, s2, c1, c2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s4->Multiply(s3);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // 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));
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals(TString::Format("DivideND1<%s>", HIST::Class()->GetName()), s1, s4, cmpOptStats, 1E-6);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   delete s1;
   delete s2;
   delete s3;
template <typename HIST>
bool testDivHn2()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the second Divide method for 3D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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};
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // There is no multiply with coefficients!
Philippe Canal's avatar
Philippe Canal committed
   const Double_t c1 = 1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   const Double_t c2 = 1;

   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed

   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() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s3->Divide(s2);
   HIST* s5 = new HIST("dND2-s5", "s5=(c1*s1)/(c2*s2)", 3, bsize, xmin, xmax);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s5->Divide(s1,s2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   s4->Multiply(s3);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // 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));
   }
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals(TString::Format("DivideND2<%s>", HIST::Class()->GetName()), s1, s4, cmpOptStats, 1E-6);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   delete s1;
   delete s2;
   delete s3;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssign1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 1D Histograms
   TH1D* h1 = new TH1D("=1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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("=1D_h2", "h2-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   *h2 = *h1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper Hist '='  1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssignVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 1D Histograms with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TH1D* h1 = new TH1D("=1D_h1", "h1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed

   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("=1D_h2", "h2-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   *h2 = *h1;

   bool ret = equals("Assign Oper VarH '='  1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testAssignProfile1D()
{
   // Tests the operator=() method for 1D Profiles

   TProfile* p1 = new TProfile("=1D_p1", "p1-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      p1->Fill(x, y, 1.0);
   TProfile* p2 = new TProfile("=1D_p2", "p2-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   *p2 = *p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper Prof '='  1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssignProfileVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 1D Profiles with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TProfile* p1 = new TProfile("=1D_p1", "p1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
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);
   TProfile* p2 = new TProfile("=1D_p2", "p2-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   *p2 = *p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper VarP '='  1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCopyConstructor1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 1D Histograms
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH1D* h2 = new TH1D(*h1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Copy Constructor Hist 1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCopyConstructorVar1D()
{
   // Tests the copy constructor for 1D Histograms with variable bin size

   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TH1D* h1 = new TH1D("cc1D_h1", "h1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed

   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's avatar
Lorenzo Moneta committed
bool testCopyConstructorProfile1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 1D Profiles
   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile* p2 = new TProfile(*p1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Copy Constructor Prof 1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCopyConstructorProfileVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 1D Profiles with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TProfile* p1 = new TProfile("cc1D_p1", "p1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      p1->Fill(x, y, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile* p2 = new TProfile(*p1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Copy Constructor VarP 1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testClone1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the clone method for 1D Histograms
   TH1D* h1 = new TH1D("cl1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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's avatar
Lorenzo Moneta committed
   TH1D* h2 = static_cast<TH1D*> ( h1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function Hist   1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCloneVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the clone method for 1D Histograms with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);

   TH1D* h1 = new TH1D("cl1D_h1", "h1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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's avatar
Lorenzo Moneta committed
   TH1D* h2 = static_cast<TH1D*> ( h1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function VarH   1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCloneProfile1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the clone method for 1D Profiles
   TProfile* p1 = new TProfile("cl1D_p1", "p1-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      p1->Fill(x, y, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile* p2 = static_cast<TProfile*> ( p1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function Prof   1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCloneProfileVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the clone method for 1D Profiles with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TProfile* p1 = new TProfile("cl1D_p1", "p1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
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's avatar
Lorenzo Moneta committed
   TProfile* p2 = static_cast<TProfile*> ( p1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function VarP   1D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssign2D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 2D Histograms
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
Philippe Canal's avatar
Philippe Canal committed
                       numberOfBins, minRange, maxRange,
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins + 2, minRange, maxRange);
   *h2 = *h1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper Hist '='  2D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssignProfile2D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 2D Profiles
   TProfile2D* p1 = new TProfile2D("=2D_p1", "p1-Title",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                                   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      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",
Philippe Canal's avatar
Philippe Canal committed
                                   numberOfBins, minRange, maxRange,
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                                   numberOfBins + 2, minRange, maxRange);
   *p2 = *p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper Prof '='  2D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed

bool testCopyConstructor2D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 2D Histograms
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
      h1->Fill(x, y, 1.0);
   }

Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH2D* h2 = new TH2D(*h1);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Copy Constructor Hist 2D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCopyConstructorProfile2D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 2D Profiles
   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);
   }

Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile2D* p2 = new TProfile2D(*p1);

   bool ret = equals("Copy Constructor Prof 2D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testClone2D()
{
   // Tests the clone method for 2D Histograms

Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      h1->Fill(x, y, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH2D* h2 = static_cast<TH2D*> ( h1->Clone() );

   bool ret = equals("Clone Function Hist   2D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testCloneProfile2D()
{
   // Tests the clone method for 2D Profiles

   TProfile2D* p1 = new TProfile2D("cl2D_p1", "p1-Title",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                                   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      p1->Fill(x, y, z, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile2D* p2 = static_cast<TProfile2D*> ( p1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function Prof   2D", p1, p2, cmpOptStats);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testAssign3D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the operator=() method for 3D Histograms
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
                       numberOfBins + 2, minRange, maxRange);

Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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);
   }

Philippe Canal's avatar
Philippe Canal committed
                       numberOfBins, minRange, maxRange,
                       numberOfBins + 1, minRange, maxRange,
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       numberOfBins + 2, minRange, maxRange);
   *h2 = *h1;

   bool ret = equals("Assign Oper Hist '='  3D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testAssignProfile3D()
{
   // Tests the operator=() method for 3D Profiles

   TProfile3D* p1 = new TProfile3D("=3D_p1", "p1-Title",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                                   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      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",
Philippe Canal's avatar
Philippe Canal committed
                                   numberOfBins, minRange, maxRange,
                                   numberOfBins + 1, minRange, maxRange,
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                                   numberOfBins + 2, minRange, maxRange);
   *p2 = *p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Assign Oper Prof '='  3D", p1, p2);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testCopyConstructor3D()
{
   // Tests the copy constructor for 3D Histograms

Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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's avatar
Lorenzo Moneta committed
bool testCopyConstructorProfile3D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the copy constructor for 3D Profiles
   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);
   }

Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile3D* p2 = new TProfile3D(*p1);

   bool ret = equals("Copy Constructor Prof 3D", p1, p2/*, cmpOptStats*/);
   if (cleanHistos) delete p1;
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testClone3D()
{
   // Tests the clone method for 3D Histograms

Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      h1->Fill(x, y, z, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TH3D* h2 = static_cast<TH3D*> ( h1->Clone() );

   bool ret = equals("Clone Function Hist   3D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   return ret;
}

bool testCloneProfile3D()
{
   // Tests the clone method for 3D Profiles

   TProfile3D* p1 = new TProfile3D("cl3D_p1", "p1-Title",
Lorenzo Moneta's avatar
Lorenzo Moneta committed
                       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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      p1->Fill(x, y, z, t, 1.0);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TProfile3D* p2 = static_cast<TProfile3D*> ( p1->Clone() );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Clone Function Prof   3D", p1, p2);
   if (cleanHistos) delete p1;
template <typename HIST>
bool testCloneHn()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the clone method for Sparse histograms

   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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   for ( Int_t i = 0; i < nEvents * nEvents; ++i ) {
      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);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
      s1->Fill(points);
   HIST* s2 = (HIST*) s1->Clone();
   bool ret = equals(TString::Format("Clone Function %s", HIST::Class()->GetName()), s1, s2);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testWriteRead1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the write and read methods for 1D Histograms
   TH1D* h1 = new TH1D("wr1D_h1", "h1-Title", numberOfBins, minRange, maxRange);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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's avatar
Lorenzo Moneta committed
   TFile f("tmpHist.root", "RECREATE");
   h1->Write();
   f.Close();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TFile f2("tmpHist.root");
   TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Read/Write Hist 1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testWriteReadVar1D()
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   // Tests the write and read methods for 1D Histograms with variable bin size
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   Double_t v[numberOfBins+1];
   FillVariableRange(v);
   TH1D* h1 = new TH1D("wr1D_h1", "h1-Title", numberOfBins, v);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   h1->Sumw2();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   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's avatar
Lorenzo Moneta committed
   TFile f("tmpHist.root", "RECREATE");
   h1->Write();
   f.Close();
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   TFile f2("tmpHist.root");
   TH1D* h2 = static_cast<TH1D*> ( f2.Get("wr1D_h1") );
Lorenzo Moneta's avatar
Lorenzo Moneta committed
   bool ret = equals("Read/Write VarH 1D", h1, h2, cmpOptStats);
Lorenzo Moneta's avatar
Lorenzo Moneta committed
bool testWriteReadProfile1D()