From: arcelli Date: Fri, 15 Feb 2008 14:06:56 +0000 (+0000) Subject: use conventional TH numbering (from 1 to N) in bin indeces for GetBinSize(...) and... X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=d957dd379a61cd284cd5a4a4e8a8124d9fb457ec use conventional TH numbering (from 1 to N) in bin indeces for GetBinSize(...) and GetBinCenter(...) --- diff --git a/CORRFW/AliCFFrame.cxx b/CORRFW/AliCFFrame.cxx index ccf8665b62f..4b822e9efb0 100644 --- a/CORRFW/AliCFFrame.cxx +++ b/CORRFW/AliCFFrame.cxx @@ -193,6 +193,7 @@ Int_t AliCFFrame::GetBinIndex(Int_t *ibin) const { // // getting the element number on the grid for a given set of bin indeces + //(here the numbering of bin indeces ranges from 0 to N-1) // Int_t ind=ibin[fNVar-1]; for(Int_t i=fNVar-1;i>0;i--){ @@ -204,7 +205,9 @@ Int_t AliCFFrame::GetBinIndex(Int_t *ibin) const Int_t AliCFFrame::GetBinIndex(Int_t ivar, Int_t ind) const { // - // getting the bin index on a given dim. ivar for a given element ind on the grid + // getting the bin index on a given dim. ivar for a given element ind + // on the grid + //(here the numbering of bin indeces ranges from 0 to N-1) // Int_t index=-1; for(Int_t i=fNVar-1;i>=0;i--){ @@ -221,6 +224,7 @@ void AliCFFrame::GetBinIndex(Int_t ind, Int_t *bins ) const { // // getting the set of bin indeces for a given element ind on the grid + // (here the numbering of bin indeces ranges from 0 to N-1) // Int_t index=-1; for(Int_t i=fNVar-1;i>=0;i--){ @@ -235,10 +239,16 @@ Double_t AliCFFrame::GetBinCenter(Int_t ivar, Int_t ibin) const { // // getting the bin center of a given bin ibin along variable ivar + // (here the numbering of bin indeces in input + // ranges from 1 to N, TH1/2/3 and THnSparse convention) // - Double_t binMin=fVarBinLimits[fOffset[ivar]+ibin]; - Double_t binMax=fVarBinLimits[fOffset[ivar]+ibin+1]; + if(ibin>fNVarBins[ivar] || ibin==0){ + AliWarning(Form("bin index out of range, number of bins in variable %i ranges from 1 to %i", ivar,fNVarBins[ivar])); + return -1; + } + Double_t binMin=fVarBinLimits[fOffset[ivar]+ibin-1]; + Double_t binMax=fVarBinLimits[fOffset[ivar]+ibin]; Double_t val=0.5*(binMin+binMax); return val; } @@ -248,6 +258,8 @@ void AliCFFrame::GetBinCenters(Int_t *ibin, Double_t *binCenter) const // // gives the centers of the N-dim bin identified by a set of bin indeces // invar + // (here the numbering of bin indeces in input + // ranges from 1 to N, TH1/2/3 and THnSparse convention) // for(Int_t i=0;i=fNVarBins[ivar]){ - AliWarning(Form("bin index out of range, number of bins in variable %i is %i", ivar,fNVarBins[ivar])); + if(ibin>fNVarBins[ivar] || ibin==0){ + AliWarning(Form("bin index out of range, number of bins in variable %i ranges from 1 to %i", ivar,fNVarBins[ivar])); return -1; } - Double_t binMin=fVarBinLimits[fOffset[ivar]+ibin]; - Double_t binMax=fVarBinLimits[fOffset[ivar]+ibin+1]; + Double_t binMin=fVarBinLimits[fOffset[ivar]+ibin-1]; + Double_t binMax=fVarBinLimits[fOffset[ivar]+ibin]; Double_t val=binMax-binMin; return val; } @@ -275,6 +289,8 @@ void AliCFFrame::GetBinSizes(Int_t *ibin, Double_t *binSizes) const // // gives the sizes of the N-dim bin identified by a set of bin indeces // ibin + // (here the numbering of bin indeces in input + // ranges from 1 to N, TH1/2/3 and THnSparse convention) // for(Int_t i=0;i