112TProfile3D::TProfile3D(
const char *
name,
const char *title,
Int_t nx,
Double_t xlow,
Double_t xup,
Int_t ny,
Double_t ylow,
Double_t yup,
Int_t nz,
Double_t zlow,
Double_t zup,
Option_t *option)
113 :
TH3D(
name,title,nx,xlow,xup,ny,ylow,yup,nz,zlow,zup)
123 :
TH3D(
name,title,nx,xbins,ny,ybins,nz,zbins)
158 profile3d.TProfile3D::Copy(*
this);
163 if (
this != &profile3d)
164 profile3d.TProfile3D::Copy(*
this);
173 Error(
"Add",
"Function not implemented for TProfile3D");
183 Error(
"Add",
"Attempt to add a non-existing profile");
187 Error(
"Add",
"Attempt to add a non-profile2D object");
202 Error(
"Add",
"Attempt to add a non-existing profile");
206 Error(
"Add",
"Attempt to add a non-profile3D object");
210 Error(
"Add",
"Attempt to add a non-profile3D object");
250 if (!nbentries)
return 0;
253 if (action == 0)
return 0;
254 nbentries = -nbentries;
267 for (
Int_t i=1;i<nbentries;i++) {
275 if (z < zmin) zmin = z;
276 if (z > zmax) zmax = z;
295 for (
Int_t i=0;i<nbentries;i++) {
296 Fill(buffer[5*i+2],buffer[5*i+3],buffer[5*i+4],buffer[5*i+5],buffer[5*i+1]);
325 nbentries = -nbentries;
356 if (
auto other =
dynamic_cast<const TProfile3D *
>(h2); other) {
358 Error(
"Chi2Test",
"Chi2 tests need TProfiles in 'error of mean' mode.");
366 Error(
"Chi2Test",
"TProfiles need to be tested with the 'W' option. Either use option 'WW' or use "
367 "histogram.Chi2Test(<profile>, 'UW')");
385 for (
int bin=0;bin<
fNcells;bin++) {
408 Error(
"Divide",
"Function not implemented for TProfile3D");
422 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
426 Error(
"Divide",
"Attempt to divide a non-profile3D object");
437 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
442 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
447 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
455 Int_t bin,binx,biny,binz;
460 for (binx =0;binx<=nx+1;binx++) {
461 for (biny =0;biny<=ny+1;biny++) {
462 for (binz =0;binz<=nz+1;binz++) {
463 bin =
GetBin(binx,biny,binz);
472 z =
fZaxis.GetBinCenter(binz);
491 else fSumw2.fArray[bin] = (e0*
c1*
c1 + e1*c0*c0)/(c12*c12);
500 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
520 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
524 Error(
"Divide",
"Attempt to divide a non-profile2D object");
529 Error(
"Divide",
"Attempt to divide a non-profile2D object");
537 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
542 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
547 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
551 Error(
"Divide",
"Coefficient of dividing profile cannot be zero");
559 Int_t bin,binx,biny,binz;
569 for (binx =0;binx<=nx+1;binx++) {
570 for (biny =0;biny<=ny+1;biny++) {
571 for (binz =0;binz<=nz+1;binz++) {
572 bin =
GetBin(binx,biny,binz);
575 if (b2) w =
c1*b1/(
c2*b2);
581 z =
fZaxis.GetBinCenter(biny);
600 if (!b2)
fSumw2.fArray[bin] = 0;
605 fSumw2.fArray[bin] = ac1*ac2*(e1*b2*b2 + e2*b1*b1)/(b22*b22);
623 Int_t bin,binx,biny,binz;
633 if (binx <0 || biny <0 || binz<0)
return -1;
634 bin =
GetBin(binx,biny,binz);
639 if (binx == 0 || binx >
fXaxis.GetNbins()) {
642 if (biny == 0 || biny >
fYaxis.GetNbins()) {
645 if (binz == 0 || binz >
fZaxis.GetNbins()) {
672 Int_t bin,binx,biny,binz;
683 if (binx <0 || biny <0 || binz<0)
return -1;
684 bin =
GetBin(binx,biny,binz);
686 fSumw2.fArray[bin] += u*t*t;
690 if (binx == 0 || binx >
fXaxis.GetNbins()) {
693 if (biny == 0 || biny >
fYaxis.GetNbins()) {
696 if (binz == 0 || binz >
fZaxis.GetNbins()) {
722 if (bin < 0 || bin >=
fNcells)
return 0;
735 if (bin < 0 || bin >=
fNcells)
return 0;
824 Int_t bin, binx, biny,binz;
827 for (bin=0;bin<
kNstat;bin++) stats[bin] = 0;
829 for (binz=
fZaxis.GetFirst();binz<=
fZaxis.GetLast();binz++) {
830 z = (!labelZaxis) ?
fZaxis.GetBinCenter(binz) : 0;
831 for (biny=
fYaxis.GetFirst();biny<=
fYaxis.GetLast();biny++) {
832 y = (!labelYaxis) ?
fYaxis.GetBinCenter(biny) : 0;
833 for (binx=
fXaxis.GetFirst();binx<=
fXaxis.GetLast();binx++) {
834 bin =
GetBin(binx,biny,binz);
837 x = (!labelXaxis) ?
fXaxis.GetBinCenter(binx) : 0;
850 stats[12] +=
fSumw2.fArray[bin];
904 Error(
"LabelsOption",
"Labels option function is not implemented for a TProfile3D");
931 Error(
"Multiply",
"Function not implemented for TProfile3D");
942 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
953 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
1002 if (pname ==
"_px") {
1006 if (xbins->fN == 0 && ybins->
fN == 0 && zbins->
fN == 0)
1007 h1 =
new TH3D(pname,
GetTitle(),nx,
fXaxis.GetXmin(),
fXaxis.GetXmax(),ny,
fYaxis.GetXmin(),
fYaxis.GetXmax(),nz,
fZaxis.GetXmin(),
fZaxis.GetXmax());
1008 else if ( xbins->fN != 0 && ybins->
fN != 0 && zbins->
fN != 0)
1011 Error(
"ProjectionXYZ",
"Histogram has an axis with variable bins and an axis with fixed bins. This case is not supported - return a null pointer");
1025 if (computeErrors || binWeight || (binEntries &&
fBinSumw2.fN) )
h1->Sumw2();
1028 Int_t bin,binx,biny,binz;
1030 for (binx =0;binx<=nx+1;binx++) {
1031 for (biny =0;biny<=ny+1;biny++) {
1032 for (binz =0;binz<=nz+1;binz++) {
1033 bin =
GetBin(binx,biny,binz);
1040 h1->SetBinContent(bin ,cont);
1043 if (computeErrors )
h1->SetBinError(bin ,
GetBinError(bin) );
1046 if (binWeight)
h1->GetSumw2()->fArray[bin] =
fSumw2.fArray[bin];
1050 h1->GetSumw2()->fArray[bin] =
fBinSumw2.fArray[bin];
1097 bool originalRange,
bool useUF,
bool useOF,
bool useWidth)
const
1104 if (ixmin == 0 && ixmax == 0) { ixmin = 1; ixmax = projX->
GetNbins(); }
1105 if (iymin == 0 && iymax == 0) { iymin = 1; iymax = projY->
GetNbins(); }
1106 Int_t nx = ixmax-ixmin+1;
1107 Int_t ny = iymax-iymin+1;
1116 if ( originalRange ) {
1117 if (xbins->fN == 0 && ybins->
fN == 0) {
1124 if (xbins->fN == 0 && ybins->
fN == 0) {
1134 if (useWeights) p2->
Sumw2();
1169 TH2D * h2W =
TH3::DoProject2D(*h3dW,
"htemp-W",
"",projX_hW, projY_hW,
true, originalRange, useUF, useOF, useWidth);
1170 TH2D * h2N =
TH3::DoProject2D(*h3dN,
"htemp-N",
"",projX_hN, projY_hN, useWeights, originalRange, useUF, useOF, useWidth);
1178 for (
int i = 0; i < p2->
fN ; ++i) {
1250 TString sxaxis, syaxis, szaxis;
1265 out << sxaxis <<
".data()";
1271 out << syaxis <<
".data()";
1277 out << szaxis <<
".data()";
1284 Int_t numentries = 0, numcontent = 0, numerrors = 0;
1291 content[bin] =
fArray[bin];
1301 if ((numentries < 100) && (numcontent < 100) && (numerrors < 100)) {
1305 out <<
" " << hname <<
"->SetBinEntries(" << bin <<
"," << entries[bin] <<
");\n";
1309 out <<
" " << hname <<
"->SetBinContent(" << bin <<
"," << content[bin] <<
");\n";
1314 out <<
" " << hname <<
"->SetBinError(" << bin <<
"," << errors[bin] <<
");\n";
1317 if (numentries > 0) {
1319 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1320 out <<
" if (" << vect <<
"[bin])\n";
1321 out <<
" " << hname <<
"->SetBinEntries(bin, " << vect <<
"[bin]);\n";
1323 if (numcontent > 0) {
1325 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1326 out <<
" if (" << vect <<
"[bin])\n";
1327 out <<
" " << hname <<
"->SetBinContent(bin, " << vect <<
"[bin]);\n";
1329 if (numerrors > 0) {
1331 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1332 out <<
" if (" << vect <<
"[bin])\n";
1333 out <<
" " << hname <<
"->SetBinError(bin, " << vect <<
"[bin]);\n";
1405 if (bufsize < 100) bufsize = 100;
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
TArrayD()
Default TArrayD ctor.
const Double_t * GetArray() const
Class to manage histogram axis.
const TArrayD * GetXbins() const
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
Collection abstract base class.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Double_t * fBuffer
[fBufferSize] entry buffer
virtual Double_t GetEffectiveEntries() const
Number of effective entries of the histogram.
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
Double_t fTsumw
Total Sum of weights.
Double_t fTsumw2
Total Sum of squares of weights.
Double_t fTsumwx2
Total Sum of weight*X*X.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
@ kIsNotW
Histogram is forced to be not weighted even when the histogram is filled with weighted.
virtual Bool_t CanExtendAllAxes() const
Returns true if all axes are extendable.
virtual Int_t GetNbinsX() const
Int_t fBufferSize
fBuffer size
TString ProvideSaveName(Option_t *option, Bool_t testfdir=kFALSE)
Provide variable name for histogram for saving as primitive Histogram pointer has by default the hist...
static Int_t fgBufferSize
! Default buffer size for automatic histograms
virtual void SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option="")
Helper function for the SavePrimitive functions from TH1 or classes derived from TH1,...
@ kNstat
Size of statistics data (up to TProfile3D).
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=nullptr) const
test for comparing weighted and unweighted histograms.
Double_t fEntries
Number of entries.
TAxis fZaxis
Z axis descriptor.
virtual TArrayD * GetSumw2()
TAxis fXaxis
X axis descriptor.
TArrayD fSumw2
Array of sum of squares of weights.
Bool_t GetStatOverflowsBehaviour() const
TAxis fYaxis
Y axis descriptor.
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
virtual void SetEntries(Double_t n)
Double_t fTsumwx
Total Sum of weight*X.
2-D histogram with a double per channel (see TH1 documentation)
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
void Copy(TObject &hnew) const override
Copy this 3-D histogram structure to newth3.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Double_t fTsumwy
Total Sum of weight*Y.
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Double_t fTsumwxz
Total Sum of weight*X*Z.
virtual TProfile2D * Project3DProfile(Option_t *option="xy") const
Project a 3-d histogram into a 2-d profile histograms depending on the option parameter option may co...
Double_t fTsumwz2
Total Sum of weight*Z*Z.
Double_t fTsumwxy
Total Sum of weight*X*Y.
virtual TH2D * DoProject2D(const char *name, const char *title, const TAxis *projX, const TAxis *projY, bool computeErrors, bool originalRange, bool useUF, bool useOF, bool useWidth) const
internal method performing the projection to a 2D histogram called from TH3::Project3D
Double_t fTsumwz
Total Sum of weight*Z.
Double_t fTsumwyz
Total Sum of weight*Y*Z.
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz) const override
See comments in TH1::GetBin.
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
virtual Int_t FindGoodLimitsXYZ(TH1 *h, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t newbinsx=0, Int_t newbinsy=0, Int_t newbinsz=0)
Compute the best axis limits and bins for the X, Y and Z axis if the corresponding newbins variable i...
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual TClass * IsA() const
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
Profile2D histograms are used to display the mean value of Z and its error for each cell in X,...
virtual void SetBinEntries(Int_t bin, Double_t w)
void Sumw2(Bool_t flag=kTRUE) override
Create/Delete structure to store sum of squares of weights per bin.
virtual TArrayD * GetBinSumw2()
TProfile3D & operator=(const TProfile3D &profile)
Long64_t Merge(TCollection *list) override
Merge all histograms in the collection in this histogram.
static Bool_t fgApproximate
Bin error approximation option.
Option_t * GetErrorOption() const
Return option to compute profile2D errors.
Bool_t fScaling
! True when TProfile3D::Scale is called
void SetBins(const Int_t *nbins, const Double_t *range)
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.
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
void SetBuffer(Int_t bufsize, Option_t *opt="") override
Set the buffer size in units of 8 bytes (double).
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.
Double_t fTsumwt2
Total Sum of weight*T*T.
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.
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.
TArrayD fBinEntries
Number of entries per bin.
void LabelsDeflate(Option_t *axis="X") override
Reduce the number of bins for this axis to the number of bins having a label.
~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).
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.
void BuildOptions(Double_t tmin, Double_t tmax, Option_t *option)
Set Profile3D histogram structure and options.
Int_t Fill(const Double_t *v)
TArrayD fBinSumw2
Array of sum of squares of weights per bin.
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 void SetErrorOption(Option_t *option="")
Set option to compute profile3D errors.
virtual TH3D * ProjectionXYZ(const char *name="_pxyz", Option_t *option="e") const
Project this profile3D into a 3-D histogram along X,Y,Z.
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.
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.
Bool_t Divide(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this/(c1*f1) .
Double_t fTsumwt
Total Sum of weight*T.
static void Approximate(Bool_t approx=kTRUE)
Set the fgApproximate flag.
Double_t fTmax
Upper limit in T (if set).
Double_t GetBinError(Int_t bin) const override
Return bin error of a Profile3D histogram.
static void LabelsInflate(T *p, Option_t *)
static Double_t GetBinError(T *p, Int_t bin)
static T * ExtendAxis(T *p, Double_t x, TAxis *axis)
static void Sumw2(T *p, Bool_t flag)
static void SetBinEntries(T *p, Int_t bin, Double_t w)
static void Scale(T *p, Double_t c1, Option_t *option)
static void SetErrorOption(T *p, Option_t *opt)
static Long64_t Merge(T *p, TCollection *list)
static void BuildArray(T *p)
static Bool_t Add(T *p, const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2=1)
static Double_t GetBinEffectiveEntries(T *p, Int_t bin)
static void LabelsDeflate(T *p, Option_t *)
void ToLower()
Change string to lower-case.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
TString & ReplaceAll(const TString &s1, const TString &s2)
void ToUpper()
Change string to upper case.
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.