245 profile.TProfile::Copy(*
this);
250 if (
this != &profile)
251 profile.TProfile::Copy(*
this);
260 Error(
"Add",
"Function not implemented for TProfile");
271 Error(
"Add",
"Attempt to add a non-existing profile");
275 Error(
"Add",
"Attempt to add a non-profile object");
293 Error(
"Add",
"Attempt to add a non-existing profile");
297 Error(
"Add",
"Attempt to add a non-profile object");
301 Error(
"Add",
"Attempt to add a non-profile object");
305 if (
c1 < 0 ||
c2 < 0)
342 if (!nbentries)
return 0;
345 if (action == 0)
return 0;
346 nbentries = -nbentries;
355 for (
Int_t i=1;i<nbentries;i++) {
374 for (
Int_t i=0;i<nbentries;i++) {
375 Fill(buffer[3*i+2],buffer[3*i+3],buffer[3*i+1]);
400 nbentries = -nbentries;
429 if (
auto other =
dynamic_cast<const TProfile *
>(h2); other) {
431 Error(
"Chi2Test",
"Chi2 tests need TProfiles in 'error of mean' mode.");
439 Error(
"Chi2Test",
"TProfiles need to be tested with the 'W' option. Either use option 'WW' or use "
440 "histogram.Chi2Test(<profile>, 'UW')");
457 for (
int bin=0;bin<
fNcells;bin++) {
482 Error(
"Divide",
"Function not implemented for TProfile");
498 Error(
"Divide",
"Attempt to divide a non-existing profile");
502 Error(
"Divide",
"Attempt to divide by a non-profile or non-histogram object");
514 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
523 Double_t *cu1=
nullptr, *er1=
nullptr, *en1=
nullptr;
531 for (bin=0;bin<=nbinsx+1;bin++) {
533 if (cu1)
c1 = cu1[bin];
534 else c1 =
h1->GetBinContent(bin);
548 if (er1) e1 = er1[bin];
549 else {e1 =
h1->GetBinError(bin); e1*=e1;}
552 else fSumw2.fArray[bin] = (e0*
c1*
c1 + e1*c0*c0)/(c12*c12);
560 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
581 Error(
"Divide",
"Attempt to divide a non-existing profile");
585 Error(
"Divide",
"Attempt to divide a non-profile object");
590 Error(
"Divide",
"Attempt to divide by a non-profile object");
601 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
605 Error(
"Divide",
"Coefficient of dividing profile cannot be zero");
610 printf(
"WARNING!!: The algorithm in TProfile::Divide computing the errors is not accurate\n");
611 printf(
" Instead of Divide(TProfile *h1, TProfile *h2), do:\n");
612 printf(
" TH1D *p1 = h1->ProjectionX();\n");
613 printf(
" TH1D *p2 = h2->ProjectionX();\n");
614 printf(
" p1->Divide(p2);\n");
632 for (bin=0;bin<=nbinsx+1;bin++) {
635 if (b2) w =
c1*b1/(
c2*b2);
651 if (!b2)
fSumw2.fArray[bin] = 0;
657 fSumw2.fArray[bin] = ac1*ac2*(e1*b2*b2 + e2*b1*b1)/(b22*b22);
660 if (en2[bin])
fBinEntries.fArray[bin] = en1[bin]/en2[bin];
667 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
692 if (bin == 0 || bin >
fXaxis.GetNbins()) {
715 bin =
fXaxis.FindBin(namex);
720 if (bin == 0 || bin >
fXaxis.GetNbins()) {
754 if (bin == 0 || bin >
fXaxis.GetNbins()) {
779 bin =
fXaxis.FindBin(namex);
785 if (bin == 0 || bin >
fXaxis.GetNbins()) {
811 for (i=0;i<ntimes;i+=stride) {
817 if (i < ntimes &&
fBuffer==
nullptr)
823 for (i=ifirst;i<ntimes;i+=stride) {
836 if (bin == 0 || bin >
fXaxis.GetNbins()) {
855 if (bin < 0 || bin >=
fNcells)
return 0;
868 if (bin < 0 || bin >=
fNcells)
return 0;
959 for (bin=0;bin<6;bin++) stats[bin] = 0;
965 if (firstBinX == 1) firstBinX = 0;
966 if (lastBinX ==
fXaxis.GetNbins() ) lastBinX += 1;
968 for (binx = firstBinX; binx <= lastBinX; binx++) {
977 stats[5] +=
fSumw2.fArray[binx];
983 for (binx=
fXaxis.GetFirst();binx<=
fXaxis.GetLast();binx++) {
1032 Warning(
"LabelsOption",
"Cannot sort. No labels");
1065 if (sort < 0)
return;
1068 Int_t n = labels->GetSize();
1074 Int_t lastLabelBin = -1;
1075 for (
Int_t i = 0; i <
n; ++i) {
1076 Int_t bin = labels->At(i)->GetUniqueID();
1077 if (bin < firstLabelBin)
1078 firstLabelBin = bin;
1079 if (bin > lastLabelBin)
1082 if (firstLabelBin != 1 || lastLabelBin - firstLabelBin + 1 !=
n) {
1083 Error(
"LabelsOption",
1084 "%s of TProfile %s contains bins without labels. Sorting will not work correctly - return",
1091 "axis %s of TProfile %s has extra following bins without labels. Sorting will work only for first label bins",
1094 std::vector<Int_t>
a(
n);
1096 std::vector<Double_t> cont(
n);
1097 std::vector<Double_t> sumw(
n);
1098 std::vector<Double_t> errors(
n);
1099 std::vector<Double_t> ent(
n);
1100 std::vector<Double_t> binsw2;
1109 std::vector<TObject *> labold(
n);
1110 for (i = 0; i <
n; i++)
1111 labold[i] =
nullptr;
1112 TIter nextold(labels);
1114 while ((obj=nextold())) {
1117 labold[bin - 1] = obj;
1124 for (i=1;i<=
n;i++) {
1127 errors[i-1] =
fSumw2.fArray[i];
1137 for (i=1;i<=
n;i++) {
1139 fSumw2.fArray[i] = errors[
a[i-1]];
1144 for (i=0 ;i <
n; i++) {
1154 std::vector<std::string> vecLabels(
n);
1155 for (i = 0; i <
n; i++) {
1156 vecLabels[i] = labold[i]->GetName();
1159 errors[i] =
fSumw2.fArray[i+1];
1167 for (i = 0; i <
n; i++) {
1169 labels->Add(labelObj);
1173 std::cout <<
"bin " << i + 1 <<
" setting new labels for axis " << labold.at(
a[i])->GetName() <<
" from "
1174 <<
a[i] << std::endl;
1177 for (i=0; i <
n; i++) {
1179 fSumw2.fArray[i+1] = errors[
a[i]];
1187 bool labelsAreSorted =
kFALSE;
1188 for (i = 0; i <
n; ++i) {
1190 labelsAreSorted =
kTRUE;
1194 if (labelsAreSorted) {
1233 Error(
"Multiply",
"Attempt to multiply by a null function");
1243 for (i=0;i<10;i++) {
s1[i] = 0;}
1251 for (bin=0;bin<=nbinsx+1;bin++) {
1252 xx[0] =
fXaxis.GetBinCenter(bin);
1253 if (!
f1->IsInside(xx))
continue;
1255 cf1 =
f1->EvalPar(xx);
1260 fSumw2.fArray[bin] *= ac1*cf1*cf1;
1273 Error(
"Multiply",
"Multiplication of profile histograms not implemented");
1285 Error(
"Multiply",
"Multiplication of profile histograms not implemented");
1320 if (pname ==
"_px") {
1326 if (bins->
fN == 0) {
1339 if (computeErrors || binWeight || (binEntries &&
fBinSumw2.fN) )
h1->Sumw2();
1343 for (
Int_t bin =0;bin<=nx+1;bin++) {
1347 else if (binWeight) cont =
fArray[bin];
1350 h1->SetBinContent(bin ,cont);
1353 if (computeErrors )
h1->SetBinError(bin ,
GetBinError(bin) );
1356 if (binWeight)
h1->GetSumw2()->fArray[bin] =
fSumw2.fArray[bin];
1360 h1->GetSumw2()->fArray[bin] =
fBinSumw2.fArray[bin];
1366 h1->GetXaxis()->ImportAttributes(this->
GetXaxis());
1443 if ((ngroup <= 0) || (ngroup > nbins)) {
1444 Error(
"Rebin",
"Illegal value of ngroup=%d",ngroup);
1447 if (!newname && xbins) {
1448 Error(
"Rebin",
"if xbins is specified, newname must be given");
1452 Int_t newbins = nbins/ngroup;
1454 Int_t nbg = nbins/ngroup;
1455 if (nbg*ngroup != nbins) {
1456 Warning(
"Rebin",
"ngroup=%d must be an exact divider of nbins=%d",ngroup,nbins);
1479 for (bin=0;bin<=nbins+1;bin++) {
1480 oldBins[bin] = cu1[bin];
1481 oldCount[bin] = en1[bin];
1482 oldErrors[bin] = er1[bin];
1483 if (ew1 &&
fBinSumw2.fN) oldBinw2[bin] = ew1[bin];
1488 if ((newname && strlen(newname) > 0) || xbins) {
1494 if(!xbins && (newbins*ngroup != nbins)) {
1500 if(!xbins && (
fXaxis.GetXbins()->GetSize() > 0)){
1503 for(i = 0; i <= newbins; ++i) bins[i] =
fXaxis.GetBinLowEdge(1+i*ngroup);
1519 while(
fXaxis.GetBinCenter(startbin) < newxmin && startbin <= nbins ) {
1527 Int_t oldbin = startbin;
1528 Double_t binContent, binCount, binError, binSumw2;
1529 for (bin = 1;bin<=newbins;bin++) {
1536 Int_t imax = ngroup;
1538 for (i=0;i<ngroup;i++) {
1539 if((hnew ==
this && (oldbin+i > nbins)) ||
1540 (hnew !=
this && (
fXaxis.GetBinCenter(oldbin+i) > xbinmax)))
1546 binContent += oldBins[oldbin+i];
1547 binCount += oldCount[oldbin+i];
1548 binError += oldErrors[oldbin+i];
1549 if (
fBinSumw2.fN) binSumw2 += oldBinw2[oldbin+i];
1552 cu2[bin] = binContent;
1553 er2[bin] = binError;
1554 en2[bin] = binCount;
1563 for(i=0;i<startbin;i++)
1565 binContent += oldBins[i];
1566 binCount += oldCount[i];
1567 binError += oldErrors[i];
1568 if (
fBinSumw2.fN) binSumw2 += oldBinw2[i];
1570 hnew->
fArray[0] = binContent;
1572 hnew->
fSumw2[0] = binError;
1580 for(i=oldbin;i<=nbins+1;i++)
1582 binContent += oldBins[i];
1583 binCount += oldCount[i];
1584 binError += oldErrors[i];
1585 if (
fBinSumw2.fN) binSumw2 += oldBinw2[i];
1587 hnew->
fArray[newbins+1] = binContent;
1589 hnew->
fSumw2[newbins+1] = binError;
1595 delete [] oldErrors;
1596 if (oldBinw2)
delete [] oldBinw2;
1658 out << sxaxis <<
".data()";
1664 Int_t numentries = 0, numcontent = 0, numerrors = 0;
1671 content[bin] =
fArray[bin];
1681 if ((numentries < 100) && (numcontent < 100) && (numerrors < 100)) {
1685 out <<
" " << hname <<
"->SetBinEntries(" << bin <<
"," << entries[bin] <<
");\n";
1689 out <<
" " << hname <<
"->SetBinContent(" << bin <<
"," << content[bin] <<
");\n";
1694 out <<
" " << hname <<
"->SetBinError(" << bin <<
"," << errors[bin] <<
");\n";
1697 if (numentries > 0) {
1699 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1700 out <<
" if (" << vect <<
"[bin])\n";
1701 out <<
" " << hname <<
"->SetBinEntries(bin, " << vect <<
"[bin]);\n";
1703 if (numcontent > 0) {
1705 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1706 out <<
" if (" << vect <<
"[bin])\n";
1707 out <<
" " << hname <<
"->SetBinContent(bin, " << vect <<
"[bin]);\n";
1709 if (numerrors > 0) {
1711 out <<
" for (Int_t bin = 0; bin < " <<
fNcells <<
"; bin++)\n";
1712 out <<
" if (" << vect <<
"[bin])\n";
1713 out <<
" " << hname <<
"->SetBinError(bin, " << vect <<
"[bin]);\n";
1784 if (bufsize < 100) bufsize = 100;
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned 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.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
TArrayD()
Default TArrayD ctor.
Class to manage histogram axis.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void ImportAttributes(const TAxis *axis)
Copy axis attributes to this.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
THashList * GetLabels() const
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Collection abstract base class.
static void RejectPoint(Bool_t reject=kTRUE)
static Bool_t RejectedPoint()
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 to newth1.
void Streamer(TBuffer &) override
Stream a class object.
void AddBinContent(Int_t bin) override
Increment bin content by 1.
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.
@ 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
virtual void SetMaximum(Double_t maximum=-1111)
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 SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option="")
Helper function for the SavePrimitive functions from TH1 or classes derived from TH1,...
virtual void SetMinimum(Double_t minimum=-1111)
virtual void ResetStats()
Reset the statistics including the number of entries and replace with values calculated from bin cont...
@ 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 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.
Double_t fTsumwx
Total Sum of weight*X.
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
virtual Int_t FindGoodLimits(TH1 *h, Double_t xmin, Double_t xmax)
Compute the best axis limits for the X axis.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Collectable string class.
Mother of all ROOT objects.
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.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
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.
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 *)
Double_t GetBinContent(Int_t bin) const override
Return bin content of a Profile histogram.
virtual Double_t GetBinEffectiveEntries(Int_t bin) const
Return bin effective entries for a weighted filled Profile histogram.
Bool_t Divide(TF1 *h1, Double_t c1=1) override
Performs the operation: this = this/(c1*f1).
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
void ExtendAxis(Double_t x, TAxis *axis) override
Profile histogram is resized along x axis such that x is in the axis range.
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.
EErrorType fErrorMode
Option to compute errors.
Long64_t Merge(TCollection *list) override
Merge all histograms in the collection in this histogram.
void Copy(TObject &hnew) const override
Copy a Profile histogram to a new profile histogram.
Double_t fYmax
Upper limit in Y (if set).
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.
void LabelsDeflate(Option_t *axis="X") override
Reduce the number of bins for this axis to the number of bins having a label.
void Streamer(TBuffer &) override
Stream an object of class TProfile.
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.
void SetBuffer(Int_t bufsize, Option_t *option="") override
Set the buffer size in units of 8 bytes (double).
TProfile()
Default constructor for Profile histograms.
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
Double_t Chi2Test(const TH1 *h2, Option_t *option="WW", Double_t *res=nullptr) const override
Run a Chi2Test between a TProfileD and another histogram.
void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override
Fill this histogram with an array x and weights w.
TProfile & operator=(const TProfile &profile)
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.
Double_t fTsumwy2
Total Sum of weight*Y*Y.
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.
Double_t GetBinError(Int_t bin) const override
Return bin error of a Profile histogram.
Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override
Performs the operation: this = this + c1*f1.
Int_t Fill(const Double_t *v)
Double_t fTsumwy
Total Sum of weight*Y.
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
~TProfile() override
Default destructor for Profile histograms.
void SetBins(const Int_t *nbins, const Double_t *range)
Double_t fYmin
Lower limit in Y (if set).
TArrayD fBinEntries
number of entries per bin
static void Approximate(Bool_t approx=kTRUE)
Static function to set the fgApproximate flag.
Bool_t fScaling
! True when TProfile::Scale is called
void GetStats(Double_t *stats) const override
fill the array stats from the contents of this profile.
TClass * IsA() const override
Option_t * GetErrorOption() const
Return option to compute profile errors.
void LabelsOption(Option_t *option="h", Option_t *axis="X") override
Set option(s) to draw axis with labels.
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...
const char * Data() const
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.
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.