Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
26class TProfileHelper;
27
29
30class TF1;
31
32class TProfile : public TH1D {
33
34public:
35 friend class TProfileHelper;
36 friend class TH1Merger;
37
38protected:
39 TArrayD fBinEntries; ///< number of entries per bin
40 EErrorType fErrorMode; ///< Option to compute errors
41 Double_t fYmin; ///< Lower limit in Y (if set)
42 Double_t fYmax; ///< Upper limit in Y (if set)
43 Bool_t fScaling; ///<! True when TProfile::Scale is called
44 Double_t fTsumwy; ///< Total Sum of weight*Y
45 Double_t fTsumwy2; ///< Total Sum of weight*Y*Y
46 TArrayD fBinSumw2; ///< Array of sum of squares of weights per bin
47
48 static Bool_t fgApproximate; ///< bin error approximation option
49
50 Int_t BufferFill(Double_t, Double_t) override {return -2;} //may not use
52
53 // helper methods for the Merge unification in TProfileHelper
54 void SetBins(const Int_t* nbins, const Double_t* range) { SetBins(nbins[0], range[0], range[1]); };
55 Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2]); };
56
57 Double_t RetrieveBinContent(Int_t bin) const override { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
58 //virtual void UpdateBinContent(Int_t bin, Double_t content);
59 Double_t GetBinErrorSqUnchecked(Int_t bin) const override { Double_t err = GetBinError(bin); return err*err; }
60
61private:
62 Int_t Fill(Double_t) override { MayNotUse("Fill(Double_t)"); return -1;}
63 void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override { MayNotUse("FillN(Int_t, Double_t*, Double_t*, Int_t)"); }
65 Double_t *GetB2() {return fBinSumw2.fN ? &fBinSumw2.fArray[0] : nullptr; }
66 Double_t *GetW() {return &fArray[0];}
67 Double_t *GetW2() {return &fSumw2.fArray[0];}
69 { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
70 void SetBins(Int_t, const Double_t*, Int_t, const Double_t*) override
71 { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*"); }
73 { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
74 void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *) override
75 { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*, Int_t, const Double_t*"); }
76
77public:
78 TProfile();
79 TProfile(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup, Option_t *option="");
80 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="");
81 TProfile(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins, Option_t *option="");
82 TProfile(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins, Option_t *option="");
83 TProfile(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins, Double_t ylow,Double_t yup, Option_t *option="");
84 TProfile(const TProfile &profile);
85 TProfile &operator=(const TProfile &profile);
86 ~TProfile() override;
87 Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
88 Bool_t Add(const TH1 *h1, Double_t c1=1) override;
89 Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override; // *MENU*
90 static void Approximate(Bool_t approx=kTRUE);
91 Int_t BufferEmpty(Int_t action=0) override;
93 void Copy(TObject &hnew) const override;
94 Bool_t Divide(TF1 *h1, Double_t c1=1) override;
95 Bool_t Divide(const TH1 *h1) override;
96 Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override; // *MENU*
97 void ExtendAxis(Double_t x, TAxis *axis) override;
98 Int_t Fill(Double_t x, Double_t y) override;
99 Int_t Fill(const char *namex, Double_t y) override;
100 virtual Int_t Fill(Double_t x, Double_t y, Double_t w);
101 virtual Int_t Fill(const char *namex, Double_t y, Double_t w);
102 void FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1) override;
103 Double_t GetBinContent(Int_t bin) const override;
104 Double_t GetBinContent(Int_t bin, Int_t) const override {return GetBinContent(bin);}
105 Double_t GetBinContent(Int_t bin, Int_t, Int_t) const override {return GetBinContent(bin);}
106 Double_t GetBinError(Int_t bin) const override;
107 Double_t GetBinError(Int_t bin, Int_t) const override {return GetBinError(bin);}
108 Double_t GetBinError(Int_t bin, Int_t, Int_t) const override {return GetBinError(bin);}
109 virtual Double_t GetBinEntries(Int_t bin) const;
110 virtual Double_t GetBinEffectiveEntries(Int_t bin) const;
111 virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
112 virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
113 Option_t *GetErrorOption() const;
114 void GetStats(Double_t *stats) const override;
115 virtual Double_t GetYmin() const {return fYmin;}
116 virtual Double_t GetYmax() const {return fYmax;}
117 void LabelsDeflate(Option_t *axis="X") override;
118 void LabelsInflate(Option_t *axis="X") override;
119 void LabelsOption(Option_t *option="h", Option_t *axis="X") override;
120 Long64_t Merge(TCollection *list) override;
121 Bool_t Multiply(TF1 *h1, Double_t c1=1) override;
122 Bool_t Multiply(const TH1 *h1) override;
123 Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override; // *MENU*
124 TH1D *ProjectionX(const char *name="_px", Option_t *option="e") const;
125 void PutStats(Double_t *stats) override;
126 TH1 *Rebin(Int_t ngroup = 2, const char *newname = "", const Double_t *xbins = nullptr) override;
127 void Reset(Option_t *option="") override;
128 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
129 void Scale(Double_t c1=1, Option_t *option="") override;
130 virtual void SetBinEntries(Int_t bin, Double_t w);
131 void SetBins(Int_t nbins, Double_t xmin, Double_t xmax) override;
132 void SetBins(Int_t nx, const Double_t *xbins) override;
133 void SetBinsLength(Int_t n=-1) override;
134 void SetBuffer(Int_t buffersize, Option_t *option="") override;
135 virtual void SetErrorOption(Option_t *option=""); // *MENU*
136 void Sumw2(Bool_t flag = kTRUE) override;
137
138 ClassDefOverride(TProfile,7) //Profile histogram class
139};
140
141#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
EErrorType
Definition TProfile.h:28
@ kERRORSPREAD
Definition TProfile.h:28
@ kERRORSPREADG
Definition TProfile.h:28
@ kERRORSPREADI
Definition TProfile.h:28
@ kERRORMEAN
Definition TProfile.h:28
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Double_t * fArray
Definition TArrayD.h:30
void Reset()
Definition TArrayD.h:47
Int_t fN
Definition TArray.h:38
Class to manage histogram axis.
Definition TAxis.h:31
Collection abstract base class.
Definition TCollection.h:65
1-Dim function class
Definition TF1.h:233
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:669
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
TArrayD fSumw2
Array of sum of squares of weights.
Definition TH1.h:104
Mother of all ROOT objects.
Definition TObject.h:41
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:1040
Profile Histogram.
Definition TProfile.h:32
Double_t GetBinContent(Int_t bin) const override
Return bin content of a Profile histogram.
Definition TProfile.cxx:824
virtual Double_t GetBinEffectiveEntries(Int_t bin) const
Return bin effective entries for a weighted filled Profile histogram.
Definition TProfile.cxx:853
virtual TArrayD * GetBinSumw2()
Definition TProfile.h:111
Bool_t Divide(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this/(c1*f1).
Definition TProfile.cxx:453
TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=nullptr) override
Rebin this profile grouping ngroup bins together.
static Bool_t fgApproximate
bin error approximation option
Definition TProfile.h:48
void ExtendAxis(Double_t x, TAxis *axis) override
Profile histogram is resized along x axis such that x is in the axis range.
Double_t GetBinContent(Int_t bin, Int_t, Int_t) const override
Definition TProfile.h:105
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
void BuildOptions(Double_t ymin, Double_t ymax, Option_t *option)
Set Profile histogram structure and options.
Definition TProfile.cxx:227
void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *) override
Redefine x, y and z axis parameters with variable bin sizes.
Definition TProfile.h:74
EErrorType fErrorMode
Option to compute errors.
Definition TProfile.h:40
Long64_t Merge(TCollection *list) override
Merge all histograms in the collection in this histogram.
Int_t Fill(Double_t) override
Increment bin with abscissa X by 1.
Definition TProfile.h:62
virtual Double_t GetYmax() const
Definition TProfile.h:116
void Copy(TObject &hnew) const override
Copy a Profile histogram to a new profile histogram.
Definition TProfile.cxx:423
virtual Double_t GetYmin() const
Definition TProfile.h:115
void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t) override
Redefine x and y axis parameters.
Definition TProfile.h:68
void SetBins(Int_t, const Double_t *, Int_t, const Double_t *) override
Redefine x and y axis parameters with variable bin sizes.
Definition TProfile.h:70
virtual const TArrayD * GetBinSumw2() const
Definition TProfile.h:112
Double_t fYmax
Upper limit in Y (if set)
Definition TProfile.h:42
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin.
TH1D * ProjectionX(const char *name="_px", Option_t *option="e") const
Project this profile into a 1-D histogram along X.
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile errors.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile histogram.
Definition TProfile.cxx:837
void LabelsDeflate(Option_t *axis="X") override
Reduce the number of bins for this axis to the number of bins having a label.
Definition TProfile.cxx:973
Double_t * GetB2()
Definition TProfile.h:65
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow.
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this profile by a constant c1.
TProfile()
Default constructor for Profile histograms.
Definition TProfile.cxx:92
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
Definition TProfile.cxx:338
Double_t GetBinErrorSqUnchecked(Int_t bin) const override
Definition TProfile.h:59
void SetBuffer(Int_t buffersize, Option_t *option="") override
Set the buffer size in units of 8 bytes (double).
void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override
Fill this histogram with an array x and weights w.
Definition TProfile.h:63
TProfile & operator=(const TProfile &profile)
Definition TProfile.cxx:249
void Sumw2(Bool_t flag=kTRUE) override
Create/delete structure to store sum of squares of weights per bin.
void LabelsInflate(Option_t *axis="X") override
Double the number of bins for axis.
Definition TProfile.cxx:983
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Definition TProfile.h:45
void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t) override
Redefine x, y and z axis parameters.
Definition TProfile.h:72
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TProfile.h:57
Double_t GetBinContent(Int_t bin, Int_t) const override
Definition TProfile.h:104
Bool_t Multiply(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this*c1*f1.
TArrayD fBinSumw2
Array of sum of squares of weights per bin.
Definition TProfile.h:46
Double_t GetBinError(Int_t bin) const override
Return bin error of a Profile histogram.
Definition TProfile.cxx:888
Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override
Performs the operation: this = this + c1*f1.
Definition TProfile.cxx:259
Double_t GetBinError(Int_t bin, Int_t, Int_t) const override
Definition TProfile.h:108
Int_t Fill(const Double_t *v)
Definition TProfile.h:55
Double_t fTsumwy
Total Sum of weight*Y.
Definition TProfile.h:44
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
Definition TProfile.h:50
Double_t * GetB()
Definition TProfile.h:64
~TProfile() override
Default destructor for Profile histograms.
Definition TProfile.cxx:100
void SetBins(const Int_t *nbins, const Double_t *range)
Definition TProfile.h:54
Double_t fYmin
Lower limit in Y (if set)
Definition TProfile.h:41
TArrayD fBinEntries
number of entries per bin
Definition TProfile.h:39
Double_t GetBinError(Int_t bin, Int_t) const override
Definition TProfile.h:107
Double_t * GetW()
Definition TProfile.h:66
static void Approximate(Bool_t approx=kTRUE)
Static function to set the fgApproximate flag.
Definition TProfile.cxx:324
Bool_t fScaling
! True when TProfile::Scale is called
Definition TProfile.h:43
void GetStats(Double_t *stats) const override
fill the array stats from the contents of this profile.
Definition TProfile.cxx:921
Option_t * GetErrorOption() const
Return option to compute profile errors.
Definition TProfile.cxx:896
void LabelsOption(Option_t *option="h", Option_t *axis="X") override
Set option(s) to draw axis with labels.
Double_t * GetW2()
Definition TProfile.h:67
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TH1F * h1
Definition legend1.C:5
return c2
Definition legend2.C:14