246 profile.TProfile::Copy(*
this);
251 if (
this != &profile)
252 profile.TProfile::Copy(*
this);
261 Error(
"Add",
"Function not implemented for TProfile");
272 Error(
"Add",
"Attempt to add a non-existing profile");
276 Error(
"Add",
"Attempt to add a non-profile object");
294 Error(
"Add",
"Attempt to add a non-existing profile");
298 Error(
"Add",
"Attempt to add a non-profile object");
302 Error(
"Add",
"Attempt to add a non-profile object");
306 if (
c1 < 0 ||
c2 < 0)
343 if (!nbentries)
return 0;
346 if (action == 0)
return 0;
347 nbentries = -nbentries;
376 Fill(buffer[3*
i+2],buffer[3*
i+3],buffer[3*
i+1]);
401 nbentries = -nbentries;
430 for (
int bin=0;bin<
fNcells;bin++) {
455 Error(
"Divide",
"Function not implemented for TProfile");
471 Error(
"Divide",
"Attempt to divide a non-existing profile");
475 Error(
"Divide",
"Attempt to divide by a non-profile or non-histogram object");
487 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
496 Double_t *cu1=
nullptr, *er1=
nullptr, *en1=
nullptr;
504 for (bin=0;bin<=nbinsx+1;bin++) {
506 if (cu1)
c1 = cu1[bin];
507 else c1 =
h1->GetBinContent(bin);
521 if (er1) e1 = er1[bin];
522 else {e1 =
h1->GetBinError(bin); e1*=e1;}
525 else fSumw2.fArray[bin] = (e0*
c1*
c1 + e1*c0*c0)/(c12*c12);
533 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
554 Error(
"Divide",
"Attempt to divide a non-existing profile");
558 Error(
"Divide",
"Attempt to divide a non-profile object");
563 Error(
"Divide",
"Attempt to divide by a non-profile object");
574 Error(
"Divide",
"Attempt to divide profiles with different number of bins");
578 Error(
"Divide",
"Coefficient of dividing profile cannot be zero");
583 printf(
"WARNING!!: The algorithm in TProfile::Divide computing the errors is not accurate\n");
584 printf(
" Instead of Divide(TProfile *h1, TProfile *h2), do:\n");
585 printf(
" TH1D *p1 = h1->ProjectionX();\n");
586 printf(
" TH1D *p2 = h2->ProjectionX();\n");
587 printf(
" p1->Divide(p2);\n");
605 for (bin=0;bin<=nbinsx+1;bin++) {
608 if (b2)
w =
c1*b1/(
c2*b2);
624 if (!b2)
fSumw2.fArray[bin] = 0;
630 fSumw2.fArray[bin] = ac1*ac2*(e1*b2*b2 + e2*b1*b1)/(b22*b22);
633 if (en2[bin])
fBinEntries.fArray[bin] = en1[bin]/en2[bin];
640 Warning(
"Divide",
"Cannot preserve during the division of profiles the sum of bin weight square");
665 if (bin == 0 || bin >
fXaxis.GetNbins()) {
688 bin =
fXaxis.FindBin(namex);
693 if (bin == 0 || bin >
fXaxis.GetNbins()) {
727 if (bin == 0 || bin >
fXaxis.GetNbins()) {
752 bin =
fXaxis.FindBin(namex);
758 if (bin == 0 || bin >
fXaxis.GetNbins()) {
784 for (
i=0;
i<ntimes;
i+=stride) {
796 for (
i=ifirst;
i<ntimes;
i+=stride) {
809 if (bin == 0 || bin >
fXaxis.GetNbins()) {
828 if (bin < 0 || bin >=
fNcells)
return 0;
841 if (bin < 0 || bin >=
fNcells)
return 0;
932 for (bin=0;bin<6;bin++) stats[bin] = 0;
938 if (firstBinX == 1) firstBinX = 0;
939 if (lastBinX ==
fXaxis.GetNbins() ) lastBinX += 1;
941 for (binx = firstBinX; binx <= lastBinX; binx++) {
950 stats[5] +=
fSumw2.fArray[binx];
956 for (binx=
fXaxis.GetFirst();binx<=
fXaxis.GetLast();binx++) {
1005 Warning(
"LabelsOption",
"Cannot sort. No labels");
1038 if (sort < 0)
return;
1047 Int_t lastLabelBin = -1;
1050 if (bin < firstLabelBin)
1051 firstLabelBin = bin;
1052 if (bin > lastLabelBin)
1055 if (firstLabelBin != 1 || lastLabelBin - firstLabelBin + 1 !=
n) {
1056 Error(
"LabelsOption",
1057 "%s of TProfile %s contains bins without labels. Sorting will not work correctly - return",
1064 "axis %s of TProfile %s has extra following bins without labels. Sorting will work only for first label bins",
1067 std::vector<Int_t>
a(
n);
1069 std::vector<Double_t> cont(
n);
1070 std::vector<Double_t> sumw(
n);
1071 std::vector<Double_t> errors(
n);
1072 std::vector<Double_t> ent(
n);
1073 std::vector<Double_t> binsw2;
1082 std::vector<TObject *> labold(
n);
1083 for (
i = 0;
i <
n;
i++)
1084 labold[
i] =
nullptr;
1085 TIter nextold(labels);
1087 while ((obj=nextold())) {
1090 labold[bin - 1] = obj;
1097 for (
i=1;
i<=
n;
i++) {
1110 for (
i=1;
i<=
n;
i++) {
1117 for (
i=0 ;
i <
n;
i++) {
1127 std::vector<std::string> vecLabels(
n);
1128 for (
i = 0;
i <
n;
i++) {
1129 vecLabels[
i] = labold[
i]->GetName();
1140 for (
i = 0;
i <
n;
i++) {
1142 labels->
Add(labelObj);
1146 std::cout <<
"bin " <<
i + 1 <<
" setting new labels for axis " << labold.at(
a[
i])->GetName() <<
" from "
1147 <<
a[
i] << std::endl;
1150 for (
i=0;
i <
n;
i++) {
1160 bool labelsAreSorted =
kFALSE;
1161 for (
i = 0;
i <
n; ++
i) {
1163 labelsAreSorted =
kTRUE;
1167 if (labelsAreSorted) {
1206 Error(
"Multiply",
"Attempt to multiply by a null function");
1216 for (
i=0;
i<10;
i++) {
s1[
i] = 0;}
1224 for (bin=0;bin<=nbinsx+1;bin++) {
1225 xx[0] =
fXaxis.GetBinCenter(bin);
1226 if (!
f1->IsInside(xx))
continue;
1228 cf1 =
f1->EvalPar(xx);
1233 fSumw2.fArray[bin] *= ac1*cf1*cf1;
1246 Error(
"Multiply",
"Multiplication of profile histograms not implemented");
1258 Error(
"Multiply",
"Multiplication of profile histograms not implemented");
1292 if (pname ==
"_px") {
1298 if (bins->
fN == 0) {
1311 if (computeErrors || binWeight || (binEntries &&
fBinSumw2.fN) )
h1->Sumw2();
1315 for (
Int_t bin =0;bin<=nx+1;bin++) {
1319 else if (binWeight) cont =
fArray[bin];
1322 h1->SetBinContent(bin ,cont);
1325 if (computeErrors )
h1->SetBinError(bin ,
GetBinError(bin) );
1328 if (binWeight)
h1->GetSumw2()->fArray[bin] =
fSumw2.fArray[bin];
1332 h1->GetSumw2()->fArray[bin] =
fBinSumw2.fArray[bin];
1338 h1->GetXaxis()->ImportAttributes(this->
GetXaxis());
1415 if ((ngroup <= 0) || (ngroup > nbins)) {
1416 Error(
"Rebin",
"Illegal value of ngroup=%d",ngroup);
1419 if (!newname && xbins) {
1420 Error(
"Rebin",
"if xbins is specified, newname must be given");
1424 Int_t newbins = nbins/ngroup;
1426 Int_t nbg = nbins/ngroup;
1427 if (nbg*ngroup != nbins) {
1428 Warning(
"Rebin",
"ngroup=%d must be an exact divider of nbins=%d",ngroup,nbins);
1451 for (bin=0;bin<=nbins+1;bin++) {
1452 oldBins[bin] = cu1[bin];
1453 oldCount[bin] = en1[bin];
1454 oldErrors[bin] = er1[bin];
1455 if (ew1 &&
fBinSumw2.fN) oldBinw2[bin] = ew1[bin];
1460 if ((newname && strlen(newname) > 0) || xbins) {
1466 if(!xbins && (newbins*ngroup != nbins)) {
1472 if(!xbins && (
fXaxis.GetXbins()->GetSize() > 0)){
1475 for(
i = 0;
i <= newbins; ++
i) bins[
i] =
fXaxis.GetBinLowEdge(1+
i*ngroup);
1491 while(
fXaxis.GetBinCenter(startbin) < newxmin && startbin <= nbins ) {
1499 Int_t oldbin = startbin;
1500 Double_t binContent, binCount, binError, binSumw2;
1501 for (bin = 1;bin<=newbins;bin++) {
1508 Int_t imax = ngroup;
1510 for (
i=0;
i<ngroup;
i++) {
1511 if((hnew ==
this && (oldbin+
i > nbins)) ||
1512 (hnew !=
this && (
fXaxis.GetBinCenter(oldbin+
i) > xbinmax)))
1518 binContent += oldBins[oldbin+
i];
1519 binCount += oldCount[oldbin+
i];
1520 binError += oldErrors[oldbin+
i];
1521 if (
fBinSumw2.fN) binSumw2 += oldBinw2[oldbin+
i];
1524 cu2[bin] = binContent;
1525 er2[bin] = binError;
1526 en2[bin] = binCount;
1535 for(
i=0;
i<startbin;
i++)
1537 binContent += oldBins[
i];
1538 binCount += oldCount[
i];
1539 binError += oldErrors[
i];
1542 hnew->
fArray[0] = binContent;
1544 hnew->
fSumw2[0] = binError;
1552 for(
i=oldbin;
i<=nbins+1;
i++)
1554 binContent += oldBins[
i];
1555 binCount += oldCount[
i];
1556 binError += oldErrors[
i];
1559 hnew->
fArray[newbins+1] = binContent;
1561 hnew->
fSumw2[newbins+1] = binError;
1567 delete [] oldErrors;
1568 if (oldBinw2)
delete [] oldBinw2;
1627 if (
i != 0) out <<
", ";
1630 out <<
"}; " << std::endl;
1634 out<<
" "<<std::endl;
1639 static Int_t hcounter = 0;
1644 histName += hcounter;
1646 const char *hname = histName.
Data();
1648 out << hname <<
" = new " <<
ClassName() <<
"(" << quote << hname << quote <<
"," << quote <<
GetTitle() << quote
1659 for (bin=0;bin<
fNcells;bin++) {
1662 out<<
" "<<hname<<
"->SetBinEntries("<<bin<<
","<<bi<<
");"<<std::endl;
1666 for (bin=0;bin<
fNcells;bin++) {
1669 out<<
" "<<hname<<
"->SetBinContent("<<bin<<
","<<bc<<
");"<<std::endl;
1674 for (bin=0;bin<
fNcells;bin++) {
1677 out<<
" "<<hname<<
"->SetBinError("<<bin<<
","<<be<<
");"<<std::endl;
1745 if (buffersize <= 0) {
1749 if (buffersize < 100) buffersize = 100;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
TArrayD()
Default TArrayD ctor.
Class to manage histogram axis.
const TArrayD * GetXbins() const
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.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static void RejectPoint(Bool_t reject=kTRUE)
Static function to set the global flag to reject points the fgRejectPoint global flag is tested by al...
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
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.
TDirectory * fDirectory
! Pointer to directory holding this histogram
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
Int_t fBufferSize
fBuffer size
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)
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...
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.
Collectable string class.
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.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
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 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.
TProfile()
Default constructor for Profile histograms.
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
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.
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.
const char * Data() const
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.