Problem with ttree.Draw("same")

Hi, I’m trying to Draw two histograms containing the same variable from two different ttrees on the same histogram. I set the drawing option to same but for some reason only the first plot is being drawn. Have you any idea why? Here is my code

   TFile *fileIn= new TFile("tree_signal_background.root");
   TTree *Signal=(TTree*)fileIn->Get("ts;1");
   TTree *Cosmics=(TTree*)fileIn->Get("tb;1");

   TCanvas *c6 = new TCanvas("c6","c6",750, 500);
   gStyle->SetOptStat(0);
   Signal->Draw("ntracks>>hntracks");
   chntracks->SetLineColor(kRed);
   Cosmics->Draw("ntracks>>chntracks","","same");

ROOT Version: 6.12

It could be that your 2nd plot is outside the range of the 1st one. In that case you should fill the histogram only with the Draw command (option goff) . then put them in a THStack and draw the THSTack

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