Hello Rooters, Maybe it will be silly, but I don't understand why there is diffrence in mean and RMS, when I calculate manually (including //1 h1->Fill(vht[i]); ) and automaticly (including //2 bas.Draw("vht >> h1"); ). Histrograms also look diffrent 1// starts from 0 on y axis, 2// from 10 on y axis. I don't see why. There is my code ( a little simplifying) { ////////////////////////////////////////////////////////// // This file has been automatically generated // (Mon Nov 24 12:46:19 1997 by ROOT version 1.03/07) // from TTree bas/BASKET // found on file: dst00459.root ////////////////////////////////////////////////////////// //Reset ROOT and connect tree file gROOT->Reset(); kret=new TCanvas("kret","Description",0,0,500,700); kret->SetFillColor(10); kret->SetGrid(); // Line below gives nothing!?? kret->RangeAxis(0.,0.,100.,1000.); kret->SetLogy(); kret->GetFrame()->SetFillColor(10); kret->GetFrame()->SetBorderSize(1); TChain bas("h10"); bas.Add("/home/root/dst001.root"); //Declaration of leaves types ....... Int_t nt; Float_t vht[480]; //Set branch addresses ............... bas->SetBranchAddress("nt",&nt); bas->SetBranchAddress("vht",vht); // This is the loop skeleton // To read only selected branches, Insert statements like: bas->SetBranchStatus("vht",1); // able all branches bas->SetBranchStatus("nt",1); TH1F *h1 = new TH1F("h1","Histogram ",150,0,1500); Int_t nentries = bas->GetEntries(); Float_t sum=0.,my_mean; Int_t n=0,nbytes = 0; for (Int_t j=0; j<nentries;j++) { nbytes += bas->GetEvent(j); for (Int_t i=0; i<nt;i++) { // 1 h1->Fill(vht[i]); // gives h1, Nent=504286, Mean=19.969, RMS=63.3418 sum+=vht[i]; n++; } } // 2 // bas.Draw("vht >> h1"); // gives h1, Nent=504286, Mean=15.9455, RMS=48.5221 h1.Draw(); my_mean=sum/n; // my_mean=19.969 char headstring[100]; sprintf(headstring,"my_mean= %7.4f",my_mean); TText *text = new TText(600,5,headstring); text->Draw(); kret->Update(); } Best regards, Tadeusz Pytlos -- Tadeusz Pytlos mailto:pytlos@fizwe5.uni.lodz.pl Lodz, Poland
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:29 MET