{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf470 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \f0\fs24 \cf0 void htest() \{\ TCanvas* canvas1 = new TCanvas("c1", "Histogram stacking test");\ THStack* stack = new THStack("stack", "Histogram stacking test");\ \ double xBins[11] = \{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5\};\ double yBinsOne[21];\ for (int i = 0; i < 21; i++) \{\ yBinsOne[i] = (-5) + (i * 0.5);\ \}\ double yBinsTwo[11];\ for (int i = 0; i < 11; i++) \{\ yBinsTwo[i] = (-5) + i;\ \}\ \ TH2* h1 = new TH2F("h1", "Hist1", 10, xBins, 20, yBinsOne);\ h1->FillRandom("gaus", 10000);\ TH2* h2 = new TH2F("h2", "Hist2", 10, xBins, 10, yBinsTwo);\ h2->FillRandom("gaus", 5000);\ \ stack->Add(h1);\ stack->Add(h2);\ stack->Draw();\ \}\ }