Changeset 9195 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 12/21/08 18:09:49 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mhbase
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r9186 r9195 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.4 1 2008-12-02 11:22:15tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.42 2008-12-21 18:09:49 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 1616 1616 CreateGradientColorTable(8, s, r, g, b, ncol); 1617 1617 found=kTRUE; 1618 } 1618 }/* 1619 if (paletteName.Contains("glows2")) 1620 { 1621 double s[10] = {0.00, 0.17, 0.35, 0.50, 0.65, 0.73, 0.77, 0.85, 0.92, 1.00}; 1622 double r[10] = {0.09, 0.18, 0.09, 0.00, 0.00, 0.20, 0.55, 0.85, 1.00, 1.00}; 1623 double g[10] = {0.81, 0.51, 0.27, 0.00, 0.00, 0.05, 0.10, 0.20, 0.73, 1.00}; 1624 double b[10] = {0.70, 0.40, 0.02, 0.00, 0.27, 0.40, 0.35, 0.16, 0.03, 1.00}; 1625 gStyle->CreateGradientColorTable(10, s, r, g, b, ncol); 1626 found=kTRUE; 1627 }*/ 1619 1628 1620 1629 if (paletteName.Contains("redish")) … … 1668 1677 gLog << warn << "MH::SetPalette: Palette " << paletteName << " unknown... ignored." << endl; 1669 1678 } 1679 1680 // -------------------------------------------------------------------------- 1681 // 1682 // Unfortunately in TH1::GetObjectInfo the buffer is just 64 characters 1683 // which is sometimes to small. This is just a copy of the code but the 1684 // buffer has been increased to 128 which should fairly be enough. 1685 // 1686 // Necessary for root <= 5.22/00 1687 // 1688 char *MH::GetObjectInfoH(Int_t px, Int_t py, const TH1 &h) 1689 { 1690 const TH1 *fH = &h; 1691 const TAxis *fXaxis = h.GetXaxis(); 1692 const TAxis *fYaxis = h.GetYaxis(); 1693 1694 // Redefines TObject::GetObjectInfo. 1695 // Displays the histogram info (bin number, contents, integral up to bin 1696 // corresponding to cursor position px,py 1697 1698 if (!gPad) return (char*)""; 1699 1700 static char info[128]; 1701 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px)); 1702 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py)); 1703 Double_t x1 = gPad->PadtoX(gPad->AbsPixeltoX(px+1)); 1704 const char *drawOption = fH->GetDrawOption(); 1705 Double_t xmin, xmax, uxmin,uxmax; 1706 Double_t ymin, ymax, uymin,uymax; 1707 if (fH->GetDimension() == 2) { 1708 if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0 1709 || strncmp(drawOption,"CONT",4) == 0) { 1710 uxmin=gPad->GetUxmin(); 1711 uxmax=gPad->GetUxmax(); 1712 xmin = fXaxis->GetBinLowEdge(fXaxis->GetFirst()); 1713 xmax = fXaxis->GetBinUpEdge(fXaxis->GetLast()); 1714 x = xmin +(xmax-xmin)*(x-uxmin)/(uxmax-uxmin); 1715 uymin=gPad->GetUymin(); 1716 uymax=gPad->GetUymax(); 1717 ymin = fYaxis->GetBinLowEdge(fYaxis->GetFirst()); 1718 ymax = fYaxis->GetBinUpEdge(fYaxis->GetLast()); 1719 y = ymin +(ymax-ymin)*(y-uymin)/(uymax-uymin); 1720 } 1721 } 1722 Int_t binx,biny,binmin,binx1; 1723 if (gPad->IsVertical()) { 1724 binx = fXaxis->FindFixBin(x); 1725 binmin = fXaxis->GetFirst(); 1726 binx1 = fXaxis->FindFixBin(x1); 1727 // special case if more than 1 bin in x per pixel 1728 if (binx1-binx>1 && fH->GetDimension() == 1) { 1729 Double_t binval=fH->GetBinContent(binx); 1730 Int_t binnear=binx; 1731 for (Int_t ibin=binx+1; ibin<binx1; ibin++) { 1732 Double_t binvaltmp = fH->GetBinContent(ibin); 1733 if (TMath::Abs(y-binvaltmp) < TMath::Abs(y-binval)) { 1734 binval=binvaltmp; 1735 binnear=ibin; 1736 } 1737 } 1738 binx = binnear; 1739 } 1740 } else { 1741 x1 = gPad->PadtoY(gPad->AbsPixeltoY(py+1)); 1742 binx = fXaxis->FindFixBin(y); 1743 binmin = fXaxis->GetFirst(); 1744 binx1 = fXaxis->FindFixBin(x1); 1745 // special case if more than 1 bin in x per pixel 1746 if (binx1-binx>1 && fH->GetDimension() == 1) { 1747 Double_t binval=fH->GetBinContent(binx); 1748 Int_t binnear=binx; 1749 for (Int_t ibin=binx+1; ibin<binx1; ibin++) { 1750 Double_t binvaltmp = fH->GetBinContent(ibin); 1751 if (TMath::Abs(x-binvaltmp) < TMath::Abs(x-binval)) { 1752 binval=binvaltmp; 1753 binnear=ibin; 1754 } 1755 } 1756 binx = binnear; 1757 } 1758 } 1759 if (fH->GetDimension() == 1) { 1760 Double_t integ = 0; 1761 for (Int_t bin=binmin;bin<=binx;bin++) {integ += fH->GetBinContent(bin);} 1762 sprintf(info,"(x=%g, y=%g, binx=%d, binc=%g, Sum=%g)",x,y,binx,fH->GetBinContent(binx),integ); 1763 } else { 1764 biny = fYaxis->FindFixBin(y); 1765 sprintf(info,"(x=%g, y=%g, binx=%d, biny=%d, binc=%g)",x,y,binx,biny,fH->GetCellContent(binx,biny)); 1766 } 1767 return info; 1768 } 1769 1770 // -------------------------------------------------------------------------- 1771 // 1772 // Unfortunately in TProfile::GetObjectInfo the buffer is just 64 characters 1773 // which is sometimes to small. This is just a copy of the code but the 1774 // buffer has been increased to 128 which should fairly be enough. 1775 // 1776 // Necessary for root <= 5.22/00 1777 // 1778 char *MH::GetObjectInfoP(Int_t px, Int_t py, const TProfile &p) 1779 { 1780 if (!gPad) return (char*)""; 1781 static char info[128]; 1782 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px)); 1783 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py)); 1784 Int_t binx = p.GetXaxis()->FindFixBin(x); 1785 sprintf(info,"(x=%g, y=%g, binx=%d, binc=%g, bine=%g, binn=%d)", x, y, binx, p.GetBinContent(binx), p.GetBinError(binx), (Int_t)p.GetBinEntries(binx)); 1786 return info; 1787 } 1788 1789 // -------------------------------------------------------------------------- 1790 // 1791 // Unfortunately TH1::GetObjectInfo and TProfile::GetObjectInfo can 1792 // result in buffer ovwerflows therefor we have to re-implement these 1793 // function by our own. 1794 // 1795 // Necessary for root <= 5.22/00 1796 // 1797 char *MH::GetObjectInfo(Int_t px, Int_t py, const TObject &o) 1798 { 1799 if (!o.InheritsFrom(TH1::Class())) 1800 return o.GetObjectInfo(px, py); 1801 1802 if (o.InheritsFrom(TProfile::Class())) 1803 return GetObjectInfoP(px, py, static_cast<const TProfile&>(o)); 1804 1805 if (o.InheritsFrom("MHCamera")) 1806 return o.GetObjectInfo(px, py); 1807 1808 if (o.InheritsFrom(TH1::Class())) 1809 return GetObjectInfoH(px, py, static_cast<const TH1&>(o)); 1810 1811 return "MH::GetObjectInfo: unknown class."; 1812 } -
trunk/MagicSoft/Mars/mhbase/MH3.cc
r9153 r9195 146 146 #include "MH3.h" 147 147 148 #include <ctype.h> // tolower 148 #include <ctype.h> // tolower 149 #include <stdlib.h> // atoi (Ubuntu 8.10) 149 150 #include <fstream> 150 151 -
trunk/MagicSoft/Mars/mhbase/MHn.h
r9153 r9195 21 21 void InitHist(); 22 22 23 Bool_t InitName(Int_t n, const char *n );24 Bool_t InitTitle(Int_t n, const char *t );23 Bool_t InitName(Int_t n, const char *name); 24 Bool_t InitTitle(Int_t n, const char *title); 25 25 Bool_t SetDrawOption(Int_t n, const char *opt); 26 26
Note:
See TracChangeset
for help on using the changeset viewer.