Rebinning of 2D ROOT histogram in Python

This is still not possible.

For example, you cannot know if the low values of x correspond to the low values of y, or the high values (slope positive or negative). Having the two distributions does provide some information about what situations can be excluded, but will not provide a single relation between x and y.

Take this example:

{
   TH2D* h2d_A = new TH2D("h2d_A","Dist A", 100, -2, 2, 100, -2, 2);
   TH2D* h2d_B = new TH2D("h2d_B","Dist B", 100, -2, 2, 100, -2, 2);

   for (int i=0;i<5000;i++) {
      double xValue = gRandom->Gaus();
      h2d_A->Fill(xValue, xValue);
      h2d_B->Fill(xValue, -xValue);
   }

   TCanvas *c = new TCanvas("c","");
   c->Divide(3,2);

   c->cd(1);
   h2d_A->Draw("COLZ");
   c->cd(2);
   h2d_A->ProjectionX()->Draw();
   c->cd(3);
   h2d_A->ProjectionY()->Draw();

   c->cd(4);
   h2d_B->Draw("COLZ");
   c->cd(5);
   h2d_B->ProjectionX()->Draw();
   c->cd(6);
   h2d_B->ProjectionY()->Draw();
}

You can see that both the positive and negative sloped 2D histogram produce Gaussian projections with no indication of the correlation between the two values.

1 Like