{ gROOT->Clear(); gROOT->Reset(); //Load chain. TFile *Achain = new TFile("/disk/usr4/ethrane/upmu3ET/tanaka/tanaka.root"); //Create histograms. TH1F *Hohit8mThru = new TH1F("Hohit8mThru","ohit8m (exit)",60,0,60); TH1F *Hohit8mStop = new TH1F("Hohit8mStop","ohit8m (exit)",60,0,60); //Fill histogram with ehit8m. (The default tree is h1.) h1->Draw("Um_ohit8m>>Hohit8mThru","Pid_flg==1"); h1->Draw("Um_ohit8m>>Hohit8mStop","Pid_flg==2","same"); //Color each histogram. Hohit8mStop->SetFillColor(2); Hohit8mThru->SetFillColor(3); Hohit8mStop->SetFillStyle(3013); //Stack histograms. THStack hs("hs","stack"); hs.Add(Hohit8mThru); hs.Add(Hohit8mStop); //remove old .root file with command line prompt .! rm pid.root //Save stack. TFile f("pid.root","new"); hs.Write(); //Save as gif. c1->Print("pid.gif"); }