172TProfile2D::TProfile2D(
const char *
name,
const char *title,
Int_t nx,
Double_t xlow,
Double_t xup,
Int_t ny,
Double_t ylow,
Double_t yup,
Double_t zlow,
Double_t zup,
Option_t *
option)
226 Error(
"Add",
"Function not implemented for TProfile2D");
236 Error(
"Add",
"Attempt to add a non-existing profile");
240 Error(
"Add",
"Attempt to add a non-profile2D object");
255 Error(
"Add",
"Attempt to add a non-existing profile");
259 Error(
"Add",
"Attempt to add a non-profile2D object");
263 Error(
"Add",
"Attempt to add a non-profile2D object");
302 if (
action == 0)
return 0;
338 Fill(buffer[4*i+2],buffer[4*i+3],buffer[4*i+4],buffer[4*i+1]);
398 Error(
"Chi2Test",
"Chi2 tests need TProfiles in 'error of mean' mode.");
406 Error(
"Chi2Test",
"TProfiles need to be tested with the 'W' option. Either use option 'WW' or use "
407 "histogram.Chi2Test(<profile>, 'UW')");
437 Fatal(
"Copy",
"Cannot copy a TProfile2D in a %s",obj.
IsA()->GetName());
448 Error(
"Divide",
"Function not implemented for TProfile2D");
463 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
467 Error(
"Divide",
"Attempt to divide a non-profile2D object");
477 if (
nx !=
p1->GetNbinsX()) {
478 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
482 if (
ny !=
p1->GetNbinsY()) {
483 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
529 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
549 Error(
"Divide",
"Attempt to divide a non-existing profile2D");
553 Error(
"Divide",
"Attempt to divide a non-profile2D object");
558 Error(
"Divide",
"Attempt to divide a non-profile2D object");
568 if (
nx !=
p1->GetNbinsX() ||
nx !=
p2->GetNbinsX()) {
569 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
573 if (
ny !=
p1->GetNbinsY() ||
ny !=
p2->GetNbinsY()) {
574 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
578 Error(
"Divide",
"Coefficient of dividing profile cannot be zero");
601 if (b2)
w =
c1*b1/(
c2*b2);
693 if (
binx < 0 ||
biny < 0)
return -1;
1046 Warning(
"LabelsOption",
"Cannot sort. No labels");
1079 if (sort < 0)
return;
1088 for (
Int_t i = 0; i <
n; ++i) {
1096 Error(
"LabelsOption",
1097 "%s of TProfile2D %s contains bins without labels. Sorting will not work correctly - return",
1104 "axis %s of TProfile2D %s has extra following bins without labels. Sorting will work only for first label bins",
1108 std::vector<Int_t>
a(
n);
1113 std::vector<Double_t>
binsw2;
1127 std::vector<TObject *>
labold(
n);
1128 for (i = 0; i <
n; i++)
1141 std::vector<Double_t>
pcont;
1142 std::vector<Double_t>
econt;
1148 for (i = 0; i <
nx; i++) {
1149 for (
j = 0;
j <
ny;
j++) {
1169 for (k = 0; k <
n; ++k) {
1183 for (i = 0; i <
n; i++) {
1192 for (i = 0; i <
n; i++) {
1198 std::cout <<
"bin " << i + 1 <<
" setting new labels for axis " <<
labold.at(
a[i])->GetName() <<
" from "
1199 <<
a[i] << std::endl;
1202 for (i = 0; i <
nx; i++) {
1203 for (
j = 0;
j <
ny;
j++) {
1209 if (
j == 0)
continue;
1222 for (i = 0; i <
n; ++i) {
1268 Error(
"Multiply",
"Function not implemented for TProfile2D");
1279 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
1290 Error(
"Multiply",
"Multiplication of profile2D histograms not implemented");
1338 }
else if (
xbins->fN == 0) {
1340 }
else if (
ybins->fN == 0) {
1448 if (bins->
fN == 0) {
1469 h2dW->SetDirectory(
nullptr);
h2dN->SetDirectory(
nullptr);
1475 h1W->SetDirectory(
nullptr);
h1N->SetDirectory(
nullptr);
1482 for (
int i = 0; i <
p1->fN ; ++i) {
1483 p1->fArray[i] =
h1W->GetBinContent(i);
1484 p1->GetSumw2()->fArray[i] =
h1W->GetSumw2()->fArray[i];
1485 p1->SetBinEntries(i,
h1N->GetBinContent(i) );
1486 if (
fBinSumw2.
fN)
p1->GetBinSumw2()->fArray[i] =
h1N->GetSumw2()->fArray[i];
1496 p1->SetEntries(
p1->GetEffectiveEntries() );
1619 Error(
"Rebin2D",
"if xbins or ybins are specified, newname must be given");
1681 {{oldBins.data(), cu2}, {oldErrors.data(), er2}, {oldCount.data(), en2}, {oldBinw2.data(), ew2}});
1684 {{oldBins.data(), cu2}, {oldErrors.data(), er2}, {oldCount.data(), en2}});
1730 out <<
sxaxis <<
".data()";
1736 out <<
syaxis <<
".data()";
1781 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1782 out <<
" if (" <<
vect <<
"[bin])\n";
1783 out <<
" " <<
hname <<
"->SetBinEntries(bin, " <<
vect <<
"[bin]);\n";
1787 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1788 out <<
" if (" <<
vect <<
"[bin])\n";
1789 out <<
" " <<
hname <<
"->SetBinContent(bin, " <<
vect <<
"[bin]);\n";
1793 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1794 out <<
" if (" <<
vect <<
"[bin])\n";
1795 out <<
" " <<
hname <<
"->SetBinError(bin, " <<
vect <<
"[bin]);\n";
1903 if (
R__b.IsReading()) {
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
short Version_t
Class version identifier (short)
float Float_t
Float 4 bytes (float)
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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.
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Array of doubles (64 bits per element).
void Streamer(TBuffer &) override
Stream a TArrayD object.
void Copy(TArrayD &array) const
void Set(Int_t n) override
Set size of this array to n doubles.
TArrayD()
Default TArrayD ctor.
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
const TArrayD * GetXbins() const
void Copy(TObject &axis) const override
Copy axis structure to another axis.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Int_t GetLast() const
Return last bin on the axis i.e.
Int_t GetFirst() const
Return first bin on the axis i.e.
THashList * GetLabels() const
Buffer base class used for serializing objects.
Collection abstract base class.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-D histogram with a double per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
Double_t * fBuffer
[fBufferSize] entry buffer
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
@ 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...
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
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,...
UInt_t GetAxisLabelStatus() const
Internal function used in TH1::Fill to see which axis is full alphanumeric, i.e.
@ kNstat
Size of statistics data (up to TProfile3D)
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
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.
virtual TArrayD * GetSumw2()
TAxis fXaxis
X axis descriptor.
TArrayD fSumw2
Array of sum of squares of weights.
Bool_t GetStatOverflowsBehaviour() const
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
TAxis fYaxis
Y axis descriptor.
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
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 Streamer(TBuffer &) override
Stream an object of class TH2D.
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.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Double_t fTsumwxy
Total Sum of weight*X*Y.
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const override
Return Global bin number corresponding to binx,y,z.
Double_t fTsumwy
Total Sum of weight*Y.
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
void Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual UInt_t GetUniqueID() const
Return the unique object id.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
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,...
Long64_t Merge(TCollection *list) override
Merge all histograms in the collection in this histogram.
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
Double_t fTsumwz
Total Sum of weight*Z.
Int_t Fill(const Double_t *v)
TClass * IsA() const override
TH2D * ProjectionXY(const char *name="_pxy", Option_t *option="e") const
Project this profile2D into a 2-D histogram along X,Y.
Bool_t Multiply(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this*c1*f1.
void LabelsDeflate(Option_t *axis="X") override
Reduce the number of bins for this axis to the number of bins having a label.
Double_t GetBinError(Int_t bin) const override
Return bin error of a Profile2D histogram.
static void Approximate(Bool_t approx=kTRUE)
Static function, set the fgApproximate flag.
EErrorType fErrorMode
Option to compute errors.
Double_t fZmin
Lower limit in Z (if set)
TProfile2D * RebinX(Int_t ngroup=2, const char *newname="") override
Rebin only the X axis.
void SetBuffer(Int_t bufsize, Option_t *option="") override
Set the buffer size in units of 8 bytes (double).
Bool_t fScaling
! True when TProfile2D::Scale is called
virtual Double_t GetBinEffectiveEntries(Int_t bin)
Return bin effective entries for a weighted filled Profile histogram.
Option_t * GetErrorOption() const
Return option to compute profile2D errors.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TArrayD fBinSumw2
Array of sum of squares of weights per bin.
TProfile2D * Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="", const Double_t *xbins=nullptr, const Double_t *ybins=nullptr) override
Rebin this histogram grouping nxgroup/nygroup bins along the xaxis/yaxis together.
void ExtendAxis(Double_t x, TAxis *axis) override
Profile histogram is resized along axis such that x is in the axis range.
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.
TProfile2D * RebinY(Int_t ngroup=2, const char *newname="") override
Rebin only the Y axis.
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this profile2D by a constant c1.
virtual void SetBinEntries(Int_t bin, Double_t w)
Set the number of entries in bin.
void Copy(TObject &hnew) const override
Copy a Profile2D histogram to a new profile2D histogram.
TProfile * DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const override
Implementation of ProfileX or ProfileY for a TProfile2D.
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.
void LabelsOption(Option_t *option="h", Option_t *axis="X") override
Set option(s) to draw axis with labels.
TProfile2D()
Default constructor for Profile2D histograms.
void Sumw2(Bool_t flag=kTRUE) override
Create/Delete structure to store sum of squares of weights per bin.
TArrayD fBinEntries
Number of entries per bin.
void SetBins(const Int_t *nbins, const Double_t *range)
~TProfile2D() override
Default destructor for Profile2D histograms.
void Streamer(TBuffer &) override
Stream an object of class TProfile2D.
static Bool_t fgApproximate
Bin error approximation option.
Bool_t Divide(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this/(c1*f1) .
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
void LabelsInflate(Option_t *axis="X") override
Double the number of bins for axis.
void GetStats(Double_t *stats) const override
Fill the array stats from the contents of this profile.
virtual Double_t GetBinEntries(Int_t bin) const
Return bin entries of a Profile2D histogram.
Double_t fZmax
Upper limit in Z (if set)
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow.
void BuildOptions(Double_t zmin, Double_t zmax, Option_t *option)
Set Profile2D histogram structure and options.
Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override
Performs the operation: this = this + c1*f1 .
TProfile2D & operator=(const TProfile2D &profile)
Double_t fTsumwz2
Total Sum of weight*Z*Z.
Double_t Chi2Test(const TH1 *h2, Option_t *option="WW", Double_t *res=nullptr) const override
Run a Chi2Test between a TProfile2D and another histogram.
virtual void SetErrorOption(Option_t *option="")
Set option to compute profile2D errors.
Double_t GetBinContent(Int_t bin) const override
Return bin content of a Profile2D 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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void WarnAboutUnusedFlowContent(const TAxis &oldAxis, const RebinnedAxisInfo &info, const Double_t *userBins, char axisName, const Double_t *bins, Int_t stride, Int_t nOther, Int_t otherStride, TH1 &hist, const char *where)
Warn when the range of the new axis extends beyond the old one while the corresponding flow bins hold...
void SetRebinnedBins2D(TH1 &hnew, const TAxis &newXaxis, const TAxis &newYaxis)
Apply the axes of the rebinned histogram, using explicit bin edges if any of the two axes has non-uni...
void MergeRebinnedCells(Int_t nOldX, Int_t nOldY, Int_t nNewX, const std::vector< Int_t > &mapX, const std::vector< Int_t > &mapY, std::initializer_list< std::pair< const Double_t *, Double_t * > > arrays)
Accumulate every old cell (including under- and overflow) into the new cell given by the per-axis bin...
bool SetupRebinnedAxis(const TAxis &oldAxis, Int_t ngroup, const Double_t *userBins, char axisName, TH1 &hist, const char *where, RebinnedAxisInfo &info)
Validate the rebinning parameters for one axis and fill the definition of the rebinned axis and the m...
Double_t Sqrt(Double_t x)
Returns the square root of x.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
The definition of one axis of the rebinned histogram.