Order of variables in TTree draw

Hi,

Just curious and a little bit confusing, the order of variables in TTree::Draw() is just opposite to the order of variables defined in histogram. Here is an example code taken and from ROOT user guide and modified a little bit.

In this case, order of variables in histogram declaration and h3->Fill(x,y,z) are same.

void t1()
{
        TH3D *h3 = new TH3D("h3", "h3", 20, -2, 2, 20, -2, 2, 20, 0, 4);
        Double_t x,y,z;
        
        for (Int_t i=0; i<10000; i++) {
                gRandom->Rannor(x, y);
                z = x*x + y*y;
                h3->Fill(x,y,z);
        }
        h3->Draw();
}

In this case, order of variables in histogram declaration and tree->Draw(“z:y:x >> h3”, “”, “iso”) are opposite to get identical plot as above.

void t2()
{
        Double_t x,y,z;
        TTree *tree = new TTree("test", "test");
        tree->Branch("x", &x, "x/D");
        tree->Branch("y", &y, "y/D");
        tree->Branch("z", &z, "z/D");

        for (Int_t i=0; i<10000; i++) {
                gRandom->Rannor(x, y);
                z = x*x + y*y;
                tree->Fill();
        }

        TH3D *h3 = new TH3D("h3", "h3", 20, -2, 2, 20, -2, 2, 20, 0, 4);
        tree->Draw("z:y:x >> h3", "", "iso");
}

OR am I missing some thing?

Another thing: while accessing the bin content of the histogram by h3->GetBinContent(x,y,z), what will be the order?

Thanks.

Use Fill(x, y, z), Draw(“z:y:x”) and GetBinContent(x, y, z). “z:y:x” reads as “z versus y versus x”.