Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TH1.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 26/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TH1
13 #define ROOT_TH1
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TH1 //
19 // //
20 // 1-Dim histogram base class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TAxis.h"
25 
26 #include "TAttLine.h"
27 
28 #include "TAttFill.h"
29 
30 #include "TAttMarker.h"
31 
32 #include "TArrayC.h"
33 #include "TArrayS.h"
34 #include "TArrayI.h"
35 #include "TArrayF.h"
36 #include "TArrayD.h"
37 #include "Foption.h"
38 
39 #include "TVectorFfwd.h"
40 #include "TVectorDfwd.h"
41 
42 #include "TFitResultPtr.h"
43 
44 #include <float.h>
45 
46 class TF1;
47 class TH1D;
48 class TBrowser;
49 class TDirectory;
50 class TList;
51 class TCollection;
52 class TVirtualFFT;
53 class TVirtualHistPainter;
54 
55 
56 class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
57 
58 public:
59 
60  // enumeration specifying type of statistics for bin errors
61  enum EBinErrorOpt {
62  kNormal = 0, ///< errors with Normal (Wald) approximation: errorUp=errorLow= sqrt(N)
63  kPoisson = 1 , ///< errors from Poisson interval at 68.3% (1 sigma)
64  kPoisson2 = 2 ///< errors from Poisson interval at 95% CL (~ 2 sigma)
65  };
66 
67  // enumeration specifying which axes can be extended
68  enum {
69  kNoAxis = 0, ///< NOTE: Must always be 0 !!!
70  kXaxis = BIT(0),
71  kYaxis = BIT(1),
72  kZaxis = BIT(2),
73  kAllAxes = kXaxis | kYaxis | kZaxis
74  };
75 
76  /// Enumeration specifying the way to treat statoverflow
77  enum EStatOverflows {
78  kIgnore = 0, ///< Override global flag ignoring the overflows
79  kConsider = 1, ///< Override global flag considering the overflows
80  kNeutral = 2, ///< Adapt to the global flag
81  };
82 
83  friend class TH1Merger;
84 
85 protected:
86  Int_t fNcells; ///< number of bins(1D), cells (2D) +U/Overflows
87  TAxis fXaxis; ///< X axis descriptor
88  TAxis fYaxis; ///< Y axis descriptor
89  TAxis fZaxis; ///< Z axis descriptor
90  Short_t fBarOffset; ///< (1000*offset) for bar charts or legos
91  Short_t fBarWidth; ///< (1000*width) for bar charts or legos
92  Double_t fEntries; ///< Number of entries
93  Double_t fTsumw; ///< Total Sum of weights
94  Double_t fTsumw2; ///< Total Sum of squares of weights
95  Double_t fTsumwx; ///< Total Sum of weight*X
96  Double_t fTsumwx2; ///< Total Sum of weight*X*X
97  Double_t fMaximum; ///< Maximum value for plotting
98  Double_t fMinimum; ///< Minimum value for plotting
99  Double_t fNormFactor; ///< Normalization factor
100  TArrayD fContour; ///< Array to display contour levels
101  TArrayD fSumw2; ///< Array of sum of squares of weights
102  TString fOption; ///< histogram options
103  TList *fFunctions; ///<->Pointer to list of functions (fits and user)
104  Int_t fBufferSize; ///< fBuffer size
105  Double_t *fBuffer; ///<[fBufferSize] entry buffer
106  TDirectory *fDirectory; ///<!Pointer to directory holding this histogram
107  Int_t fDimension; ///<!Histogram dimension (1, 2 or 3 dim)
108  Double_t *fIntegral; ///<!Integral of bins used by GetRandom
109  TVirtualHistPainter *fPainter; ///<!pointer to histogram painter
110  EBinErrorOpt fBinStatErrOpt; ///< option for bin statistical errors
111  EStatOverflows fStatOverflows; ///< per object flag to use under/overflows in statistics
112  static Int_t fgBufferSize; ///<!default buffer size for automatic histograms
113  static Bool_t fgAddDirectory; ///<!flag to add histograms to the directory
114  static Bool_t fgStatOverflows; ///<!flag to use under/overflows in statistics
115  static Bool_t fgDefaultSumw2; ///<!flag to call TH1::Sumw2 automatically at histogram creation time
116 
117 public:
118  static Int_t FitOptionsMake(Option_t *option, Foption_t &Foption);
119 
120 private:
121  Int_t AxisChoice(Option_t *axis) const;
122  void Build();
123 
124  TH1(const TH1&);
125  TH1& operator=(const TH1&); // Not implemented
126 
127 
128 protected:
129  TH1();
130  TH1(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
131  TH1(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
132  TH1(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
133  virtual Int_t BufferFill(Double_t x, Double_t w);
134  virtual Bool_t FindNewAxisLimits(const TAxis* axis, const Double_t point, Double_t& newMin, Double_t &newMax);
135  virtual void SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option = "");
136  static Bool_t RecomputeAxisLimits(TAxis& destAxis, const TAxis& anAxis);
137  static Bool_t SameLimitsAndNBins(const TAxis& axis1, const TAxis& axis2);
138  Bool_t IsEmpty() const;
139 
140  inline static Double_t AutoP2GetPower2(Double_t x, Bool_t next = kTRUE);
141  inline static Int_t AutoP2GetBins(Int_t n);
142  virtual Int_t AutoP2FindLimits(Double_t min, Double_t max);
143 
144  virtual Double_t DoIntegral(Int_t ix1, Int_t ix2, Int_t iy1, Int_t iy2, Int_t iz1, Int_t iz2, Double_t & err,
145  Option_t * opt, Bool_t doerr = kFALSE) const;
146 
147  virtual void DoFillN(Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1);
148  Bool_t GetStatOverflowsBehaviour() const { return EStatOverflows::kNeutral == fStatOverflows ? fgStatOverflows : EStatOverflows::kConsider == fStatOverflows; }
149 
150  static bool CheckAxisLimits(const TAxis* a1, const TAxis* a2);
151  static bool CheckBinLimits(const TAxis* a1, const TAxis* a2);
152  static bool CheckBinLabels(const TAxis* a1, const TAxis* a2);
153  static bool CheckEqualAxes(const TAxis* a1, const TAxis* a2);
154  static bool CheckConsistentSubAxes(const TAxis *a1, Int_t firstBin1, Int_t lastBin1, const TAxis *a2, Int_t firstBin2=0, Int_t lastBin2=0);
155  static bool CheckConsistency(const TH1* h1, const TH1* h2);
156 
157 public:
158  // TH1 status bits
159  enum EStatusBits {
160  kNoStats = BIT(9), ///< don't draw stats box
161  kUserContour = BIT(10), ///< user specified contour levels
162  // kCanRebin = BIT(11), ///< FIXME DEPRECATED - to be removed, replaced by SetCanExtend / CanExtendAllAxes
163  kLogX = BIT(15), ///< X-axis in log scale
164  kIsZoomed = BIT(16), ///< bit set when zooming on Y axis
165  kNoTitle = BIT(17), ///< don't draw the histogram title
166  kIsAverage = BIT(18), ///< Bin contents are average (used by Add)
167  kIsNotW = BIT(19), ///< Histogram is forced to be not weighted even when the histogram is filled with weighted
168  /// different than 1.
169  kAutoBinPTwo = BIT(20), ///< Use Power(2)-based algorithm for autobinning
170  kIsHighlight = BIT(21) ///< bit set if histo is highlight
171  };
172  // size of statistics data (size of array used in GetStats()/ PutStats )
173  // s[0] = sumw s[1] = sumw2
174  // s[2] = sumwx s[3] = sumwx2
175  // s[4] = sumwy s[5] = sumwy2 s[6] = sumwxy
176  // s[7] = sumwz s[8] = sumwz2 s[9] = sumwxz s[10] = sumwyz
177  // s[11] = sumwt s[12] = sumwt2 (11 and 12 used only by TProfile3D)
178  enum {
179  kNstat = 13 // size of statistics data (up to TProfile3D)
180  };
181 
182 
183  virtual ~TH1();
184 
185  virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
186  virtual Bool_t Add(const TH1 *h1, Double_t c1=1);
187  virtual Bool_t Add(const TH1 *h, const TH1 *h2, Double_t c1=1, Double_t c2=1); // *MENU*
188  virtual void AddBinContent(Int_t bin);
189  virtual void AddBinContent(Int_t bin, Double_t w);
190  static void AddDirectory(Bool_t add=kTRUE);
191  static Bool_t AddDirectoryStatus();
192  virtual void Browse(TBrowser *b);
193  virtual Bool_t CanExtendAllAxes() const;
194  virtual Double_t Chi2Test(const TH1* h2, Option_t *option = "UU", Double_t *res = 0) const;
195  virtual Double_t Chi2TestX(const TH1* h2, Double_t &chi2, Int_t &ndf, Int_t &igood,Option_t *option = "UU", Double_t *res = 0) const;
196  virtual Double_t Chisquare(TF1 * f1, Option_t *option = "") const;
197  virtual void ClearUnderflowAndOverflow();
198  virtual Double_t ComputeIntegral(Bool_t onlyPositive = false);
199  TObject* Clone(const char* newname=0) const;
200  virtual void Copy(TObject &hnew) const;
201  virtual void DirectoryAutoAdd(TDirectory *);
202  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
203  virtual Bool_t Divide(TF1 *f1, Double_t c1=1);
204  virtual Bool_t Divide(const TH1 *h1);
205  virtual Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
206  virtual void Draw(Option_t *option="");
207  virtual TH1 *DrawCopy(Option_t *option="", const char * name_postfix = "_copy") const;
208  virtual TH1 *DrawNormalized(Option_t *option="", Double_t norm=1) const;
209  virtual void DrawPanel(); // *MENU*
210  virtual Int_t BufferEmpty(Int_t action=0);
211  virtual void Eval(TF1 *f1, Option_t *option="");
212  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
213  virtual void ExtendAxis(Double_t x, TAxis *axis);
214  virtual TH1 *FFT(TH1* h_output, Option_t *option);
215  virtual Int_t Fill(Double_t x);
216  virtual Int_t Fill(Double_t x, Double_t w);
217  virtual Int_t Fill(const char *name, Double_t w);
218  virtual void FillN(Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1);
219  virtual void FillN(Int_t, const Double_t *, const Double_t *, const Double_t *, Int_t) {;}
220  virtual void FillRandom(const char *fname, Int_t ntimes=5000);
221  virtual void FillRandom(TH1 *h, Int_t ntimes=5000);
222  virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0);
223  virtual Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
224  virtual Int_t FindFirstBinAbove(Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const;
225  virtual Int_t FindLastBinAbove (Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const;
226  virtual TObject *FindObject(const char *name) const;
227  virtual TObject *FindObject(const TObject *obj) const;
228  virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption="", Double_t xmin=0, Double_t xmax=0); // *MENU*
229  virtual TFitResultPtr Fit(TF1 *f1 ,Option_t *option="" ,Option_t *goption="", Double_t xmin=0, Double_t xmax=0);
230  virtual void FitPanel(); // *MENU*
231  TH1 *GetAsymmetry(TH1* h2, Double_t c2=1, Double_t dc2=0);
232  Int_t GetBufferLength() const {return fBuffer ? (Int_t)fBuffer[0] : 0;}
233  Int_t GetBufferSize () const {return fBufferSize;}
234  const Double_t *GetBuffer() const {return fBuffer;}
235  static Int_t GetDefaultBufferSize();
236  virtual Double_t *GetIntegral();
237  TH1 *GetCumulative(Bool_t forward = kTRUE, const char* suffix = "_cumulative") const;
238 
239  TList *GetListOfFunctions() const { return fFunctions; }
240 
241  virtual Int_t GetNdivisions(Option_t *axis="X") const;
242  virtual Color_t GetAxisColor(Option_t *axis="X") const;
243  virtual Color_t GetLabelColor(Option_t *axis="X") const;
244  virtual Style_t GetLabelFont(Option_t *axis="X") const;
245  virtual Float_t GetLabelOffset(Option_t *axis="X") const;
246  virtual Float_t GetLabelSize(Option_t *axis="X") const;
247  virtual Style_t GetTitleFont(Option_t *axis="X") const;
248  virtual Float_t GetTitleOffset(Option_t *axis="X") const;
249  virtual Float_t GetTitleSize(Option_t *axis="X") const;
250  virtual Float_t GetTickLength(Option_t *axis="X") const;
251  virtual Float_t GetBarOffset() const {return Float_t(0.001*Float_t(fBarOffset));}
252  virtual Float_t GetBarWidth() const {return Float_t(0.001*Float_t(fBarWidth));}
253  virtual Int_t GetContour(Double_t *levels=0);
254  virtual Double_t GetContourLevel(Int_t level) const;
255  virtual Double_t GetContourLevelPad(Int_t level) const;
256 
257  virtual Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const;
258  virtual void GetBinXYZ(Int_t binglobal, Int_t &binx, Int_t &biny, Int_t &binz) const;
259  virtual Double_t GetBinCenter(Int_t bin) const;
260  virtual Double_t GetBinContent(Int_t bin) const;
261  virtual Double_t GetBinContent(Int_t bin, Int_t) const { return GetBinContent(bin); }
262  virtual Double_t GetBinContent(Int_t bin, Int_t, Int_t) const { return GetBinContent(bin); }
263  virtual Double_t GetBinError(Int_t bin) const;
264  virtual Double_t GetBinError(Int_t binx, Int_t biny) const { return GetBinError(GetBin(binx, biny)); } // for 2D histograms only
265  virtual Double_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(GetBin(binx, biny, binz)); } // for 3D histograms only
266  virtual Double_t GetBinErrorLow(Int_t bin) const;
267  virtual Double_t GetBinErrorUp(Int_t bin) const;
268  virtual EBinErrorOpt GetBinErrorOption() const { return fBinStatErrOpt; }
269  virtual Double_t GetBinLowEdge(Int_t bin) const;
270  virtual Double_t GetBinWidth(Int_t bin) const;
271  virtual Double_t GetBinWithContent(Double_t c, Int_t &binx, Int_t firstx=0, Int_t lastx=0,Double_t maxdiff=0) const;
272  virtual void GetCenter(Double_t *center) const;
273  static Bool_t GetDefaultSumw2();
274  TDirectory *GetDirectory() const {return fDirectory;}
275  virtual Double_t GetEntries() const;
276  virtual Double_t GetEffectiveEntries() const;
277  virtual TF1 *GetFunction(const char *name) const;
278  virtual Int_t GetDimension() const { return fDimension; }
279  virtual Double_t GetKurtosis(Int_t axis=1) const;
280  virtual void GetLowEdge(Double_t *edge) const;
281  virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const;
282  virtual Int_t GetMaximumBin() const;
283  virtual Int_t GetMaximumBin(Int_t &locmax, Int_t &locmay, Int_t &locmaz) const;
284  virtual Double_t GetMaximumStored() const {return fMaximum;}
285  virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const;
286  virtual Int_t GetMinimumBin() const;
287  virtual Int_t GetMinimumBin(Int_t &locmix, Int_t &locmiy, Int_t &locmiz) const;
288  virtual Double_t GetMinimumStored() const {return fMinimum;}
289  virtual void GetMinimumAndMaximum(Double_t& min, Double_t& max) const;
290  virtual Double_t GetMean(Int_t axis=1) const;
291  virtual Double_t GetMeanError(Int_t axis=1) const;
292  virtual Int_t GetNbinsX() const {return fXaxis.GetNbins();}
293  virtual Int_t GetNbinsY() const {return fYaxis.GetNbins();}
294  virtual Int_t GetNbinsZ() const {return fZaxis.GetNbins();}
295  virtual Int_t GetNcells() const {return fNcells; }
296  virtual Double_t GetNormFactor() const {return fNormFactor;}
297  virtual char *GetObjectInfo(Int_t px, Int_t py) const;
298  Option_t *GetOption() const {return fOption.Data();}
299 
300  TVirtualHistPainter *GetPainter(Option_t *option="");
301 
302  virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum=0);
303  virtual Double_t GetRandom() const;
304  virtual void GetStats(Double_t *stats) const;
305  virtual Double_t GetStdDev(Int_t axis=1) const;
306  virtual Double_t GetStdDevError(Int_t axis=1) const;
307  virtual Double_t GetSumOfWeights() const;
308  virtual TArrayD *GetSumw2() {return &fSumw2;}
309  virtual const TArrayD *GetSumw2() const {return &fSumw2;}
310  virtual Int_t GetSumw2N() const {return fSumw2.fN;}
311  Double_t GetRMS(Int_t axis=1) const { return GetStdDev(axis); }
312  Double_t GetRMSError(Int_t axis=1) const { return GetStdDevError(axis); }
313 
314  virtual Double_t GetSkewness(Int_t axis=1) const;
315  EStatOverflows GetStatOverflows() const {return fStatOverflows; }; ///< Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more information.
316  TAxis* GetXaxis() { return &fXaxis; }
317  TAxis* GetYaxis() { return &fYaxis; }
318  TAxis* GetZaxis() { return &fZaxis; }
319  const TAxis* GetXaxis() const { return &fXaxis; }
320  const TAxis* GetYaxis() const { return &fYaxis; }
321  const TAxis* GetZaxis() const { return &fZaxis; }
322  virtual Double_t Integral(Option_t *option="") const;
323  virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const;
324  virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Double_t & err, Option_t *option="") const;
325  virtual Double_t Interpolate(Double_t x) const;
326  virtual Double_t Interpolate(Double_t x, Double_t y) const;
327  virtual Double_t Interpolate(Double_t x, Double_t y, Double_t z) const;
328  Bool_t IsBinOverflow(Int_t bin, Int_t axis = 0) const;
329  Bool_t IsBinUnderflow(Int_t bin, Int_t axis = 0) const;
330  virtual Bool_t IsHighlight() const { return TestBit(kIsHighlight); }
331  virtual Double_t AndersonDarlingTest(const TH1 *h2, Option_t *option="") const;
332  virtual Double_t AndersonDarlingTest(const TH1 *h2, Double_t &advalue) const;
333  virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const;
334  virtual void LabelsDeflate(Option_t *axis="X");
335  virtual void LabelsInflate(Option_t *axis="X");
336  virtual void LabelsOption(Option_t *option="h", Option_t *axis="X");
337  virtual Long64_t Merge(TCollection *list) { return Merge(list,""); }
338  Long64_t Merge(TCollection *list, Option_t * option);
339  virtual Bool_t Multiply(TF1 *f1, Double_t c1=1);
340  virtual Bool_t Multiply(const TH1 *h1);
341  virtual Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
342  virtual void Paint(Option_t *option="");
343  virtual void Print(Option_t *option="") const;
344  virtual void PutStats(Double_t *stats);
345  virtual TH1 *Rebin(Int_t ngroup=2, const char*newname="", const Double_t *xbins=0); // *MENU*
346  virtual TH1 *RebinX(Int_t ngroup=2, const char*newname="") { return Rebin(ngroup,newname, (Double_t*) 0); }
347  virtual void Rebuild(Option_t *option="");
348  virtual void RecursiveRemove(TObject *obj);
349  virtual void Reset(Option_t *option="");
350  virtual void ResetStats();
351  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
352  virtual void Scale(Double_t c1=1, Option_t *option="");
353  virtual void SetAxisColor(Color_t color=1, Option_t *axis="X");
354  virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X");
355  virtual void SetBarOffset(Float_t offset=0.25) {fBarOffset = Short_t(1000*offset);}
356  virtual void SetBarWidth(Float_t width=0.5) {fBarWidth = Short_t(1000*width);}
357  virtual void SetBinContent(Int_t bin, Double_t content);
358  virtual void SetBinContent(Int_t bin, Int_t, Double_t content) { SetBinContent(bin, content); }
359  virtual void SetBinContent(Int_t bin, Int_t, Int_t, Double_t content) { SetBinContent(bin, content); }
360  virtual void SetBinError(Int_t bin, Double_t error);
361  virtual void SetBinError(Int_t binx, Int_t biny, Double_t error);
362  virtual void SetBinError(Int_t binx, Int_t biny, Int_t binz, Double_t error);
363  virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax);
364  virtual void SetBins(Int_t nx, const Double_t *xBins);
365  virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax);
366  virtual void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins);
367  virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax, Int_t ny, Double_t ymin, Double_t ymax,
368  Int_t nz, Double_t zmin, Double_t zmax);
369  virtual void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t * yBins, Int_t nz,
370  const Double_t *zBins);
371  virtual void SetBinsLength(Int_t = -1) { } //redefined in derived classes
372  virtual void SetBinErrorOption(EBinErrorOpt type) { fBinStatErrOpt = type; }
373  virtual void SetBuffer(Int_t buffersize, Option_t *option="");
374  virtual UInt_t SetCanExtend(UInt_t extendBitMask);
375  virtual void SetContent(const Double_t *content);
376  virtual void SetContour(Int_t nlevels, const Double_t *levels=0);
377  virtual void SetContourLevel(Int_t level, Double_t value);
378  static void SetDefaultBufferSize(Int_t buffersize=1000);
379  static void SetDefaultSumw2(Bool_t sumw2=kTRUE);
380  virtual void SetDirectory(TDirectory *dir);
381  virtual void SetEntries(Double_t n) {fEntries = n;};
382  virtual void SetError(const Double_t *error);
383  virtual void SetHighlight(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHighlight
384  virtual void SetLabelColor(Color_t color=1, Option_t *axis="X");
385  virtual void SetLabelFont(Style_t font=62, Option_t *axis="X");
386  virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X");
387  virtual void SetLabelSize(Float_t size=0.02, Option_t *axis="X");
388 
389  /*
390  * Set the minimum / maximum value for the Y axis (1-D histograms) or Z axis (2-D histograms)
391  * By default the maximum / minimum value used in drawing is the maximum / minimum value of the histogram
392  * plus a margin of 10%. If these functions are called, the values are used without any extra margin.
393  */
394  virtual void SetMaximum(Double_t maximum = -1111) { fMaximum = maximum; }; // *MENU*
395  virtual void SetMinimum(Double_t minimum = -1111) { fMinimum = minimum; }; // *MENU*
396 
397  virtual void SetName(const char *name); // *MENU*
398  virtual void SetNameTitle(const char *name, const char *title);
399  virtual void SetNdivisions(Int_t n=510, Option_t *axis="X");
400  virtual void SetNormFactor(Double_t factor=1) {fNormFactor = factor;}
401  virtual void SetStats(Bool_t stats=kTRUE); // *MENU*
402  virtual void SetOption(Option_t *option=" ") {fOption = option;}
403  virtual void SetTickLength(Float_t length=0.02, Option_t *axis="X");
404  virtual void SetTitleFont(Style_t font=62, Option_t *axis="X");
405  virtual void SetTitleOffset(Float_t offset=1, Option_t *axis="X");
406  virtual void SetTitleSize(Float_t size=0.02, Option_t *axis="X");
407  void SetStatOverflows(EStatOverflows statOverflows) {fStatOverflows = statOverflows;}; ///< See GetStatOverflows for more information.
408  virtual void SetTitle(const char *title); // *MENU*
409  virtual void SetXTitle(const char *title) {fXaxis.SetTitle(title);}
410  virtual void SetYTitle(const char *title) {fYaxis.SetTitle(title);}
411  virtual void SetZTitle(const char *title) {fZaxis.SetTitle(title);}
412  virtual TH1 *ShowBackground(Int_t niter=20, Option_t *option="same"); // *MENU*
413  virtual Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05); // *MENU*
414  virtual void Smooth(Int_t ntimes=1, Option_t *option=""); // *MENU*
415  static void SmoothArray(Int_t NN, Double_t *XX, Int_t ntimes=1);
416  static void StatOverflows(Bool_t flag=kTRUE);
417  virtual void Sumw2(Bool_t flag = kTRUE);
418  void UseCurrentStyle();
419  static TH1 *TransformHisto(TVirtualFFT *fft, TH1* h_output, Option_t *option);
420 
421 
422  // TODO: Remove obsolete methods in v6-04
423  virtual Double_t GetCellContent(Int_t binx, Int_t biny) const
424  { Obsolete("GetCellContent", "v6-00", "v6-04"); return GetBinContent(GetBin(binx, biny)); }
425  virtual Double_t GetCellError(Int_t binx, Int_t biny) const
426  { Obsolete("GetCellError", "v6-00", "v6-04"); return GetBinError(binx, biny); }
427  virtual void RebinAxis(Double_t x, TAxis *axis)
428  { Obsolete("RebinAxis", "v6-00", "v6-04"); ExtendAxis(x, axis); }
429  virtual void SetCellContent(Int_t binx, Int_t biny, Double_t content)
430  { Obsolete("SetCellContent", "v6-00", "v6-04"); SetBinContent(GetBin(binx, biny), content); }
431  virtual void SetCellError(Int_t binx, Int_t biny, Double_t content)
432  { Obsolete("SetCellError", "v6-00", "v6-04"); SetBinError(binx, biny, content); }
433 
434  ClassDef(TH1,8) //1-Dim histogram base class
435 
436 protected:
437  virtual Double_t RetrieveBinContent(Int_t bin) const;
438  virtual void UpdateBinContent(Int_t bin, Double_t content);
439  virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const { return fSumw2.fN ? fSumw2.fArray[bin] : RetrieveBinContent(bin); }
440 };
441 
442 namespace cling {
443  std::string printValue(TH1 *val);
444 }
445 
446 //________________________________________________________________________
447 
448 class TH1C : public TH1, public TArrayC {
449 
450 public:
451  TH1C();
452  TH1C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
453  TH1C(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
454  TH1C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
455  TH1C(const TH1C &h1c);
456  TH1C& operator=(const TH1C &h1);
457  virtual ~TH1C();
458 
459  virtual void AddBinContent(Int_t bin);
460  virtual void AddBinContent(Int_t bin, Double_t w);
461  virtual void Copy(TObject &hnew) const;
462  virtual void Reset(Option_t *option="");
463  virtual void SetBinsLength(Int_t n=-1);
464 
465  ClassDef(TH1C,3) //1-Dim histograms (one char per channel)
466 
467  friend TH1C operator*(Double_t c1, const TH1C &h1);
468  friend TH1C operator*(const TH1C &h1, Double_t c1);
469  friend TH1C operator+(const TH1C &h1, const TH1C &h2);
470  friend TH1C operator-(const TH1C &h1, const TH1C &h2);
471  friend TH1C operator*(const TH1C &h1, const TH1C &h2);
472  friend TH1C operator/(const TH1C &h1, const TH1C &h2);
473 
474 protected:
475  virtual Double_t RetrieveBinContent(Int_t bin) const { return Double_t (fArray[bin]); }
476  virtual void UpdateBinContent(Int_t bin, Double_t content) { fArray[bin] = Char_t (content); }
477 };
478 
479 TH1C operator*(Double_t c1, const TH1C &h1);
480 inline
481 TH1C operator*(const TH1C &h1, Double_t c1) {return operator*(c1,h1);}
482 TH1C operator+(const TH1C &h1, const TH1C &h2);
483 TH1C operator-(const TH1C &h1, const TH1C &h2);
484 TH1C operator*(const TH1C &h1, const TH1C &h2);
485 TH1C operator/(const TH1C &h1, const TH1C &h2);
486 
487 //________________________________________________________________________
488 
489 class TH1S : public TH1, public TArrayS {
490 
491 public:
492  TH1S();
493  TH1S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
494  TH1S(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
495  TH1S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
496  TH1S(const TH1S &h1s);
497  TH1S& operator=(const TH1S &h1);
498  virtual ~TH1S();
499 
500  virtual void AddBinContent(Int_t bin);
501  virtual void AddBinContent(Int_t bin, Double_t w);
502  virtual void Copy(TObject &hnew) const;
503  virtual void Reset(Option_t *option="");
504  virtual void SetBinsLength(Int_t n=-1);
505 
506  ClassDef(TH1S,3) //1-Dim histograms (one short per channel)
507 
508  friend TH1S operator*(Double_t c1, const TH1S &h1);
509  friend TH1S operator*(const TH1S &h1, Double_t c1);
510  friend TH1S operator+(const TH1S &h1, const TH1S &h2);
511  friend TH1S operator-(const TH1S &h1, const TH1S &h2);
512  friend TH1S operator*(const TH1S &h1, const TH1S &h2);
513  friend TH1S operator/(const TH1S &h1, const TH1S &h2);
514 
515 protected:
516  virtual Double_t RetrieveBinContent(Int_t bin) const { return Double_t (fArray[bin]); }
517  virtual void UpdateBinContent(Int_t bin, Double_t content) { fArray[bin] = Short_t (content); }
518 };
519 
520 TH1S operator*(Double_t c1, const TH1S &h1);
521 inline
522 TH1S operator*(const TH1S &h1, Double_t c1) {return operator*(c1,h1);}
523 TH1S operator+(const TH1S &h1, const TH1S &h2);
524 TH1S operator-(const TH1S &h1, const TH1S &h2);
525 TH1S operator*(const TH1S &h1, const TH1S &h2);
526 TH1S operator/(const TH1S &h1, const TH1S &h2);
527 
528 //________________________________________________________________________
529 
530 class TH1I: public TH1, public TArrayI {
531 
532 public:
533  TH1I();
534  TH1I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
535  TH1I(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
536  TH1I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
537  TH1I(const TH1I &h1i);
538  TH1I& operator=(const TH1I &h1);
539  virtual ~TH1I();
540 
541  virtual void AddBinContent(Int_t bin);
542  virtual void AddBinContent(Int_t bin, Double_t w);
543  virtual void Copy(TObject &hnew) const;
544  virtual void Reset(Option_t *option="");
545  virtual void SetBinsLength(Int_t n=-1);
546 
547  ClassDef(TH1I,3) //1-Dim histograms (one 32 bits integer per channel)
548 
549  friend TH1I operator*(Double_t c1, const TH1I &h1);
550  friend TH1I operator*(const TH1I &h1, Double_t c1);
551  friend TH1I operator+(const TH1I &h1, const TH1I &h2);
552  friend TH1I operator-(const TH1I &h1, const TH1I &h2);
553  friend TH1I operator*(const TH1I &h1, const TH1I &h2);
554  friend TH1I operator/(const TH1I &h1, const TH1I &h2);
555 
556 protected:
557  virtual Double_t RetrieveBinContent(Int_t bin) const { return Double_t (fArray[bin]); }
558  virtual void UpdateBinContent(Int_t bin, Double_t content) { fArray[bin] = Int_t (content); }
559 };
560 
561 TH1I operator*(Double_t c1, const TH1I &h1);
562 inline
563 TH1I operator*(const TH1I &h1, Double_t c1) {return operator*(c1,h1);}
564 TH1I operator+(const TH1I &h1, const TH1I &h2);
565 TH1I operator-(const TH1I &h1, const TH1I &h2);
566 TH1I operator*(const TH1I &h1, const TH1I &h2);
567 TH1I operator/(const TH1I &h1, const TH1I &h2);
568 
569 //________________________________________________________________________
570 
571 class TH1F : public TH1, public TArrayF {
572 
573 public:
574  TH1F();
575  TH1F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
576  TH1F(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
577  TH1F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
578  explicit TH1F(const TVectorF &v);
579  TH1F(const TH1F &h1f);
580  TH1F& operator=(const TH1F &h1);
581  virtual ~TH1F();
582 
583  virtual void AddBinContent(Int_t bin) {++fArray[bin];}
584  virtual void AddBinContent(Int_t bin, Double_t w)
585  {fArray[bin] += Float_t (w);}
586  virtual void Copy(TObject &hnew) const;
587  virtual void Reset(Option_t *option="");
588  virtual void SetBinsLength(Int_t n=-1);
589 
590  ClassDef(TH1F,3) //1-Dim histograms (one float per channel)
591 
592  friend TH1F operator*(Double_t c1, const TH1F &h1);
593  friend TH1F operator*(const TH1F &h1, Double_t c1);
594  friend TH1F operator+(const TH1F &h1, const TH1F &h2);
595  friend TH1F operator-(const TH1F &h1, const TH1F &h2);
596  friend TH1F operator*(const TH1F &h1, const TH1F &h2);
597  friend TH1F operator/(const TH1F &h1, const TH1F &h2);
598 
599 protected:
600  virtual Double_t RetrieveBinContent(Int_t bin) const { return Double_t (fArray[bin]); }
601  virtual void UpdateBinContent(Int_t bin, Double_t content) { fArray[bin] = Float_t (content); }
602 };
603 
604 TH1F operator*(Double_t c1, const TH1F &h1);
605 inline
606 TH1F operator*(const TH1F &h1, Double_t c1) {return operator*(c1,h1);}
607 TH1F operator+(const TH1F &h1, const TH1F &h2);
608 TH1F operator-(const TH1F &h1, const TH1F &h2);
609 TH1F operator*(const TH1F &h1, const TH1F &h2);
610 TH1F operator/(const TH1F &h1, const TH1F &h2);
611 
612 //________________________________________________________________________
613 
614 class TH1D : public TH1, public TArrayD {
615 
616 public:
617  TH1D();
618  TH1D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup);
619  TH1D(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins);
620  TH1D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins);
621  explicit TH1D(const TVectorD &v);
622  TH1D(const TH1D &h1d);
623  TH1D& operator=(const TH1D &h1);
624  virtual ~TH1D();
625 
626  virtual void AddBinContent(Int_t bin) {++fArray[bin];}
627  virtual void AddBinContent(Int_t bin, Double_t w)
628  {fArray[bin] += Double_t (w);}
629  virtual void Copy(TObject &hnew) const;
630  virtual void Reset(Option_t *option="");
631  virtual void SetBinsLength(Int_t n=-1);
632 
633  ClassDef(TH1D,3) //1-Dim histograms (one double per channel)
634 
635  friend TH1D operator*(Double_t c1, const TH1D &h1);
636  friend TH1D operator*(const TH1D &h1, Double_t c1);
637  friend TH1D operator+(const TH1D &h1, const TH1D &h2);
638  friend TH1D operator-(const TH1D &h1, const TH1D &h2);
639  friend TH1D operator*(const TH1D &h1, const TH1D &h2);
640  friend TH1D operator/(const TH1D &h1, const TH1D &h2);
641 
642 protected:
643  virtual Double_t RetrieveBinContent(Int_t bin) const { return fArray[bin]; }
644  virtual void UpdateBinContent(Int_t bin, Double_t content) { fArray[bin] = content; }
645 };
646 
647 TH1D operator*(Double_t c1, const TH1D &h1);
648 inline
649 TH1D operator*(const TH1D &h1, Double_t c1) {return operator*(c1,h1);}
650 TH1D operator+(const TH1D &h1, const TH1D &h2);
651 TH1D operator-(const TH1D &h1, const TH1D &h2);
652 TH1D operator*(const TH1D &h1, const TH1D &h2);
653 TH1D operator/(const TH1D &h1, const TH1D &h2);
654 
655  extern TH1 *R__H(Int_t hid);
656  extern TH1 *R__H(const char *hname);
657 
658 #endif