Want to make a 2D histo with unusual binning

I wish to make a 2D histo with bin sizes that vary across the 2D plane, but not in the form constrained by the standard variable-size binning option. For instance, if the origin is in the center of my plot, I want small bins, in both x and y, when x .AND. y are small, and large bins when x .AND. y are large. Hence, smaller bins in the center of the plot, larger bins as you move away from the origin. I don’t see a TH2 constructor that allows for this, but perhaps that is a class or method I’m unaware of?

TH2Poly

TH2Poly did the trick. But it doesn’t seem to fill properly when projecting from a TTree using the Draw method. Ex: MyTree.Draw(“x:y>>myTH2Poly”);

If instead of a TH2Poly with rectangular bins I construct a standard TH2, the filling works as expected.

Is there an easy workaround?

Yes TH2Poly are not taken into account in that way. I guess the only way will be to fill your histogram in some C++ code called by TTree::Process:
root.cern.ch/doc/master/classTT … 9ab24c7a85

Thanks! Too bad this does not work with TH2Poly. I think I can also dump the Scan() of the TTree to an output text file, then read back in the entries and call Fill for the TH2Poly:

((TTreePlayer*)(tree->GetPlayer()))->SetScanRedirect(true);
((TTreePlayer*)(tree->GetPlayer()))->SetScanFileName(“output.txt”);
tree->Scan(…)

Not so elegant, but should work.

-Carlo