Logo ROOT  
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 #include "TH2.h"
25 #include "TProfile.h"
26 
27 class TProfile2D : public TH2D {
28 
29 public:
30  friend class TProfileHelper;
31 
32 protected:
33  TArrayD fBinEntries; //number of entries per bin
34  EErrorType fErrorMode; //Option to compute errors
35  Double_t fZmin; //Lower limit in Z (if set)
36  Double_t fZmax; //Upper limit in Z (if set)
37  Bool_t fScaling; //!True when TProfile2D::Scale is called
38  Double_t fTsumwz; //Total Sum of weight*Z
39  Double_t fTsumwz2; //Total Sum of weight*Z*Z
40  TArrayD fBinSumw2; //Array of sum of squares of weights per bin
41  static Bool_t fgApproximate; //bin error approximation option
42 
43  virtual Int_t BufferFill(Double_t, Double_t) {return -2;} //may not use
44  virtual Int_t BufferFill(Double_t, Double_t, Double_t) {return -2;} //may not use
46 
47  // helper methods for the Merge unification in TProfileHelper
48  void SetBins(const Int_t* nbins, const Double_t* range) { SetBins(nbins[0], range[0], range[1],
49  nbins[1], range[2], range[3]); };
50  Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2], v[3]); };
51 
52  virtual TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
53 
54  using TH2::Fill;
55  Int_t Fill(Double_t, Double_t) {return TH2::Fill(0); } //MayNotUse
56 
57  virtual Double_t RetrieveBinContent(Int_t bin) const { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
58  //virtual void UpdateBinContent(Int_t bin, Double_t content);
59  virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const { Double_t err = GetBinError(bin); return err*err; }
60 
61 private:
62  Double_t *GetB() {return &fBinEntries.fArray[0];}
63  Double_t *GetB2() {return (fBinSumw2.fN ? &fBinSumw2.fArray[0] : 0 ); }
64  Double_t *GetW() {return &fArray[0];}
65  Double_t *GetW2() {return &fSumw2.fArray[0];}
67  { MayNotUse("SetBins(Int_t, Double_t, Double_t"); }
68  void SetBins(Int_t, const Double_t*)
69  { MayNotUse("SetBins(Int_t, const Double_t*"); }
71  { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
72  void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *)
73  { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*, Int_t, const Double_t*"); }
74 
75 public:
77  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
78  ,Int_t nbinsy,Double_t ylow,Double_t yup
79  ,Double_t zlow, Double_t zup,Option_t *option="");
80  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
81  ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
82  TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
83  ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
84  TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
85  ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
86  TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
87  ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
88  TProfile2D(const TProfile2D &profile);
89  TProfile2D &operator=(const TProfile2D &profile);
90  virtual ~TProfile2D();
91  virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
92  virtual Bool_t Add(const TH1 *h1, Double_t c1=1);
93  virtual Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1); // *MENU*
94  static void Approximate(Bool_t approx=kTRUE);
95  void BuildOptions(Double_t zmin, Double_t zmax, Option_t *option);
96  virtual Int_t BufferEmpty(Int_t action=0);
97  virtual void Copy(TObject &hnew) const;
98  virtual Bool_t Divide(TF1 *h1, Double_t c1=1);
99  virtual Bool_t Divide(const TH1 *h1);
100  virtual Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
101  virtual void ExtendAxis(Double_t x, TAxis *axis);
103  virtual Int_t Fill(Double_t x, const char *namey, Double_t z);
104  virtual Int_t Fill(const char *namex, Double_t y, Double_t z);
105  virtual Int_t Fill(const char *namex, const char *namey, Double_t z);
106  virtual Int_t Fill(Double_t x, Double_t y, Double_t z, Double_t w);
107  virtual Double_t GetBinContent(Int_t bin) const;
108  virtual Double_t GetBinContent(Int_t binx, Int_t biny) const {return GetBinContent(GetBin(binx,biny));}
109  virtual Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const {return GetBinContent(GetBin(binx,biny));}
110  virtual Double_t GetBinError(Int_t bin) const;
111  virtual Double_t GetBinError(Int_t binx, Int_t biny) const {return GetBinError(GetBin(binx,biny));}
112  virtual Double_t GetBinError(Int_t binx, Int_t biny, Int_t) const {return GetBinError(GetBin(binx,biny));}
113  virtual Double_t GetBinEntries(Int_t bin) const;
115  virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
116  virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
118  virtual void GetStats(Double_t *stats) const;
119  virtual Double_t GetZmin() const {return fZmin;}
120  virtual Double_t GetZmax() const {return fZmax;}
121  virtual void LabelsDeflate(Option_t *axis="X");
122  virtual void LabelsInflate(Option_t *axis="X");
123  virtual void LabelsOption(Option_t *option="h", Option_t *axis="X");
124  virtual Long64_t Merge(TCollection *list);
125  virtual Bool_t Multiply(TF1 *h1, Double_t c1=1);
126  virtual Bool_t Multiply(const TH1 *h1);
127  virtual Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
128  TH2D *ProjectionXY(const char *name="_pxy", Option_t *option="e") const;
129  TProfile *ProfileX(const char *name="_pfx", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const; // *MENU*
130  TProfile *ProfileY(const char *name="_pfy", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const; // *MENU*
131  virtual void PutStats(Double_t *stats);
132  virtual void Reset(Option_t *option="");
133  virtual TProfile2D *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="");
134  virtual TProfile2D *RebinX(Int_t ngroup=2, const char *newname="");
135  virtual TProfile2D *RebinY(Int_t ngroup=2, const char *newname="");
136  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
137  virtual void Scale(Double_t c1=1, Option_t *option="");
138  virtual void SetBinEntries(Int_t bin, Double_t w);
139  virtual void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax);
140  virtual void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins);
141  virtual void SetBinsLength(Int_t n=-1);
142  virtual void SetBuffer(Int_t buffersize, Option_t *option="");
143  virtual void SetErrorOption(Option_t *option=""); // *MENU*
144  virtual void Sumw2(Bool_t flag = kTRUE);
146 
147  ClassDef(TProfile2D,8) //Profile2D histogram class
148 };
149 
150 #endif
n
const Int_t n
Definition: legend1.C:16
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
ymax
float ymax
Definition: THbookFile.cxx:95
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TProfile2D::Merge
virtual Long64_t Merge(TCollection *list)
Merge all histograms in the collection in this histogram.
Definition: TProfile2D.cxx:1141
TProfile2D::~TProfile2D
virtual ~TProfile2D()
Default destructor for Profile2D histograms.
Definition: TProfile2D.cxx:98
TProfile2D::GetNumberOfBins
Double_t GetNumberOfBins()
Definition: TProfile2D.h:151
TProfile2D::fTsumwz
Double_t fTsumwz
True when TProfile2D::Scale is called.
Definition: TProfile2D.h:44
TProfile2D::GetZmin
virtual Double_t GetZmin() const
Definition: TProfile2D.h:125
TProfile2D::fZmax
Double_t fZmax
Definition: TProfile2D.h:42
TProfile2D::fBinEntries
TArrayD fBinEntries
Definition: TProfile2D.h:39
TProfile2D::GetBinError
virtual Double_t GetBinError(Int_t bin) const
Return bin error of a Profile2D histogram.
Definition: TProfile2D.cxx:851
xmax
float xmax
Definition: THbookFile.cxx:95
TProfile2D::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TProfile2D.cxx:1768
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TProfile2D::SetBuffer
virtual void SetBuffer(Int_t buffersize, Option_t *option="")
Set the buffer size in units of 8 bytes (double).
Definition: TProfile2D.cxx:1868
TProfile2D
Definition: TProfile2D.h:27
TProfile2D::fgApproximate
static Bool_t fgApproximate
Definition: TProfile2D.h:47
TProfile2D::GetZmax
virtual Double_t GetZmax() const
Definition: TProfile2D.h:126
TProfile2D::Multiply
virtual Bool_t Multiply(TF1 *h1, Double_t c1=1)
Performs the operation: this = this*c1*f1.
Definition: TProfile2D.cxx:1149
Int_t
int Int_t
Definition: RtypesCore.h:45
TProfile2D::Add
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 .
Definition: TProfile2D.cxx:220
x
Double_t x[n]
Definition: legend1.C:17
TObject::MayNotUse
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:943
TArray::fN
Int_t fN
Definition: TArray.h:38
TProfile2D::RebinY
virtual TProfile2D * RebinY(Int_t ngroup=2, const char *newname="")
Rebin only the Y axis.
Definition: TProfile2D.cxx:1757
TProfile2D::Divide
virtual Bool_t Divide(TF1 *h1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) .
Definition: TProfile2D.cxx:414
TProfile2D::ProjectionXY
TH2D * ProjectionXY(const char *name="_pxy", Option_t *option="e") const
Project this profile2D into a 2-D histogram along X,Y.
Definition: TProfile2D.cxx:1201
TProfile.h
TProfile2D::Fill
Int_t Fill(const Double_t *v)
Definition: TProfile2D.h:56
TProfile2D::GetB2
Double_t * GetB2()
Definition: TProfile2D.h:69
v
@ v
Definition: rootcling_impl.cxx:3635
TProfile2D::RebinX
virtual TProfile2D * RebinX(Int_t ngroup=2, const char *newname="")
Rebin only the X axis.
Definition: TProfile2D.cxx:1749
h1
TH1F * h1
Definition: legend1.C:5
bool
TProfile2D::PutStats
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
Definition: TProfile2D.cxx:1386
TProfile2D::BuildOptions
void BuildOptions(Double_t zmin, Double_t zmax, Option_t *option)
Set Profile2D histogram structure and options.
Definition: TProfile2D.cxx:189
TProfile2D::GetW2
Double_t * GetW2()
Definition: TProfile2D.h:71
TProfile2D::Copy
virtual void Copy(TObject &hnew) const
Copy a Profile2D histogram to a new profile2D histogram.
Definition: TProfile2D.cxx:385
TProfile2D::TProfile2D
TProfile2D()
Default constructor for Profile2D histograms.
Definition: TProfile2D.cxx:88
TProfile2D::operator=
TProfile2D & operator=(const TProfile2D &profile)
Definition: TProfile2D.cxx:211
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
xmin
float xmin
Definition: THbookFile.cxx:95
TProfile2D::Scale
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this profile2D by a constant c1.
Definition: TProfile2D.cxx:1822
TProfile2D::fScaling
Bool_t fScaling
Definition: TProfile2D.h:43
TProfile2D::LabelsDeflate
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:946
TProfile2D::GetBinEffectiveEntries
virtual Double_t GetBinEffectiveEntries(Int_t bin)
Return bin effective entries for a weighted filled Profile histogram.
Definition: TProfile2D.cxx:828
TProfile2D::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow.
Definition: TProfile2D.cxx:1859
TH2D
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
TProfile2D::ProfileY
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.
Definition: TProfile2D.cxx:1301
TProfile2D::SetBins
void SetBins(const Int_t *nbins, const Double_t *range)
Definition: TProfile2D.h:54
TProfile2D::SetBinEntries
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin.
Definition: TProfile2D.cxx:1830
TProfile2D::BufferEmpty
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
Definition: TProfile2D.cxx:290
TProfile2D::DoProfile
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.
Definition: TProfile2D.cxx:1311
TProfile2D::SetErrorOption
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile2D errors.
Definition: TProfile2D.cxx:1906
TH2::GetBin
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:967
TProfile2D::BufferFill
virtual Int_t BufferFill(Double_t, Double_t)
accumulate arguments in buffer.
Definition: TProfile2D.h:49
y
Double_t y[n]
Definition: legend1.C:17
TH2.h
TH2::Fill
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:294
ymin
float ymin
Definition: THbookFile.cxx:95
TProfile2D::GetW
Double_t * GetW()
Definition: TProfile2D.h:70
TProfile
Definition: TProfile.h:32
TArrayD::Reset
void Reset()
Definition: TArrayD.h:53
TArrayD::fArray
Double_t * fArray
Definition: TArrayD.h:36
TProfile2D::fErrorMode
EErrorType fErrorMode
Definition: TProfile2D.h:40
TProfile2D::LabelsOption
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
Definition: TProfile2D.cxx:974
TProfile2D::ProfileX
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.
Definition: TProfile2D.cxx:1282
Double_t
double Double_t
Definition: RtypesCore.h:59
TProfile2D::fZmin
Double_t fZmin
Definition: TProfile2D.h:41
TProfile2D::fTsumwz2
Double_t fTsumwz2
Definition: TProfile2D.h:45
TProfile2D::GetBinErrorSqUnchecked
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Definition: TProfile2D.h:65
TProfile2D::GetBinSumw2
virtual TArrayD * GetBinSumw2()
Definition: TProfile2D.h:121
EErrorType
EErrorType
Definition: TProfile.h:28
TProfile2D::GetBinEntries
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile2D histogram.
Definition: TProfile2D.cxx:812
TProfile2D::ExtendAxis
virtual void ExtendAxis(Double_t x, TAxis *axis)
Profile histogram is resized along axis such that x is in the axis range.
Definition: TProfile2D.cxx:1426
TH1::fSumw2
TArrayD fSumw2
Array of sum of squares of weights.
Definition: TH1.h:102
TProfile2D::GetStats
virtual void GetStats(Double_t *stats) const
Fill the array stats from the contents of this profile.
Definition: TProfile2D.cxx:886
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
Definition: TH1.h:57
TProfile2D::LabelsInflate
virtual void LabelsInflate(Option_t *axis="X")
Double the number of bins for axis.
Definition: TProfile2D.cxx:956
name
char name[80]
Definition: TGX11.cxx:110
TProfileHelper
Definition: TProfileHelper.h:29
TProfile2D::Approximate
static void Approximate(Bool_t approx=kTRUE)
Static function, set the fgApproximate flag.
Definition: TProfile2D.cxx:276
TProfile2D::SetBins
void SetBins(Int_t, Double_t, Double_t)
Redefine x axis parameters.
Definition: TProfile2D.h:72
c2
return c2
Definition: legend2.C:14
TProfile2D::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return bin content of a Profile2D histogram.
Definition: TProfile2D.cxx:799
TCollection
Definition: TCollection.h:63
TProfile2D::Sumw2
virtual void Sumw2(Bool_t flag=kTRUE)
Create/Delete structure to store sum of squares of weights per bin.
Definition: TProfile2D.cxx:1955
TF1
1-Dim function class
Definition: TF1.h:212
TArrayD
Definition: TArrayD.h:27
TProfile2D::GetB
Double_t * GetB()
Definition: TProfile2D.h:68
TArray::GetSize
Int_t GetSize() const
Definition: TArray.h:47
TProfile2D::GetErrorOption
Option_t * GetErrorOption() const
Return option to compute profile2D errors.
Definition: TProfile2D.cxx:859
int
TProfile2D::fBinSumw2
TArrayD fBinSumw2
Definition: TProfile2D.h:46
TProfile2D::Rebin2D
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.
Definition: TProfile2D.cxx:1464
c1
return c1
Definition: legend1.C:41
TProfile2D::RetrieveBinContent
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:63