Changeset 2530
- Timestamp:
- 11/19/03 00:11:36 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/NEWS
r2521 r2530 8 8 - added classes to read and interprete central control report files 9 9 (Directory: mreport, Base-Class: MReport, Reader: MReportFileRead, ...) 10 11 - added classes for light calibration (MCalibration* and 12 MHCalibration*) by Markus Gaug. Further work has to be and will 13 be done soon. 10 14 11 15 -
trunk/MagicSoft/Mars/mhist/MH.cc
r2525 r2530 893 893 Int_t MH::CutEdges(TH1 *h, Int_t nbins) 894 894 { 895 896 TAxis* axe = h->GetXaxis(); 897 898 Int_t min1 = axe->GetFirst(); 899 Int_t max1 = axe->GetLast(); 900 Int_t range1 = max1-min1; 901 902 // 903 // Check for useless zeros 904 // 905 if (range1 == 0) 906 return 0; 907 908 Int_t min2 = 0; 909 Int_t max2 = 0; 910 911 for (int i=min1; i<=max1; i++) 912 { 913 Double_t x = h->GetBinContent(i); 914 if (x != 0.) 895 TAxis* axe = h->GetXaxis(); 896 897 const Int_t min1 = axe->GetFirst(); 898 const Int_t max1 = axe->GetLast(); 899 const Int_t range1 = max1-min1; 900 901 // 902 // Check for useless zeros 903 // 904 if (range1 == 0) 905 return 0; 906 907 Int_t min2 = 0; 908 for (int i=min1; i<=max1; i++) 909 if (h->GetBinContent(i) != 0) 915 910 { 916 min2 = i;917 break;911 min2 = i; 912 break; 918 913 } 919 } 920 921 // 922 // If the histogram consists of zeros only 923 // 924 if (min2 == max1) 925 return 0; 926 927 for (int i=max1; i>=min2; i--) 928 { 929 Double_t x = h->GetBinContent(i); 930 if (x != 0.) 914 915 // 916 // If the histogram consists of zeros only 917 // 918 if (min2 == max1) 919 return 0; 920 921 Int_t max2 = 0; 922 for (int i=max1; i>=min2; i--) 923 if (h->GetBinContent(i) != 0) 931 924 { 932 max2 = i;933 break;925 max2 = i; 926 break; 934 927 } 935 } 936 937 // 938 // Check for rebinning 939 // 940 if (nbins < 1) 941 { 942 axe->SetRange(min2,max2); 943 return axe->GetLast()-axe->GetFirst(); 944 } 945 946 // 947 // Appying TAxis->SetRange before ReBin does not work ... 948 // But this workaround helps quite fine 949 // 950 Axis_t min = h->GetBinLowEdge(min2); 951 Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2); 952 953 Int_t ngroup = (int)((max2-min2)*h->GetNbinsX()/nbins/(max1-min1)); 954 955 if (ngroup > 1) 956 h->Rebin(ngroup); 957 958 axe->SetRangeUser(min,max); 959 960 return axe->GetLast()-axe->GetFirst(); 928 929 // 930 // Check for rebinning 931 // 932 if (nbins < 1) 933 { 934 axe->SetRange(min2,max2); 935 return axe->GetLast()-axe->GetFirst(); 936 } 937 938 // 939 // Appying TAxis->SetRange before ReBin does not work ... 940 // But this workaround helps quite fine 941 // 942 const Axis_t min = h->GetBinLowEdge(min2); 943 const Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2); 944 945 const Int_t ngroup = (int)((max2-min2)*h->GetNbinsX()/nbins/(max1-min1)); 946 947 if (ngroup > 1) 948 h->Rebin(ngroup); 949 950 axe->SetRangeUser(min,max); 951 952 return axe->GetLast()-axe->GetFirst(); 961 953 } 962 954
Note:
See TracChangeset
for help on using the changeset viewer.