Logo ROOT   6.08/07
Reference Guide
TH1Merger.h
Go to the documentation of this file.
1 // Helper clas implementing some of the TH1 functionality
2 
3 
4 #include "TH1.h"
5 #include "TList.h"
6 
7 class TH1Merger{
8 
9 public:
10 
11  enum EMergerType {
12  kNotCompatible = -1, // histogram arenot compatible and cannot be merged
13  kAllSameAxes = 0, // histogram have all some axes
14  kAllNoLimits = 1, // all histogram don't have limits (the buffer is used)
15  kHasNewLimits = 2, // all histogram don't have limits (the buffer is used)
16  kAllLabel = 3 // histogram have labels all axis
17  };
18 
19  static Bool_t AxesHaveLimits(const TH1 * h);
20 
21  static Int_t FindFixBinNumber(Int_t ibin, const TAxis & inAxis, const TAxis & outAxis) {
22  // should I ceck in case of underflow/overflow if underflow/overflow values of input axis
23  // outside output axis ?
24  if (ibin == 0 ) return 0; // return underflow
25  if (ibin == inAxis.GetNbins()+1 ) return outAxis.GetNbins()+1; // return overflow
26  return outAxis.FindFixBin(inAxis.GetBinCenter(ibin));
27  }
28 
29  // find bin number estending the axis
30  static Int_t FindBinNumber(Int_t ibin, const TAxis & inAxis, TAxis & outAxis) {
31  // should I ceck in case of underflow/overflow if underflow/overflow values of input axis
32  // outside output axis ?
33  if (ibin == 0 ) return 0; // return underflow
34  if (ibin == inAxis.GetNbins()+1 ) return outAxis.GetNbins()+1; // return overflow
35  return outAxis.FindBin(inAxis.GetBinCenter(ibin));
36  }
37 
38 
40  fH0(&h),
42  fNewAxisFlag(0)
43  {
44  fInputList.AddAll(&l);
45  }
46 
48  if (fHClone) delete fHClone;
49  }
50 
51  // function douing the actual merge
53 
54 private:
55 
57 
58  void DefineNewAxes();
59 
61 
63 
65 
67 
68 
69  TH1 * fH0; //! histogram on which the list is merged
70  TH1 * fHClone; //! copy of fH0 - managed by this class
71  TList fInputList; // input histogram List
76 };
TH1 * fHClone
histogram on which the list is merged
Definition: TH1Merger.h:70
static Bool_t AxesHaveLimits(const TH1 *h)
Definition: TH1Merger.cxx:14
void DefineNewAxes()
Function to define new histogram axis when merging It is call only in case of merging with different ...
Definition: TH1Merger.cxx:301
TAxis fNewYAxis
Definition: TH1Merger.h:73
TH1 * h
Definition: legend2.C:5
Bool_t LabelMerge()
Merge histograms with labels.
Definition: TH1Merger.cxx:557
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Definition: TCollection.cxx:58
static Int_t FindFixBinNumber(Int_t ibin, const TAxis &inAxis, const TAxis &outAxis)
Definition: TH1Merger.h:21
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TList fInputList
copy of fH0 - managed by this class
Definition: TH1Merger.h:71
~TH1Merger()
Definition: TH1Merger.h:47
TH1Merger(TH1 &h, TCollection &l)
Definition: TH1Merger.h:39
TAxis fNewZAxis
Definition: TH1Merger.h:74
Bool_t operator()()
Function performing the actual merge.
Definition: TH1Merger.cxx:22
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
Bool_t DifferentAxesMerge()
Merged histogram when axis can be different.
Definition: TH1Merger.cxx:466
A doubly linked list.
Definition: TList.h:47
UInt_t fNewAxisFlag
Definition: TH1Merger.h:75
TAxis fNewXAxis
Definition: TH1Merger.h:72
Class to manage histogram axis.
Definition: TAxis.h:36
Collection abstract base class.
Definition: TCollection.h:48
unsigned int UInt_t
Definition: RtypesCore.h:42
TLine * l
Definition: textangle.C:4
Bool_t SameAxesMerge()
Definition: TH1Merger.cxx:413
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:279
Bool_t BufferMerge()
Definition: TH1Merger.cxx:367
EMergerType ExamineHistograms()
Examine the list of histograms to find out which type of Merge we need to do Pass the input list cont...
Definition: TH1Merger.cxx:69
The TH1 histogram class.
Definition: TH1.h:80
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:405
static Int_t FindBinNumber(Int_t ibin, const TAxis &inAxis, TAxis &outAxis)
Definition: TH1Merger.h:30
#define nullptr
Definition: Rtypes.h:87
TH1 * fH0
Definition: TH1Merger.h:69
Int_t GetNbins() const
Definition: TAxis.h:127