Ploting superimpose gragh from tree

I want to draw superimpose graph from tree branches, but I can’t find the command for that. I tried to use “same”, but when I run the code, it draws the first graph only

Could someone tell me if something is missing here?

Here is the code

TFile *file1 = TFile::Open("******.root");
  TTree *BeamS = (TTree*)file1->Get("**Nt");

 Int_t X;
  Int_t Y;
BeamS->SetBranchAddress("X", &X);
BeamS->SetBranchAddress("Y", &Y);

  TCanvas *c = new TCanvas("c","c",800,500);
 BeamS->Draw("X:Y","status==10 && Ang==40");
BeamS->Draw("X:Y","status==10 && Ang==37"," same");

I guess the second one is being drawn “outside” the frame of the first one; if the axis ranges (x or y) do not match, for the second, third, etc. histogram drawn you only see the areas that fall within the same region as the first drawn histogram. If for example y goes from 0 to 100 in histo A and 0 to 300 in histo B, try drawing first histo B, then A. But the best is to use a THStack, which ensures all will be shown (draw with the option “nostack”).

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