Draw two branches from a root file on the same plot

Hello All,

I have two branches of a tree with different pieces of information in a root file. And I wanted to draw them one vs the other.
Is this possible to draw this plot or may I do something before filling it in a tree?

Thank You

   TFile *f = new TFile("myfile.root");
   TTree *t1 = (TTree*)f->Get("mytree");
   Float_t px, py;


Sorry, I forgot to mention that the two branches are from two different trees.
Is it possible to plot?

Just duplicate the lines for each tree and instead of tree->Draw, fill and draw a 2D histogram as in the linked tutorial.
More tutorials: ROOT: Tree tutorials

I tried this

Float_t recpt, genpt;
TFile *f = new TFile(“AnalysisResults.root”);
TTree t1 = (TTree)f->Get(“recpt”);
TTree t2 = (TTree)f->Get(“genpt”);

But still has some issue. Plot not coming right.
What else to do here?

There is example showing how to use Friends tree:

And a section in the Manual:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.