I made a simpler version of your macro to ease the debugging:
void mperrint() {
double p0 = 25;
const char* fileOut = "bla.pdf";
gStyle->SetLabelSize(0.06,"xyz");
gStyle->SetLabelOffset(0.012,"xy");
gStyle->SetTitleOffset(1.05,"x");
gStyle->SetTitleOffset(1.15,"y");
gStyle->SetTitleSize(0.065,"xy");
gStyle->SetTitleBorderSize(0);
gStyle->SetOptStat("");
TLorentzVector* p4Pi = new TLorentzVector();
double mPi = 0.13957;
p4Pi->SetXYZM(0,0,p0,mPi);
double binW = 200/2595.;
double thMax =1.5;
auto hPol = new TH2D("hPol", "",40,-TMath::Pi(),TMath::Pi(),90,0,thMax);
auto hTh = new TH1D("hTh" , ";#theta_{#nu#pi} [#circ]; evts per sr",90,0,thMax);
hPol->GetZaxis()->SetMaxDigits(3);
hTh->GetYaxis()->SetMaxDigits(3);
double bW = hTh->GetBinWidth(2)*TMath::DegToRad();
double bWPhi = 2*TMath::Pi()/40;
auto cv = new TCanvas();
double mMu = 0.10565837;
double massDecay[2] = {mMu,0.};
TGenPhaseSpace generator;
int nP=100;
for (int ip(0); ip < nP; ip++) {
int nPh = int(gRandom->Poisson(1000.));
p4Pi->SetXYZM(0,0,p0,mPi);
generator.SetDecay(*p4Pi, 2, massDecay);
for (int i(0); i<nPh ; i++) {
// generate
Double_t weight = generator.Generate();
// true
TLorentzVector* p4Mu = generator.GetDecay(0);
TLorentzVector* p4Nu = generator.GetDecay(1);
double th = p4Nu->Vect().Theta();
double phi = p4Nu->Vect().Phi();
hPol->Fill(phi,th*TMath::RadToDeg(),weight/nP / bW / bWPhi);
//hPol.Fill(phi,th*TMath::RadToDeg(),weight/nP);
hTh->Fill(th*TMath::RadToDeg() ,weight/nP / bW / (2*TMath::Pi()));
}
}
hPol->Draw("lego2 polz");
hPol->SetLineColorAlpha(kBlack, 0.0);
cv->SetGrid(0,0);
cv->SetRightMargin(0.15);
cv->SetTheta(90.);
cv->SetPhi(0.);
gPad->Update();
auto gp = new TGraphPolargram("g",0,thMax, -180., 180.);
gp->SetToDegree ();
gp->SetNdivPolar(8);
gp->SetNdivRadial(4);
gp->SetLineColor(1);
gp->Draw();
}
This Marco super-impose a 3D pol and a 2D polargram. Superimposing is not straightforward in that case. I am looking for a solution with an extra pad…