Logo ROOT  
Reference Guide
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 
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
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];}
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*"); }
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);
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 
n
const Int_t n
Definition: legend1.C:16
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
TProfile::GetBinEntries
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile histogram.
Definition: TProfile.cxx:830
TProfile::SetBinEntries
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin.
Definition: TProfile.cxx:1636
ymax
float ymax
Definition: THbookFile.cxx:95
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TProfile::TProfile
TProfile()
Default constructor for Profile histograms.
Definition: TProfile.cxx:92
TProfile::operator=
TProfile & operator=(const TProfile &profile)
Definition: TProfile.cxx:249
TProfile::GetBinError
virtual Double_t GetBinError(Int_t bin) const
Return bin error of a Profile histogram.
Definition: TProfile.cxx:881
TProfile::Rebin
TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=0)
Rebin this profile grouping ngroup bins together.
Definition: TProfile.cxx:1346
TProfile::Merge
virtual Long64_t Merge(TCollection *list)
Merge all histograms in the collection in this histogram.
Definition: TProfile.cxx:1128
TProfile::GetBinEffectiveEntries
virtual Double_t GetBinEffectiveEntries(Int_t bin) const
Return bin effective entries for a weighted filled Profile histogram.
Definition: TProfile.cxx:846
TProfile::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: TProfile.cxx:962
TProfile::LabelsInflate
virtual void LabelsInflate(Option_t *axis="X")
Double the number of bins for axis.
Definition: TProfile.cxx:972
TProfile::~TProfile
virtual ~TProfile()
Default destructor for Profile histograms.
Definition: TProfile.cxx:100
TProfile::BufferEmpty
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
Definition: TProfile.cxx:334
xmax
float xmax
Definition: THbookFile.cxx:95
TProfile::Add
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1.
Definition: TProfile.cxx:258
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TProfile::ExtendAxis
virtual void ExtendAxis(Double_t x, TAxis *axis)
Profile histogram is resized along x axis such that x is in the axis range.
Definition: TProfile.cxx:1519
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:615
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TProfile::GetYmax
virtual Double_t GetYmax() const
Definition: TProfile.h:115
TProfile::SetBins
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: TProfile.h:73
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
TProfile::Sumw2
virtual void Sumw2(Bool_t flag=kTRUE)
Create/delete structure to store sum of squares of weights per bin.
Definition: TProfile.cxx:1761
TArray::fN
Int_t fN
Definition: TArray.h:38
TProfile::Divide
virtual Bool_t Divide(TF1 *h1, Double_t c1=1)
Performs the operation: this = this/(c1*f1).
Definition: TProfile.cxx:449
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
v
@ v
Definition: rootcling_impl.cxx:3635
TProfile::fYmax
Double_t fYmax
Definition: TProfile.h:41
h1
TH1F * h1
Definition: legend1.C:5
bool
TProfile::GetB2
Double_t * GetB2()
Definition: TProfile.h:64
kERRORMEAN
@ kERRORMEAN
Definition: TProfile.h:28
TProfile::GetBinErrorSqUnchecked
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Definition: TProfile.h:58
TProfile::fTsumwy
Double_t fTsumwy
True when TProfile::Scale is called.
Definition: TProfile.h:43
TProfile::PutStats
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
Definition: TProfile.cxx:1294
TProfile::LabelsOption
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
Definition: TProfile.cxx:990
TProfile::fTsumwy2
Double_t fTsumwy2
Definition: TProfile.h:44
TProfile::FillN
void FillN(Int_t, const Double_t *, const Double_t *, Int_t)
Fill this histogram with an array x and weights w.
Definition: TProfile.h:62
TProfile::GetW2
Double_t * GetW2()
Definition: TProfile.h:66
TProfile::GetBinContent
virtual Double_t GetBinContent(Int_t bin, Int_t, Int_t) const
Definition: TProfile.h:104
TProfile::GetBinSumw2
virtual TArrayD * GetBinSumw2()
Definition: TProfile.h:110
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TProfile::SetBuffer
virtual void SetBuffer(Int_t buffersize, Option_t *option="")
Set the buffer size in units of 8 bytes (double).
Definition: TProfile.cxx:1674
TProfile::GetW
Double_t * GetW()
Definition: TProfile.h:65
TProfile::Approximate
static void Approximate(Bool_t approx=kTRUE)
Static function to set the fgApproximate flag.
Definition: TProfile.cxx:320
TProfile::SetBins
void SetBins(Int_t, const Double_t *, Int_t, const Double_t *)
Redefine x and y axis parameters with variable bin sizes.
Definition: TProfile.h:69
xmin
float xmin
Definition: THbookFile.cxx:95
TProfile::Fill
Int_t Fill(const Double_t *v)
Definition: TProfile.h:54
TProfile::GetYmin
virtual Double_t GetYmin() const
Definition: TProfile.h:114
TProfile::GetStats
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this profile.
Definition: TProfile.cxx:914
TProfile::BufferFill
virtual Int_t BufferFill(Double_t, Double_t)
accumulate arguments in buffer.
Definition: TProfile.h:49
y
Double_t y[n]
Definition: legend1.C:17
TProfile::GetBinContent
virtual Double_t GetBinContent(Int_t bin, Int_t) const
Definition: TProfile.h:103
TProfile::Copy
virtual void Copy(TObject &hnew) const
Copy a Profile histogram to a new profile histogram.
Definition: TProfile.cxx:419
kERRORSPREADI
@ kERRORSPREADI
Definition: TProfile.h:28
TProfile::SetErrorOption
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile errors.
Definition: TProfile.cxx:1713
TProfile::GetErrorOption
Option_t * GetErrorOption() const
Return option to compute profile errors.
Definition: TProfile.cxx:889
ymin
float ymin
Definition: THbookFile.cxx:95
TProfile
Definition: TProfile.h:32
TArrayD::Reset
void Reset()
Definition: TArrayD.h:53
TArrayD::fArray
Double_t * fArray
Definition: TArrayD.h:36
Double_t
double Double_t
Definition: RtypesCore.h:59
TProfile::BuildOptions
void BuildOptions(Double_t ymin, Double_t ymax, Option_t *option)
Set Profile histogram structure and options.
Definition: TProfile.cxx:227
TProfile::GetB
Double_t * GetB()
Definition: TProfile.h:63
TProfile::fgApproximate
static Bool_t fgApproximate
Definition: TProfile.h:47
EErrorType
EErrorType
Definition: TProfile.h:28
TH1::fSumw2
TArrayD fSumw2
Array of sum of squares of weights.
Definition: TH1.h:102
TObject
Definition: TObject.h:37
TProfile::Fill
Int_t Fill(Double_t)
Increment bin with abscissa X by 1.
Definition: TProfile.h:61
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TProfile::SetBins
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: TProfile.h:71
TProfile::GetBinError
virtual Double_t GetBinError(Int_t bin, Int_t, Int_t) const
Definition: TProfile.h:107
TH1
Definition: TH1.h:57
name
char name[80]
Definition: TGX11.cxx:110
TProfileHelper
Definition: TProfileHelper.h:29
c2
return c2
Definition: legend2.C:14
TProfile::GetBinError
virtual Double_t GetBinError(Int_t bin, Int_t) const
Definition: TProfile.h:106
kERRORSPREADG
@ kERRORSPREADG
Definition: TProfile.h:28
TProfile::fBinEntries
TArrayD fBinEntries
Definition: TProfile.h:38
TProfile::GetBinSumw2
virtual const TArrayD * GetBinSumw2() const
Definition: TProfile.h:111
TProfile::SetBins
void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t)
Redefine x and y axis parameters.
Definition: TProfile.h:67
TCollection
Definition: TCollection.h:63
TProfile::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow.
Definition: TProfile.cxx:1665
TProfile::fScaling
Bool_t fScaling
Definition: TProfile.h:42
TF1
1-Dim function class
Definition: TF1.h:212
TArrayD
Definition: TArrayD.h:27
TProfile::fYmin
Double_t fYmin
Definition: TProfile.h:40
kERRORSPREAD
@ kERRORSPREAD
Definition: TProfile.h:28
TH1.h
TProfile::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return bin content of a Profile histogram.
Definition: TProfile.cxx:817
TProfile::SetBins
void SetBins(const Int_t *nbins, const Double_t *range)
Definition: TProfile.h:53
TProfile::Multiply
virtual Bool_t Multiply(TF1 *h1, Double_t c1=1)
Performs the operation: this = this*c1*f1.
Definition: TProfile.cxx:1138
TProfile::Scale
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this profile by a constant c1.
Definition: TProfile.cxx:1628
TProfile::fErrorMode
EErrorType fErrorMode
Definition: TProfile.h:39
TProfile::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TProfile.cxx:1548
int
c1
return c1
Definition: legend1.C:41
TProfile::fBinSumw2
TArrayD fBinSumw2
Definition: TProfile.h:45
TProfile::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: TProfile.h:56
TProfile::ProjectionX
TH1D * ProjectionX(const char *name="_px", Option_t *option="e") const
Project this profile into a 1-D histogram along X.
Definition: TProfile.cxx:1219