Logo ROOT   6.08/07
Reference Guide
TProfile2D.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 16/04/2000
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_TProfile2D
13 #define ROOT_TProfile2D
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProfile2D //
19 // //
20 // Profile2D histogram class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TH2
25 #include "TH2.h"
26 #endif
27 #ifndef ROOT_TProfile
28 #include "TProfile.h"
29 #endif
30 
31 class TProfile2D : public TH2D {
32 
33 public:
34  friend class TProfileHelper;
35 
36 protected:
37  TArrayD fBinEntries; //number of entries per bin
38  EErrorType fErrorMode; //Option to compute errors
39  Double_t fZmin; //Lower limit in Z (if set)
40  Double_t fZmax; //Upper limit in Z (if set)
41  Bool_t fScaling; //!True when TProfile2D::Scale is called
42  Double_t fTsumwz; //Total Sum of weight*Z
43  Double_t fTsumwz2; //Total Sum of weight*Z*Z
44  TArrayD fBinSumw2; //Array of sum of squares of weights per bin
45  static Bool_t fgApproximate; //bin error approximation option
46 
47  virtual Int_t BufferFill(Double_t, Double_t) {return -2;} //may not use
48  virtual Int_t BufferFill(Double_t, Double_t, Double_t) {return -2;} //may not use
50 
51  // helper methods for the Merge unification in TProfileHelper
52  void SetBins(const Int_t* nbins, const Double_t* range) { SetBins(nbins[0], range[0], range[1],
53  nbins[1], range[2], range[3]); };
54  Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2], v[3]); };
55 
56  virtual TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
57 
58  using TH2::Fill;
59  Int_t Fill(Double_t, Double_t) {return TH2::Fill(0); } //MayNotUse
60 
61  virtual Double_t RetrieveBinContent(Int_t bin) const { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
62  //virtual void UpdateBinContent(Int_t bin, Double_t content);
63  virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const { Double_t err = GetBinError(bin); return err*err; }
64 
65 private:
66  Double_t *GetB() {return &fBinEntries.fArray[0];}
67  Double_t *GetB2() {return (fBinSumw2.fN ? &fBinSumw2.fArray[0] : 0 ); }
68  Double_t *GetW() {return &fArray[0];}
69  Double_t *GetW2() {return &fSumw2.fArray[0];}
71  { MayNotUse("SetBins(Int_t, Double_t, Double_t"); }
72  void SetBins(Int_t, const Double_t*)
73  { MayNotUse("SetBins(Int_t, const Double_t*"); }
75  { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
76  void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *)
77  { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*, Int_t, const Double_t*"); }
78 
79 public:
80  TProfile2D();
81  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
82  ,Int_t nbinsy,Double_t ylow,Double_t yup
83  ,Double_t zlow, Double_t zup,Option_t *option="");
84  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
85  ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
86  TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
87  ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
88  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
89  ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
90  TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
91  ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
92  TProfile2D(const TProfile2D &profile);
93  virtual ~TProfile2D();
94  virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
95  virtual Bool_t Add(const TH1 *h1, Double_t c1=1);
96  virtual Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1); // *MENU*
97  static void Approximate(Bool_t approx=kTRUE);
98  void BuildOptions(Double_t zmin, Double_t zmax, Option_t *option);
99  virtual Int_t BufferEmpty(Int_t action=0);
100  virtual void Copy(TObject &hnew) const;
101  virtual Bool_t Divide(TF1 *h1, Double_t c1=1);
102  virtual Bool_t Divide(const TH1 *h1);
103  virtual Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
104  virtual void ExtendAxis(Double_t x, TAxis *axis);
106  virtual Int_t Fill(Double_t x, const char *namey, Double_t z);
107  virtual Int_t Fill(const char *namex, Double_t y, Double_t z);
108  virtual Int_t Fill(const char *namex, const char *namey, Double_t z);
109  virtual Int_t Fill(Double_t x, Double_t y, Double_t z, Double_t w);
110  virtual Double_t GetBinContent(Int_t bin) const;
111  virtual Double_t GetBinContent(Int_t binx, Int_t biny) const {return GetBinContent(GetBin(binx,biny));}
112  virtual Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const {return GetBinContent(GetBin(binx,biny));}
113  virtual Double_t GetBinError(Int_t bin) const;
114  virtual Double_t GetBinError(Int_t binx, Int_t biny) const {return GetBinError(GetBin(binx,biny));}
115  virtual Double_t GetBinError(Int_t binx, Int_t biny, Int_t) const {return GetBinError(GetBin(binx,biny));}
116  virtual Double_t GetBinEntries(Int_t bin) const;
118  virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
119  virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
120  Option_t *GetErrorOption() const;
121  virtual void GetStats(Double_t *stats) const;
122  virtual Double_t GetZmin() const {return fZmin;}
123  virtual Double_t GetZmax() const {return fZmax;}
124  virtual void LabelsDeflate(Option_t *axis="X");
125  virtual void LabelsInflate(Option_t *axis="X");
126  virtual void LabelsOption(Option_t *option="h", Option_t *axis="X");
127  virtual Long64_t Merge(TCollection *list);
128  virtual Bool_t Multiply(TF1 *h1, Double_t c1=1);
129  virtual Bool_t Multiply(const TH1 *h1);
130  virtual Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
131  TH2D *ProjectionXY(const char *name="_pxy", Option_t *option="e") const;
132  TProfile *ProfileX(const char *name="_pfx", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const; // *MENU*
133  TProfile *ProfileY(const char *name="_pfy", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const; // *MENU*
134  virtual void PutStats(Double_t *stats);
135  virtual void Reset(Option_t *option="");
136  virtual TProfile2D *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="");
137  virtual TProfile2D *RebinX(Int_t ngroup=2, const char *newname="");
138  virtual TProfile2D *RebinY(Int_t ngroup=2, const char *newname="");
139  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
140  virtual void Scale(Double_t c1=1, Option_t *option="");
141  virtual void SetBinEntries(Int_t bin, Double_t w);
142  virtual void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax);
143  virtual void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins);
144  virtual void SetBinsLength(Int_t n=-1);
145  virtual void SetBuffer(Int_t buffersize, Option_t *option="");
146  virtual void SetErrorOption(Option_t *option=""); // *MENU*
147  virtual void Sumw2(Bool_t flag = kTRUE);
148 
149  ClassDef(TProfile2D,7) //Profile2D histogram class
150 };
151 
152 #endif
const int nx
Definition: kalman.C:16
virtual Long64_t Merge(TCollection *list)
Merge all histograms in the collection in this histogram.
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile2D histogram.
Definition: TProfile2D.cxx:798
float xmin
Definition: THbookFile.cxx:93
virtual Double_t GetBinError(Int_t binx, Int_t biny) const
Definition: TProfile2D.h:114
long long Long64_t
Definition: RtypesCore.h:69
virtual void Sumw2(Bool_t flag=kTRUE)
Create/Delete structure to store sum of squares of weights per bin This is needed to compute the corr...
virtual Double_t GetBinError(Int_t bin) const
-*Return bin error of a Profile2D histogram
Definition: TProfile2D.cxx:839
const char Option_t
Definition: RtypesCore.h:62
return c1
Definition: legend1.C:41
void Reset()
Definition: TArrayD.h:49
virtual void ExtendAxis(Double_t x, TAxis *axis)
Profile histogram is resized along axis such that x is in the axis range.
float ymin
Definition: THbookFile.cxx:93
TProfile * ProfileY(const char *name="_pfy", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
*-*Project a 2-D histogram into a profile histogram along X *-* =====================================...
Option_t * GetErrorOption() const
-*Return option to compute profile2D errors *-* ========================================= ...
Definition: TProfile2D.cxx:848
virtual TProfile2D * RebinY(Int_t ngroup=2, const char *newname="")
Rebin only the Y axis see Rebin2D.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TProfile2D * Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="")
Rebin this histogram grouping nxgroup/nygroup bins along the xaxis/yaxis together.
int nbins[3]
TArrayD fSumw2
Array of sum of squares of weights.
Definition: TH1.h:118
virtual ~TProfile2D()
Default destructor for Profile2D histograms.
Definition: TProfile2D.cxx:83
Profile Historam.
Definition: TProfile.h:34
Double_t * GetB()
Definition: TProfile2D.h:66
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual Double_t GetZmax() const
Definition: TProfile2D.h:123
virtual Bool_t Multiply(TF1 *h1, Double_t c1=1)
Performs the operation: this = this*c1*f1.
EErrorType
Definition: TProfile.h:30
static Bool_t fgApproximate
Definition: TProfile2D.h:45
Int_t Fill(Double_t, Double_t)
Increment cell defined by x,y by 1.
Definition: TProfile2D.h:59
Int_t Fill(const Double_t *v)
Definition: TProfile2D.h:54
Double_t x[n]
Definition: legend1.C:17
virtual Bool_t Divide(TF1 *h1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) This function is not implemented.
Definition: TProfile2D.cxx:395
#define ClassDef(name, id)
Definition: Rtypes.h:254
void BuildOptions(Double_t zmin, Double_t zmax, Option_t *option)
Set Profile2D histogram structure and options.
Definition: TProfile2D.cxx:173
const int ny
Definition: kalman.C:17
Double_t * GetB2()
Definition: TProfile2D.h:67
TArrayD fBinEntries
Definition: TProfile2D.h:37
virtual Double_t GetBinContent(Int_t bin) const
Return bin content of a Profile2D histogram.
Definition: TProfile2D.cxx:785
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile2D errors The computation of the bin errors is based on the parameter op...
static void Approximate(Bool_t approx=kTRUE)
static function set the fgApproximate flag.
Definition: TProfile2D.cxx:259
Double_t * fArray
Definition: TArrayD.h:32
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:978
virtual void LabelsDeflate(Option_t *axis="X")
Reduce the number of bins for this axis to the number of bins having a label.
Definition: TProfile2D.cxx:934
TH1F * h1
Definition: legend1.C:5
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this profile2D by a constant c1.
Double_t fZmin
Definition: TProfile2D.h:39
Int_t fN
Definition: TArray.h:40
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1.
Definition: TProfile2D.cxx:202
float ymax
Definition: THbookFile.cxx:93
Class to manage histogram axis.
Definition: TAxis.h:36
TH2D * ProjectionXY(const char *name="_pxy", Option_t *option="e") const
*-*Project this profile2D into a 2-D histogram along X,Y -* *-* =====================================...
SVector< double, 2 > v
Definition: Dict.h:5
void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t)
Redefine x, y and z axis parameters.
Definition: TProfile2D.h:74
virtual Double_t GetBinError(Int_t binx, Int_t biny, Int_t) const
Definition: TProfile2D.h:115
virtual Int_t BufferFill(Double_t, Double_t, Double_t)
accumulate arguments in buffer.
Definition: TProfile2D.h:48
Collection abstract base class.
Definition: TCollection.h:48
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
Definition: TProfile2D.cxx:273
virtual void Copy(TObject &hnew) const
Copy a Profile2D histogram to a new profile2D histogram*.
Definition: TProfile2D.cxx:365
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this profile The array stats must be correctly dimensionned...
Definition: TProfile2D.cxx:874
Double_t fZmax
Definition: TProfile2D.h:40
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
Double_t fTsumwz2
Definition: TProfile2D.h:43
virtual TProfile2D * RebinX(Int_t ngroup=2, const char *newname="")
Rebin only the X axis see Rebin2D.
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels option = "a" sort by alphabetic order = ">" sort by decreasing...
Definition: TProfile2D.cxx:959
float xmax
Definition: THbookFile.cxx:93
virtual void SetBuffer(Int_t buffersize, Option_t *option="")
set the buffer size in units of 8 bytes (double)
virtual void LabelsInflate(Option_t *axis="X")
Double the number of bins for axis.
Definition: TProfile2D.cxx:944
virtual Double_t GetBinContent(Int_t binx, Int_t biny) const
Definition: TProfile2D.h:111
TProfile2D()
Default constructor for Profile2D histograms.
Definition: TProfile2D.cxx:73
Double_t * GetW()
Definition: TProfile2D.h:68
TProfile * ProfileX(const char *name="_pfx", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
*-*Project a 2-D histogram into a profile histogram along X *-* =====================================...
virtual Int_t BufferFill(Double_t, Double_t)
accumulate arguments in buffer.
Definition: TProfile2D.h:47
return c2
Definition: legend2.C:14
void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *)
Redefine x, y and z axis parameters with variable bin sizes.
Definition: TProfile2D.h:76
double Double_t
Definition: RtypesCore.h:55
virtual Double_t GetBinEffectiveEntries(Int_t bin)
Return bin effective entries for a weighted filled Profile histogram.
Definition: TProfile2D.cxx:816
Double_t y[n]
Definition: legend1.C:17
The TH1 histogram class.
Definition: TH1.h:80
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin -.
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Definition: TProfile2D.h:63
Profile2D histograms are used to display the mean value of Z and its RMS for each cell in X...
Definition: TProfile2D.h:31
Array of doubles (64 bits per element).
Definition: TArrayD.h:29
virtual Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const
Definition: TProfile2D.h:112
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
1-Dim function class
Definition: TF1.h:149
TArrayD fBinSumw2
Definition: TProfile2D.h:44
void SetBins(Int_t, Double_t, Double_t)
Redefine x axis parameters.
Definition: TProfile2D.h:70
virtual Double_t GetZmin() const
Definition: TProfile2D.h:122
virtual Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
Definition: TH2.cxx:966
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
void SetBins(const Int_t *nbins, const Double_t *range)
Definition: TProfile2D.h:52
EErrorType fErrorMode
Definition: TProfile2D.h:38
virtual const TArrayD * GetBinSumw2() const
Definition: TProfile2D.h:119
virtual TProfile * DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
implementation of ProfileX or ProfileY for a TProfile2D Do correctly the combination of the bin avera...
Double_t fTsumwz
True when TProfile2D::Scale is called.
Definition: TProfile2D.h:42
const Int_t n
Definition: legend1.C:16
virtual Double_t RetrieveBinContent(Int_t bin) const
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition: TProfile2D.h:61
Double_t * GetW2()
Definition: TProfile2D.h:69
char name[80]
Definition: TGX11.cxx:109
Bool_t fScaling
Definition: TProfile2D.h:41
tomato 2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:296
void SetBins(Int_t, const Double_t *)
Redefine x axis parameters with variable bin sizes.
Definition: TProfile2D.h:72
virtual TArrayD * GetBinSumw2()
Definition: TProfile2D.h:118