Changeset 3151 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 02/14/04 17:43:35 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r3112 r3151 894 894 Int_t MH::CutEdges(TH1 *h, Int_t nbins) 895 895 { 896 TAxis * axe =h->GetXaxis();897 898 const Int_t min1 = axe ->GetFirst();899 const Int_t max1 = axe ->GetLast();896 TAxis &axe = *h->GetXaxis(); 897 898 const Int_t min1 = axe.GetFirst(); 899 const Int_t max1 = axe.GetLast(); 900 900 const Int_t range1 = max1-min1; 901 901 … … 929 929 930 930 // 931 // Check for rebinning932 //933 if (nbins < 1)934 {935 axe->SetRange(min2,max2);936 return axe->GetLast()-axe->GetFirst();937 }938 939 //940 931 // Appying TAxis->SetRange before ReBin does not work ... 941 932 // But this workaround helps quite fine 942 933 // 943 const Axis_t min = h->GetBinLowEdge(min2); 944 const Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2); 945 946 const Int_t ngroup = (int)((max2-min2)*h->GetNbinsX()/nbins/(max1-min1)); 947 948 if (ngroup > 1) 949 h->Rebin(ngroup); 950 951 axe->SetRangeUser(min,max); 952 953 return axe->GetLast()-axe->GetFirst(); 934 Axis_t min = h->GetBinLowEdge(min2); 935 Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2); 936 937 Int_t nbins2 = max2-min2; 938 // 939 // Check for rebinning 940 // 941 if (nbins > 0) 942 { 943 const Int_t ngroup = (int)(nbins2*h->GetNbinsX()/nbins/(max1-min1)); 944 if (ngroup > 1) 945 { 946 h->Rebin(ngroup); 947 nbins2 /= ngroup; 948 } 949 } 950 951 Int_t newbins = 0; 952 FindGoodLimits(nbins2, newbins, min, max, kFALSE); 953 axe.SetRangeUser(min,max); 954 return axe.GetLast()-axe.GetFirst(); 954 955 } 955 956
Note:
See TracChangeset
for help on using the changeset viewer.