Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TProfile.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 29/09/95
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_TProfile
13 #define ROOT_TProfile
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProfile //
19 // //
20 // Profile histogram class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TH1.h"
25 
26 class TProfileHelper;
27 
28 enum EErrorType { kERRORMEAN = 0, kERRORSPREAD, kERRORSPREADI, kERRORSPREADG };
29 
30 class TF1;
31 
32 class TProfile : public TH1D {
33 
34 public:
35  friend class TProfileHelper;
36 
37 protected:
38  TArrayD fBinEntries; //number of entries per bin
39  EErrorType fErrorMode; //Option to compute errors
40  Double_t fYmin; //Lower limit in Y (if set)
41  Double_t fYmax; //Upper limit in Y (if set)
42  Bool_t fScaling; //!True when TProfile::Scale is called
43  Double_t fTsumwy; //Total Sum of weight*Y
44  Double_t fTsumwy2; //Total Sum of weight*Y*Y
45  TArrayD fBinSumw2; //Array of sum of squares of weights per bin
46 
47 static Bool_t fgApproximate; //bin error approximation option
48 
49  virtual Int_t BufferFill(Double_t, Double_t) {return -2;} //may not use
50  virtual Int_t BufferFill(Double_t x, Double_t y, Double_t w);
51 
52  // helper methods for the Merge unification in TProfileHelper
53  void SetBins(const Int_t* nbins, const Double_t* range) { SetBins(nbins[0], range[0], range[1]); };
54  Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2]); };
55 
56  virtual Double_t RetrieveBinContent(Int_t bin) const { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
57  //virtual void UpdateBinContent(Int_t bin, Double_t content);
58  virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const { Double_t err = GetBinError(bin); return err*err; }
59 
60 private:
61  Int_t Fill(Double_t) { MayNotUse("Fill(Double_t)"); return -1;}
62  void FillN(Int_t, const Double_t *, const Double_t *, Int_t) { MayNotUse("FillN(Int_t, Double_t*, Double_t*, Int_t)"); }
63  Double_t *GetB() {return &fBinEntries.fArray[0];}
64  Double_t *GetB2() {return (fBinSumw2.fN ? &fBinSumw2.fArray[0] : 0 ); }
65  Double_t *GetW() {return &fArray[0];}
66  Double_t *GetW2() {return &fSumw2.fArray[0];}
67  void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t)
68  { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
69  void SetBins(Int_t, const Double_t*, Int_t, const Double_t*)
70  { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*"); }
71  void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t)
72  { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
73  void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *)
74  { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*, Int_t, const Double_t*"); }
75 
76 public:
77  TProfile();
78  TProfile(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup, Option_t *option="");
79  TProfile(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup,Double_t ylow,Double_t yup,Option_t *option="");
80  TProfile(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins, Option_t *option="");
81  TProfile(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins, Option_t *option="");
82  TProfile(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins, Double_t ylow,Double_t yup, Option_t *option="");
83  TProfile(const TProfile &profile);
84  TProfile &operator=(const TProfile &profile);
85  virtual ~TProfile();
86  virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
87  virtual Bool_t Add(const TH1 *h1, Double_t c1=1);
88  virtual Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1); // *MENU*
89  static void Approximate(Bool_t approx=kTRUE);
90  virtual Int_t BufferEmpty(Int_t action=0);
91  void BuildOptions(Double_t ymin, Double_t ymax, Option_t *option);
92  virtual void Copy(TObject &hnew) const;
93  virtual Bool_t Divide(TF1 *h1, Double_t c1=1);
94  virtual Bool_t Divide(const TH1 *h1);
95  virtual Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
96  virtual void ExtendAxis(Double_t x, TAxis *axis);
97  virtual Int_t Fill(Double_t x, Double_t y);
98  virtual Int_t Fill(const char *namex, Double_t y);
99  virtual Int_t Fill(Double_t x, Double_t y, Double_t w);
100  virtual Int_t Fill(const char *namex, Double_t y, Double_t w);
101  virtual void FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1);
102  virtual Double_t GetBinContent(Int_t bin) const;
103  virtual Double_t GetBinContent(Int_t bin, Int_t) const {return GetBinContent(bin);}
104  virtual Double_t GetBinContent(Int_t bin, Int_t, Int_t) const {return GetBinContent(bin);}
105  virtual Double_t GetBinError(Int_t bin) const;
106  virtual Double_t GetBinError(Int_t bin, Int_t) const {return GetBinError(bin);}
107  virtual Double_t GetBinError(Int_t bin, Int_t, Int_t) const {return GetBinError(bin);}
108  virtual Double_t GetBinEntries(Int_t bin) const;
109  virtual Double_t GetBinEffectiveEntries(Int_t bin) const;
110  virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
111  virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
112  Option_t *GetErrorOption() const;
113  virtual void GetStats(Double_t *stats) const;
114  virtual Double_t GetYmin() const {return fYmin;}
115  virtual Double_t GetYmax() const {return fYmax;}
116  virtual void LabelsDeflate(Option_t *axis="X");
117  virtual void LabelsInflate(Option_t *axis="X");
118  virtual void LabelsOption(Option_t *option="h", Option_t *axis="X");
119  virtual Long64_t Merge(TCollection *list);
120  virtual Bool_t Multiply(TF1 *h1, Double_t c1=1);
121  virtual Bool_t Multiply(const TH1 *h1);
122  virtual Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
123  TH1D *ProjectionX(const char *name="_px", Option_t *option="e") const;
124  virtual void PutStats(Double_t *stats);
125  TH1 *Rebin(Int_t ngroup=2, const char*newname="", const Double_t *xbins=0);
126  virtual void Reset(Option_t *option="");
127  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
128  virtual void Scale(Double_t c1=1, Option_t *option="");
129  virtual void SetBinEntries(Int_t bin, Double_t w);
130  virtual void SetBins(Int_t nbins, Double_t xmin, Double_t xmax);
131  virtual void SetBins(Int_t nx, const Double_t *xbins);
132  virtual void SetBinsLength(Int_t n=-1);
133  virtual void SetBuffer(Int_t buffersize, Option_t *option="");
134  virtual void SetErrorOption(Option_t *option=""); // *MENU*
135  virtual void Sumw2(Bool_t flag = kTRUE);
136 
137  ClassDef(TProfile,7) //Profile histogram class
138 };
139 
140 #endif
141