1 /*! 2 \class StMultiH1F 3 4 StMultiH1F allows multiple similar TH1F histograms to be 5 easily plotted on one graph 6 7 */ 8 9 #ifndef ClassStMultiH1F 10 #define ClassStMultiH1F 11 12 #include "TH2.h" 13 class TString; 14 #define StMultiH1FMaxBins 10 15 // change in MaxBins requires change in ClassDef version 16 17 class StMultiH1F : public TH2F { 18 public: 19 StMultiH1F(); 20 StMultiH1F(const char *name,const char *title,Int_t nbinsx,Axis_t xlow, 21 Axis_t xup,Int_t nbinsy); 22 StMultiH1F(const char *name,const char *title,Int_t nbinsx,Double_t *xbins, 23 Int_t nbinsy); 24 virtual ~StMultiH1F(); 25 virtual void Draw(Option_t *option=""); 26 virtual void Draw2F(Option_t *option="") { TH2F::Draw(option); } // access inherited 27 virtual void SetNames(Int_t ybin, const char* name) 28 { if (ybin<StMultiH1FMaxBins) names[ybin] = name; } 29 virtual void SetNames(Float_t ybin, const char* name) 30 { SetNames((Int_t) ybin, name); } 31 virtual const char* GetNames(Int_t ybin) const 32 { return (ybin<StMultiH1FMaxBins ? names[ybin].Data() : 0); } 33 virtual const char* GetNames(Float_t ybin) const 34 { return GetNames((Int_t) ybin); } 35 // Overload the Rebin() function to allow naming of y bins with TH2F pointer 36 virtual TH1* Rebin(Int_t ngroup, const char* newname) 37 { SetNames(ngroup, newname); return 0; } 38 virtual TH1* Rebin(Int_t ngroup, const char* newname, const Double_t* xbins) 39 { SetNames(ngroup, newname); return 0; } 40 // Overload the SetBarOffset() function to allow offsetting of y bins vertically 41 virtual void SetBarOffset(Float_t offset); 42 virtual Double_t GetNonZeroMinimum() const; 43 virtual Double_t GetNonZeroMaximum() const; 44 virtual void SavePrimitive(std::ostream& out, Option_t* option = ""); 45 virtual TH1F* GetSubHist(Int_t ybin) { return (subHists ? subHists[ybin] : 0); } 46 virtual TH1F* GetAHist() { return aHist; } 47 protected: 48 TString names[StMultiH1FMaxBins]; 49 Float_t fMOffset; 50 virtual TH1F* XProjection(const char* name, Int_t ybin=-1); 51 TH1F** subHists; //! 52 TH1F* aHist; //! 53 ClassDef(StMultiH1F,2) 54 }; 55 56 #endif 57 58 // $Id: StMultiH1F.h,v 1.11 2016/05/27 18:02:41 genevb Exp $ 59 // $Log: StMultiH1F.h,v $ 60 // Revision 1.11 2016/05/27 18:02:41 genevb 61 // Garbage collection (Coverity), remove unnecessary ROOT types 62 // 63 // Revision 1.10 2013/11/22 16:48:39 genevb 64 // Access to inherited Draw() functions 65 // 66 // Revision 1.9 2013/11/21 22:22:48 genevb 67 // Protect against array out-of-bounds, use inherited axis handles 68 // 69 // Revision 1.8 2012/06/11 15:05:34 fisyak 70 // std namespace 71 // 72 // Revision 1.7 2008/07/09 20:52:38 genevb 73 // Implement SavePrimitive functions 74 // 75 // Revision 1.6 2006/08/10 20:46:24 genevb 76 // additional Rebin() interface for TH1.h vers. 1.79, ROOT 5.13 77 // 78 // Revision 1.5 2002/04/23 01:59:16 genevb 79 // New offset abilities 80 // 81 // Revision 1.4 2000/09/05 19:54:46 genevb 82 // Erroneous delete in destructor removed 83 // 84 // Revision 1.3 2000/08/28 19:21:05 genevb 85 // Improved projection code 86 // 87 // Revision 1.2 2000/08/25 15:46:42 genevb 88 // Added stats box, legend names 89 // 90 // Revision 1.1 2000/07/26 22:00:28 lansdell 91 // new multi-hist class for superimposing the x-projections of y-bins (of a TH2F histogram) into one TH1F histogram 92 // 93 94