Hello Rooters, I can't understand how to operate on histograms. I just want to receive h14=h4, but I solved it in quite unelegant way. Would you tell me what is wrong in my macro? I reckon that operating togeher on objects and pointers causes a complicating notation. I wish there was no pointers at all or there were hidden pointers, but I understand that there are many benefits of pointers... Best wishes, Tadeusz { ////////////////////////////////////////////////////////// // This file has been automatically generated // (Mon Nov 24 12:46:19 1997 by ROOT version 1.03/07) // from TTree kas/BASKET // found on file: dst00459.root ////////////////////////////////////////////////////////// //Reset ROOT and connect tree file gROOT->Reset(); TFile hfile("dep.root"); page = new TCanvas("page","Example",0,0,500,700); page->SetFillColor(10); page->Divide(1,1); TH1F *h44 = new TH1F("h44","Example",100,0,50); TH1F *h14 = new TH1F("h14","Example",100,0,50); // Of course there h4 is the same. // It's correct // h44->Add(h4,h4); // h14->Add(h44,h4,1,-1); // There are nice figures // It's wrong h44=(*h4)+(*h4); h14=(*h4); // There is nothing ... Int_t k; char padname[20]; char hname[20]; TH1 *h; k=0; sprintf(padname,"page_%d",k+1); TPad *pad = (TPad*)page->GetPrimitive(padname); pad->cd(); pad->SetGrid(); pad->GetFrame()->SetFillColor(42); pad->GetFrame()->SetBorderMode(-1); pad->GetFrame()->SetBorderSize(5); pad->Draw(); sprintf(hname,"h1%d",k+4); h=(TH1F*)hfile.Get(hname); h.SetLineWidth(2); h.SetLineStyle(1); h.SetLineColor(4); h.SetXTitle("E[MeV]"); h.SetYTitle("N"); h.SetMinimum(0); h.SetMaximum(2.5e5); h.Draw(); sprintf(hname,"h4%d",k+4); h=(TH1F*)hfile.Get(hname); h.SetLineWidth(2); h.SetLineStyle(1); h.SetLineColor(2); h.SetMinimum(0); h.SetMaximum(2.5e5); h.Draw("same"); page.Update(); TPostScript mps("dep21.ps"); page.Draw(); mps.Close(); page->cd(); } -- Tadeusz Pytlos mailto:pytlos@fizwe5.fic.uni.lodz.pl Lodz, Poland
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET