What is exactly the range of the of the phi-axis we should use ?
0 to 2Pi or -Pi to Pi ? The example in the ‘draw2dopt.C’ file
in tutorial directory being -Pi to Pi.
Now this being said, I created a TH2F histogram directly from a TTree
h10->Draw(“rad1:ang1s>>d1(100,-TMath:: Pi(),TMath:: Pi(),15,10.,35.)”,
forcing the x-axis to be -Pi to Pi.
However if when I plot the d1 histogram in Cartesian coordinate I
obtained the expected -Pi:Pi range (see attached file ‘cart.gif’),
the corresponding POLAR projection show a missing quadrant (‘polar.gif’).
(Note that the result is identical even if I don’t force the -Pi:Pi range).
Here is an example showing that the POL option is working properly.
hpxpy = new TH2F("hpxpy", "hpypx", 50, -3.14, 3.14, 50, -4, 4);
Float_t px, py;
for (Int_t i = 0; i <500000>Rannor(px,py);
After having executed this macro I opened the TH2 editor to change the histogram range. That’s an easy way to vary interactively the angle and check it is correct. I took a snapshot of the range -Pi,0 and, as you can see, it is correct.
And I understand now what is the missing quandrant.
Then come two questions/remarks:
Why creating the histogram before (like you suggested me) will be different than creating it while drawing the TTree ?
So if understand how the POLAR option is working, it takes the two ends of the x-range
and place one at 0 and the other a 2 Pi, whatever this range was. Won’t it be easier to
force the user to create a x-range of [0:2*Pi] (or truncate it) and then plot ?
I do not think I suggested you to create the histogram before but indeed that’s the right approach. When you let TTree::Draw create the histogram, the limits are computed automatically according to the data you want to draw. This automatic computation is sometimes not suitable , like in your case, for the goal you want to achieve.
Yes, that’s how it works. It is more general that what you suggest.