Hi Angela, The Sumw2 function must be called before filling your histogram, not after. In testing your program, I found anyhow a bug in TH1::Project3D (now fixed in my development version). The error was not correctly calculated for the projected histogram. Thanks for having reported this problem. Rene Brun Angela Biselli wrote: > > Hi Rooters, > I was trying to use the error-option in Project3D and I stumbled across > something that I don't understand: > I use a 3D histogram, that has errors defined for every bin (Sumw2). The > errors for the 3d histogram-bins are therefore just the sqrt of the > associated entry. Now the calculation of the error for the projection is > fairly straightforward and the result is that the error for one bin should > just be the sqrt of the total entries projected into that bin (=sqrt(sum > of the squares of the errors of the 3Dhistogram bins) ). > However using the "e" option in Project3D (errors are computed) I get a > result that is way too big (in my humble opinion). > > For example: > > { > TH3F *test=new TH3F("test","test",2,0.5.,2.5,2,0.5,2.5,2,0.5,2.5); > for(Int_t i=1;i<3;i++){ > for(Int_t j=1;j<3;j++){ > for (Int_t k=1;k<3;k++) { > test->Fill(i,j,k,10*i); > } > } > } > test->Sumw2(); > test->Project3D("xe")->Draw(); > cout<<"1st bin content="<<test_xe->GetBinContent(1)<<endl; > cout<<"1st bin error="<<test_xe->GetBinError(1)<<endl; > } > > the output is: > 1st bin content=40 > 1st bin error=20.9762 > > The projection for 2 dimensional histograms,on the other hand works in the > way I expect > > { > TH2F *test=new TH2F("test","test",2,0.5.,2.5,2,0.5,2.5); > for(Int_t i=1;i<3;i++){ > for(Int_t j=1;j<3;j++) { > test->Fill(i,j,10*i); > } > } > > test->Sumw2(); > test->ProjectionX("test_px",1,2,"E")->Draw(); > cout<<"1st bin content="<<test_px->GetBinContent(1)<<endl; > cout<<"1st bin error="<<test_px->GetBinError(1)<<endl; > } > > 1st bin content=20 > 1st bin error=4.47214 > > I actually looked into the source code and the calculation seems to > correspond to what I expect. > Could someone please explain me what I am doing wrong? > > Thanks > Angela > > Btw I am using root version 2.23-12 for LINUX
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:21 MET