Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TProfile3D.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 17/05/2006
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_TProfile3D
13#define ROOT_TProfile3D
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TProfile3D //
19// //
20// Profile3D histogram class. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TH3.h"
25#include "TProfile.h"
26
27class TProfile3D : public TH3D {
28
29public:
30 friend class TProfileHelper;
31 friend class TH1Merger;
32 template <typename T>
33 friend T ROOT::Internal::Slice(const T &histo, std::vector<Int_t> &args);
34
35protected:
36 TArrayD fBinEntries; ///< Number of entries per bin
37 EErrorType fErrorMode; ///< Option to compute errors
38 Double_t fTmin; ///< Lower limit in T (if set)
39 Double_t fTmax; ///< Upper limit in T (if set)
40 Bool_t fScaling; ///<! True when TProfile3D::Scale is called
41 Double_t fTsumwt; ///< Total Sum of weight*T
42 Double_t fTsumwt2; ///< Total Sum of weight*T*T
43 TArrayD fBinSumw2; ///< Array of sum of squares of weights per bin
44 static Bool_t fgApproximate; ///< Bin error approximation option
45
46 Int_t BufferFill(Double_t, Double_t) override {return -2;} //may not use
47 Int_t BufferFill(Double_t, Double_t, Double_t) override {return -2;} //may not use
48 Int_t BufferFill(Double_t, Double_t, Double_t, Double_t) override {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 nbins[2], range[4], range[5]); };
55 Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2], v[3], v[4]); };
56
57
58 using TH3::Fill;
59 Int_t Fill(Double_t, Double_t,Double_t) override {return TH3::Fill(0); } //MayNotUse
60 Int_t Fill(const char *, const char *, const char *, Double_t) override {return TH3::Fill(0); } //MayNotUse
61 Int_t Fill(const char *, Double_t , const char *, Double_t) override {return TH3::Fill(0); } //MayNotUse
62 Int_t Fill(const char *, const char *, Double_t, Double_t) override {return TH3::Fill(0); } //MayNotUse
63 Int_t Fill(Double_t, const char *, const char *, Double_t) override {return TH3::Fill(0); } //MayNotUse
64 Int_t Fill(Double_t, const char *, Double_t, Double_t) override {return TH3::Fill(0); } //MayNotUse
65 Int_t Fill(Double_t, Double_t, const char *, Double_t) override {return TH3::Fill(0); } //MayNotUse
66
67 Double_t RetrieveBinContent(Int_t bin) const override { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
68 //virtual void UpdateBinContent(Int_t bin, Double_t content);
69 Double_t GetBinErrorSqUnchecked(Int_t bin) const override { Double_t err = GetBinError(bin); return err*err; }
70
71 TProfile2D *DoProjectProfile2D(const char* name, const char * title, const TAxis* projX, const TAxis* projY,
72 bool originalRange, bool useUF, bool useOF, bool useWidth) const override;
73
74private:
76 Double_t *GetB2() {return fBinSumw2.fN ? &fBinSumw2.fArray[0] : nullptr;}
77 Double_t *GetW() {return &fArray[0];}
78 Double_t *GetW2() {return &fSumw2.fArray[0];}
79 void SetBins(Int_t, Double_t, Double_t) override
80 { MayNotUse("SetBins(Int_t, Double_t, Double_t"); }
81 void SetBins(Int_t, const Double_t*) override
82 { MayNotUse("SetBins(Int_t, const Double_t*"); }
84 { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
85 void SetBins(Int_t, const Double_t*, Int_t, const Double_t*) override
86 { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*"); }
87
88public:
89 TProfile3D();
90 TProfile3D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
91 ,Int_t nbinsy,Double_t ylow,Double_t yup
92 ,Int_t nbinsz,Double_t zlow,Double_t zup, Option_t *option="");
93 TProfile3D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
94 ,Int_t nbinsy,const Double_t *ybins
95 ,Int_t nbinsz,const Double_t *zbins,Option_t *option="");
96 TProfile3D(const TProfile3D &profile);
97 TProfile3D &operator=(const TProfile3D &profile);
98 ~TProfile3D() override;
99 Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
100 Bool_t Add(const TH1 *h1, Double_t c1=1) override;
101 Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override;
102 static void Approximate(Bool_t approx=kTRUE);
103 void BuildOptions(Double_t tmin, Double_t tmax, Option_t *option);
104 Int_t BufferEmpty(Int_t action=0) override;
105 Double_t Chi2Test(const TH1* h2, Option_t *option = "WW", Double_t *res = nullptr) const override;
106 void Copy(TObject &hnew) const override;
107 Bool_t Divide(TF1 *h1, Double_t c1=1) override;
108 Bool_t Divide(const TH1 *h1) override;
109 Bool_t Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override;
110 void ExtendAxis(Double_t x, TAxis *axis) override;
111 Int_t Fill(Double_t x, Double_t y, Double_t z, Double_t t) override;
113 Double_t GetBinContent(Int_t bin) const override;
115 { MayNotUse("GetBinContent(Int_t, Int_t"); return -1; }
116 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const override {return GetBinContent(GetBin(binx,biny,binz));}
117 Double_t GetBinError(Int_t bin) const override;
119 { MayNotUse("GetBinError(Int_t, Int_t"); return -1; }
120 Double_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const override {return GetBinError(GetBin(binx,biny,binz));}
121 virtual Double_t GetBinEntries(Int_t bin) const;
123 virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
124 virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
125 Option_t *GetErrorOption() const;
126 void GetStats(Double_t *stats) const override;
127 virtual Double_t GetTmin() const {return fTmin;}
128 virtual Double_t GetTmax() const {return fTmax;}
129 void LabelsDeflate(Option_t *axis="X") override;
130 void LabelsInflate(Option_t *axis="X") override;
131 void LabelsOption(Option_t *option="h", Option_t *axis="X") override;
132 Long64_t Merge(TCollection *list) override;
133 Bool_t Multiply(TF1 *h1, Double_t c1=1) override;
134 Bool_t Multiply(const TH1 *h1) override;
135 Bool_t Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override;
136 virtual TH3D *ProjectionXYZ(const char *name="_pxyz", Option_t *option="e") const;
137 TProfile2D *Project3DProfile(Option_t *option="xy") const override; // *MENU*
138 void PutStats(Double_t *stats) override;
139 void Reset(Option_t *option="") override;
140 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
141 void Scale(Double_t c1=1, Option_t *option="") override;
142 virtual void SetBinEntries(Int_t bin, Double_t w);
143 void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax,
145 Int_t nbinsz, Double_t zmin, Double_t zmax) override;
146 void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t * yBins, Int_t nz,
147 const Double_t *zBins) override;
148 void SetBinsLength(Int_t n=-1) override;
149 void SetBuffer(Int_t bufsize, Option_t *opt="") override;
150 virtual void SetErrorOption(Option_t *option=""); // *MENU*
151 void Sumw2(Bool_t flag = kTRUE) override;
152
153 ClassDefOverride(TProfile3D,8) //Profile3D histogram class
154};
155
156#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
#define ClassDefOverride(name, id)
Definition Rtypes.h:347
void MayNotUse(const char *method)
This function can be used in classes that should override a certain function, but in the inherited cl...
Definition TError.cxx:191
Option_t Option_t option
char name[80]
Definition TGX11.cxx:142
float xmin
float ymin
float xmax
float ymax
EErrorType
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:32
Collection abstract base class.
Definition TCollection.h:65
1-Dim function class
Definition TF1.h:182
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:125
TArrayD fSumw2
Array of sum of squares of weights.
Definition TH1.h:181
3-D histogram with a double per channel (see TH1 documentation)
Definition TH3.h:424
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH3.cxx:345
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz) const override
See comments in TH1::GetBin.
Definition TH3.cxx:1144
Mother of all ROOT objects.
Definition TObject.h:42
Profile2D histograms are used to display the mean value of Z and its error for each cell in X,...
Definition TProfile2D.h:27
Profile3D histograms are used to display the mean value of T and its RMS for each cell in X,...
Definition TProfile3D.h:27
TProfile3D & operator=(const TProfile3D &profile)
Double_t GetBinErrorSqUnchecked(Int_t bin) const override
Definition TProfile3D.h:69
Double_t * GetW()
Definition TProfile3D.h:77
Long64_t Merge(TCollection *list) override
Merge all histograms in the collection in this histogram.
static Bool_t fgApproximate
Bin error approximation option.
Definition TProfile3D.h:44
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 TProfile3D.h:67
Option_t * GetErrorOption() const
Return option to compute profile2D errors.
Bool_t fScaling
! True when TProfile3D::Scale is called
Definition TProfile3D.h:40
void SetBins(const Int_t *nbins, const Double_t *range)
Definition TProfile3D.h:52
Int_t Fill(Double_t, Double_t, Double_t) override
Increment cell defined by x,y,z by 1 .
Definition TProfile3D.h:59
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
Double_t Chi2Test(const TH1 *h2, Option_t *option="WW", Double_t *res=nullptr) const override
Run a Chi2Test between a TProfile3D and another histogram.
void Copy(TObject &hnew) const override
Copy a Profile3D histogram to a new profile2D histogram.
void SetBins(Int_t, const Double_t *) override
Redefine x axis parameters with variable bin sizes.
Definition TProfile3D.h:81
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
Definition TProfile3D.h:46
void SetBuffer(Int_t bufsize, Option_t *opt="") override
Set the buffer size in units of 8 bytes (double).
Double_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const override
Definition TProfile3D.h:116
TProfile2D * DoProjectProfile2D(const char *name, const char *title, const TAxis *projX, const TAxis *projY, bool originalRange, bool useUF, bool useOF, bool useWidth) const override
Internal method to project to a 2D Profile.
Int_t Fill(Double_t, const char *, Double_t, Double_t) override
Increment cell defined by x,namey,z by a weight w.
Definition TProfile3D.h:64
Double_t fTsumwt2
Total Sum of weight*T*T.
Definition TProfile3D.h:42
virtual Double_t GetBinEffectiveEntries(Int_t bin)
Return bin effective entries for a weighted filled Profile histogram.
void GetStats(Double_t *stats) const override
fill the array stats from the contents of this profile.
Int_t Fill(const char *, const char *, const char *, Double_t) override
Increment cell defined by namex,namey,namez by a weight w.
Definition TProfile3D.h:60
Bool_t Multiply(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this*c1*f1 .
void LabelsOption(Option_t *option="h", Option_t *axis="X") override
Set option(s) to draw axis with labels.
TProfile3D()
Default constructor for Profile3D histograms.
Int_t Fill(const char *, Double_t, const char *, Double_t) override
Increment cell defined by namex,y,namez by a weight w.
Definition TProfile3D.h:61
virtual TArrayD * GetBinSumw2()
Definition TProfile3D.h:123
TArrayD fBinEntries
Number of entries per bin.
Definition TProfile3D.h:36
void LabelsDeflate(Option_t *axis="X") override
Reduce the number of bins for this axis to the number of bins having a label.
void SetBins(Int_t, const Double_t *, Int_t, const Double_t *) override
Redefine x and y axis parameters with variable bin sizes.
Definition TProfile3D.h:85
~TProfile3D() override
Default destructor for Profile3D histograms.
void ExtendAxis(Double_t x, TAxis *axis) override
Profile histogram is resized along axis such that x is in the axis range.
Double_t fTmin
Lower limit in T (if set)
Definition TProfile3D.h:38
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this profile2D by a constant c1.
void Sumw2(Bool_t flag=kTRUE) override
Create/Delete structure to store sum of squares of weights per bin This is needed to compute the corr...
void LabelsInflate(Option_t *axis="X") override
Double the number of bins for axis.
TProfile2D * Project3DProfile(Option_t *option="xy") const override
Project a 3-D profile into a 2D-profile histogram depending on the option parameter.
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin.
Int_t BufferFill(Double_t, Double_t, Double_t, Double_t) override
Accumulate arguments in buffer.
Definition TProfile3D.h:48
void BuildOptions(Double_t tmin, Double_t tmax, Option_t *option)
Set Profile3D histogram structure and options.
Int_t Fill(const Double_t *v)
Definition TProfile3D.h:55
TArrayD fBinSumw2
Array of sum of squares of weights per bin.
Definition TProfile3D.h:43
Double_t * GetB()
Definition TProfile3D.h:75
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
virtual Double_t GetTmax() const
Definition TProfile3D.h:128
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile3D errors.
Int_t BufferFill(Double_t, Double_t, Double_t) override
Definition TProfile3D.h:47
void SetBins(Int_t, Double_t, Double_t) override
Redefine x axis parameters.
Definition TProfile3D.h:79
virtual TH3D * ProjectionXYZ(const char *name="_pxyz", Option_t *option="e") const
Project this profile3D into a 3-D histogram along X,Y,Z.
Double_t GetBinError(Int_t, Int_t) const override
Definition TProfile3D.h:118
Double_t * GetB2()
Definition TProfile3D.h:76
Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override
Performs the operation: this = this + c1*f1 .
Double_t GetBinContent(Int_t bin) const override
Return bin content of a Profile3D histogram.
EErrorType fErrorMode
Option to compute errors.
Definition TProfile3D.h:37
Int_t Fill(Double_t, const char *, const char *, Double_t) override
Increment cell defined by x,namey,namez by a weight w.
Definition TProfile3D.h:63
virtual const TArrayD * GetBinSumw2() const
Definition TProfile3D.h:124
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow.
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile3D histogram.
Double_t GetBinError(Int_t binx, Int_t biny, Int_t binz) const override
Definition TProfile3D.h:120
virtual Double_t GetTmin() const
Definition TProfile3D.h:127
Double_t * GetW2()
Definition TProfile3D.h:78
Bool_t Divide(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this/(c1*f1) .
Double_t GetBinContent(Int_t, Int_t) const override
Definition TProfile3D.h:114
Double_t fTsumwt
Total Sum of weight*T.
Definition TProfile3D.h:41
Int_t Fill(Double_t, Double_t, const char *, Double_t) override
Increment cell defined by x,y,namez by a weight w.
Definition TProfile3D.h:65
Int_t Fill(const char *, const char *, Double_t, Double_t) override
Increment cell defined by namex,namey,z by a weight w.
Definition TProfile3D.h:62
void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t) override
Redefine x and y axis parameters.
Definition TProfile3D.h:83
static void Approximate(Bool_t approx=kTRUE)
Set the fgApproximate flag.
Double_t fTmax
Upper limit in T (if set)
Definition TProfile3D.h:39
Double_t GetBinError(Int_t bin) const override
Return bin error of a Profile3D histogram.
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
T Slice(const T &histo, std::vector< Int_t > &args)
Creates a sliced copy of the given histogram.
Definition TH1.h:78