I think, that I got a working solution now. I basically rebinned the histogram for each r independently.

Here is the Code:

[code]#include <TH1.h>

#include <TH2.h>

#include <TCanvas.h>

#include <TFile.h>

#include <TRandom3.h>

#include

#include <math.h>

using namespace std;

void polar_gauss() {

TRandom3 rnd;

Int_t nbinphi = 20, nbintheta = 10;

Double_t phimin = 0, phimax = 360, thetamin = 0, thetamax = 90;

TH2F *histo2d = new TH2F(“h2d”,“2DHistogramm”, nbinphi, phimin, phimax, nbintheta, thetamin, thetamax);

TH2F *new_histo2d = new TH2F(“h2d”,“2DHistogramm”, nbinphi, phimin, phimax, nbintheta, thetamin, thetamax);

Double_t dphi = (phimax-phimin)/(nbinphi-1), dtheta = (thetamax - thetamin) / (nbintheta-1);

//I left out the filling of histo2d with phi and theta

//////////////////////////////////////////////////////////

// rebinning //

//////////////////////////////////////////////////////////

Double_t bincontent[100][100];

for (Int_t Ny = 1; Ny < nbintheta + 1; Ny++)

{

Int_t i = 0;

Double_t actual_theta = (Ny - 1.) * dtheta;

//number of new bins for current theta (area of annulus divided by area of circle at theta=0)

Double_t N = (pow(actual_theta+dtheta,2) - pow(actual_theta,2))/pow(dtheta,2);

```
for(Int_t Nx = 1; Nx < nbinphi + 1; Nx++)
{
if (Nx > (i + 1) * (nbinphi / N)) //if the bin gets split in the new binning
{
for (Int_t a = 0; a < histo2d->GetBinContent(Nx, Ny); a++) //throw dice for every entry to determine, in which new bin it gets stored
{
if (rnd.Rndm(a) >= (i + 1) * (nbinphi/N) - (Int_t)((i + 1) * nbinphi/N)) bincontent[Ny-1][i+1]++;
else bincontent[Ny-1][i]++;
}
cerr << bincontent[Ny-1][i] << "\t" << bincontent[Ny-1][i+1] << "\t";
//cerr<< "vergleich:" << (i + 1) * N - (Int_t)((i + 1) * N) << "\t" << bincontent[Ny-1][i+1] << "\t";
i++; //go to next new bin
}
else {bincontent[Ny-1][i] += histo2d->GetBinContent(Nx, Ny); cerr << bincontent[Ny-1][i] << "\t" << bincontent[Ny-1][i+1] << "\t";}
}
```

}

//store new binning in a new histogram

for (Int_t Ny = 1; Ny < nbintheta + 1; Ny++)

{

Int_t i = 0;

for(Int_t Nx = 1; Nx < nbinphi + 1; Nx++)

{

Double_t actual_phi = (Nx -1.)*dphi;

if (actual_phi == 360) actual_phi = 360-0.01; //it doesn’t like phi=360°

Double_t actual_theta = (Ny - 1.)*dtheta;

Double_t N = (pow(actual_theta+dtheta,2) - pow(actual_theta,2))/pow(dtheta,2);

new_histo2d->Fill(actual_phi, actual_theta, bincontent[Ny-1][i]);

if (Nx > (i + 1) * (nbinphi / N)) i++; //increment i after end of new bin is reached

}

}

////////////////////////////

// graphical representation

////////////////////////////

//dummy for axis

TH2D* dummy_his = new TH2D(“dummy”, “histo title”, 100, -thetamax, thetamax, 100, -thetamax, thetamax);

TCanvas* c1 = new TCanvas(“c1”,“gauss”,0,10,1800,1000);

c1->Divide(2,2);

c1->cd(1);

dummy_his->Draw(“COL”); // draw the dummy histogram first

histo2d->Draw(“COLZ POL SAME”);

c1->cd(2);

dummy_his->Draw(“COL”);

new_histo2d->Draw(“COLZ POL SAME”);

c1->cd(3);

dummy_his->Draw(“COL”);

new_histo2d->Draw(“SURF2 pol”);

c1->cd(4);

dummy_his->Draw(“COL”);

new_histo2d->Draw(“SURF3 pol”);[/code]

And I get these plots:

As you can see there are still some issues with the graphical representation. While the rebinning works fine, I’d like to use 2D projection of the color map in SURF 3 without the 3D grid, is this possible? Also in the SURF options it doesn’t plot the bins for r=0 (the white hole), while it does for the COLZ option.