Changeset 2117 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 05/16/03 13:11:23 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MBinning.cc
r2106 r2117 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 218 ! Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2003 21 21 ! 22 22 ! … … 30 30 #include "MBinning.h" 31 31 32 #include <ctype.h> // tolower 32 33 #include <fstream.h> 33 34 … … 60 61 61 62 fType = kIsDefault; 63 } 64 65 void MBinning::SetEdges(const TAxis &axe) 66 { 67 const TArrayD &arr = *((TAxis&)axe).GetXbins(); 68 if (arr.GetSize()>0) 69 { 70 SetEdges(arr); 71 return; 72 } 73 74 SetEdges(axe.GetNbins(), axe.GetXmin(), axe.GetXmax()); 75 } 76 77 void MBinning::SetEdges(const TH1 &h, const Char_t axis='x') 78 { 79 TH1 &hist = (TH1&)h; // get rid of const qualifier 80 switch (tolower(axis)) 81 { 82 case 'x': 83 SetEdges(*hist.GetXaxis()); 84 return; 85 case 'y': 86 SetEdges(*hist.GetYaxis()); 87 return; 88 case 'z': 89 SetEdges(*hist.GetZaxis()); 90 return; 91 default: 92 *fLog << warn << "MBinning::SetEdges: Axis '" << axis << "' unknown... using x." << endl; 93 SetEdges(*hist.GetXaxis()); 94 } 62 95 } 63 96 -
trunk/MagicSoft/Mars/mhist/MBinning.h
r1962 r2117 7 7 8 8 #ifndef ROOT_TArrayD 9 #include "TArrayD.h"9 #include <TArrayD.h> 10 10 #endif 11 11 12 12 class TH1; 13 class TAxis; 13 14 14 15 class MBinning : public MParContainer … … 38 39 } 39 40 41 void SetEdges(const TAxis &axe); 42 void SetEdges(const TH1 &h, const Char_t axis='x'); 40 43 void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up); 41 44 void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up); -
trunk/MagicSoft/Mars/mhist/MFillH.cc
r2015 r2117 341 341 return kTRUE; 342 342 343 if (TestBit(kDoNotDisplay)) 344 return kTRUE; 345 343 346 fCanvas = &fDisplay->AddTab(fH->GetName()); 344 347 fH->Draw(); -
trunk/MagicSoft/Mars/mhist/MFillH.h
r1994 r2117 16 16 class MFillH : public MTask 17 17 { 18 public: 19 enum { 20 kDoNotDisplay = BIT(17) 21 }; 22 18 23 private: 19 24 MParContainer *fParContainer; // Pointer to the data container storing -
trunk/MagicSoft/Mars/mhist/MH.h
r2109 r2117 36 36 static TCanvas *MakeDefCanvas(const TObject *obj, 37 37 const UInt_t w=625, const UInt_t h=440); 38 39 // FIXME: * --> & !!! 38 40 39 41 static void SetBinning(TH1 *h, const MBinning *binsx); -
trunk/MagicSoft/Mars/mhist/MH3.cc
r2043 r2117 60 60 #include "MH3.h" 61 61 62 #include <ctype.h> // tolower 62 63 #include <fstream.h> 63 64 … … 636 637 return h; 637 638 } 639 640 TString MH3::GetRule(const Char_t axis='x') const 641 { 642 switch (tolower(axis)) 643 { 644 case 'x': 645 return fData[0] ? fData[0]->GetRule() : TString(""); 646 case 'y': 647 return fData[1] ? fData[1]->GetRule() : TString(""); 648 case 'z': 649 return fData[2] ? fData[2]->GetRule() : TString(""); 650 default: 651 return "<n/a>"; 652 } 653 } 654 655 // -------------------------------------------------------------------------- 656 // 657 // Returns the total number of bins in a histogram (excluding under- and 658 // overflow bins) 659 // 660 Int_t MH3::GetNbins() const 661 { 662 Int_t num = 1; 663 664 switch (fDimension) 665 { 666 case 3: 667 num *= fHist->GetNbinsZ()+2; 668 case 2: 669 num *= fHist->GetNbinsY()+2; 670 case 1: 671 num *= fHist->GetNbinsX()+2; 672 } 673 674 return num; 675 } 676 677 // -------------------------------------------------------------------------- 678 // 679 // Returns the total number of bins in a histogram (excluding under- and 680 // overflow bins) Return -1 if bin is underflow or overflow 681 // 682 Int_t MH3::FindFixBin(Double_t x, Double_t y, Double_t z) const 683 { 684 const TAxis &axex = *fHist->GetXaxis(); 685 const TAxis &axey = *fHist->GetYaxis(); 686 const TAxis &axez = *fHist->GetZaxis(); 687 688 Int_t binz = 0; 689 Int_t biny = 0; 690 Int_t binx = 0; 691 692 switch (fDimension) 693 { 694 case 3: 695 binz = axez.FindFixBin(z); 696 if (binz>axez.GetLast() || binz<axez.GetFirst()) 697 return -1; 698 case 2: 699 biny = axey.FindFixBin(y); 700 if (biny>axey.GetLast() || biny<axey.GetFirst()) 701 return -1; 702 case 1: 703 binx = axex.FindFixBin(x); 704 if (binx<axex.GetFirst() || binx>axex.GetLast()) 705 return -1; 706 } 707 708 const Int_t nx = fHist->GetNbinsX()+2; 709 const Int_t ny = fHist->GetNbinsY()+2; 710 711 return binx + nx*(biny +ny*binz); 712 } -
trunk/MagicSoft/Mars/mhist/MH3.h
r2043 r2117 17 17 protected: 18 18 // Could be const but root < 3.02/06 doesn't like this... 19 Int_t fDimension; // Number of dimensions of histogram 20 TH1 *fHist; // Histogram to fill 21 22 TString fDataMember[3]; // Data member which should be filled into the histogram x 19 Int_t fDimension; // Number of dimensions of histogram 20 TH1 *fHist; // Histogram to fill 23 21 MDataChain *fData[3]; // Object from which the data is filled 24 22 Double_t fScale[3]; // Scale for the three axis (eg unit) … … 44 42 45 43 Int_t GetDimension() const { return fDimension; } 44 Int_t GetNbins() const; 45 Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const; 46 46 47 47 void SetName(const char *name); … … 52 52 53 53 TString GetDataMember() const; 54 TString GetRule(const Char_t axis='x') const; 54 55 55 56 TH1 &GetHist() { return *fHist; }
Note:
See TracChangeset
for help on using the changeset viewer.