If it is done using using OpenGL it will be a new option in TGLHistPainter. It should not be done using the geometry package.
[quote]
TCutG object ? What can be gained if TCutG is used instead of TPolyLine ?
Do you think I’d just start by using TCutG instead of TPolyLine for the honeycomb ? [/quote]
That’s not for honeycomb. It is a generalization. TCutG has the tools to know if a value is inside or outside the cut. That’s why a TCutG is better.
I would like to know which methods of TH2 I need to override in the derived class so that I can fill bin contents via TTree::Draw. I do not intend to make a class of arbitrary bin shapes but would like to write a class inherited from TH1/TH2/TH3.
I have to dig a little more into how I did it, and more experienced people can give you a better answer,
but I far as I can remember, the only thing you have to do is write the proper SetBinContent() method.
Hope it can help. Tomorrow I can post the sources of my code if you wish.
A priori, all you need to do is ‘use’ you class:MyClass *histo = new MyClass("somename",....);
mytree->Draw("py:px>>somename");(assuming you overload the right methods of TH2)
Thanks for your replies. I should have explained my situation in detail.
I am planning to write a library to handle FITS files (astronomical data format) in ROOT. Most of 2D images used in astronomy has their own coordinate system (WCS; world coordinate system) because celestial coordinates cannot be projected on 2D images without distortion. For example, pixels in a FITS image are indexed from 1 to N1 for x and 1 to N2 for y, where the total number of pixels is N1 x N2. However, if I use WCS which converts pixel coordinates (x, y) to (galactic longitude, galactic latitude), I need an automated coordinate conversion when using TTree::Draw.
where, I suppose TFitsImage2D should have a wrapper like
TFitsImage2D::Fill(double x, double y, double w)
{
double pix[2];
Sky2Pix(x, y, pix); // a method which converts celestial coordinates to 2D pixel numbers
TH2D::Fill(pix[0], pix[1], w);
}
to calculate the correct pixel position from latitude and longitude.
Very recently we have introduced a new class interfacing FITS files to ROOT graphics, thanks to Claudi Martinez.
Could you have a look at this class (see: root.cern.ch/root/html/TFITSHDU.html) and possibly
cooperate for further developments?
For Julien, you will be pleased to know that we are about to release a new histogram class TH2Poly with arbitrary bin shapes (hexagons, country maps, etc) and with rendering in the normal 2d pad, but also with GL.
This is great ! This will save (me) a lot of time, and the results look great too (way better that what I have been able to do).
As I post it yesterday, for information I will attach here the class I wrote, as it is now.
There is no much comments in it, but I have been using it for now few months and
it seems quite stable. It also have been improved for memory management and robustness by my colleagues here.
There is also analysis methods specific to the detector I am working with (see previous posts),
especially to fit tracks. This has directly nothing to do with pure TH2 with arbitrary bin shape coding, but I will keep them here FYI
As soon as the TH2Poly is out I think I will test it and probably make my TMayaHisto class inherits from it.
I finally have time to test your great TH2Poly class.
My plan is to implement my specific methods to this more general class.
I however have some (small) troubles/questions :
I would like to access the points defining a given bin. How can I do that ?
The area of the bin is automatically calculated, but I do not think the barycenter is. Is it (easily) possible to implement this ? It will ease calculations and fit procedures.
This being said the migration is rather easy.
Thank you again for the help and the development of this new class.
This being said I think it will more efficient to have the barycenter calculated when AddBin() is called and stored in private variables e.g. fCenterX and fCenterY , as fArea is.
You send me an email via this forum. I see it in my CERN mail box but it does not show your email address, and I do not see the email in the forum mailbox either. So please send me a direct email at olivier.couet@cern.ch so I can answer you.
gStyle->SetCanvasPreferGL(true);
TCanvas *can = new TCanvas();
// ...
for ( int i = 0; i < binID->size(); i++ ) {
//set histogram bins
int bin = binID->at(i);
myEvtHisto->SetBinContent( bin, myEvtHisto->GetBinContent(bin) + Amp->at(i) );
}
myEvtHisto->Draw("GLLEGO");
can->Print("output.png");
the output is a flat LEGO-plot: always all bins 0 and z-range from -1 to 1. The xy-range is correct. I would appreciate if someone had an advice to solve this problem. Thanks in advance!