Range of POLAR Coordinates / Strange behavior

Dear Rooters,

I read here and there some questions about POLAR coordinates:
http://root.cern.ch/phpBB2/viewtopic.php?t=773&highlight=polar
http://root.cern.ch/phpBB2/viewtopic.php?t=2815&highlight=polar

and some behaviors that look like bugs:
http://root.cern.ch/phpBB2/viewtopic.php?t=564&highlight=polar

However I still have a question:

  • 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[0]>>d1(100,-TMath:: Pi(),TMath:: Pi(),15,10.,35.)”,
“(rad1>0)&&(TMath::Abs(ang1s[0])<TMath:: Pi())”);
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).

Is there something to do that I missed ?

Regards
Julien




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);
   gRandom->SetSeed();
   gStyle->SetPalette(1);
   Float_t px, py;
   for (Int_t i = 0; i <500000>Rannor(px,py);
      hpxpy->Fill(px,py);
   }
   hpxpy->Draw("lego2 pol");
}

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.


The missing quadran you see on the polar plot correspond to the white margin on the right of your COL plot (5 bins) and the little margin on left (1 bin). Six bins in total.

Ok, Thank you it works.
For the records, I use now the following commands:

 d1  = new TH2F("d1", "d1", 50, -TMath::Pi(),TMath::Pi(), 40, 0, 40);
 h10->Draw("rad1:ang1s[0]>>+d1", 
	    "(rad1>0)&&(TMath::Abs(ang1s[0])<TMath::Pi())");

And I understand now what is the missing quandrant.

Then come two questions/remarks:
[ul]

  • 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 ?
    [/ul]
    Cheers
    Julien

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.