16#define PRINTRANGE(a, b, bn) \
17 Printf(" base: %f %f %d, %s: %f %f %d", a->GetXmin(), a->GetXmax(), a->GetNbins(), bn, b->GetXmin(), b->GetXmax(), \
21 Bool_t hasLimits =
h->GetXaxis()->GetXmin() <
h->GetXaxis()->GetXmax();
22 if (
h->GetDimension() > 1) hasLimits &=
h->GetYaxis()->GetXmin() <
h->GetYaxis()->GetXmax();
23 if (
h->GetDimension() > 2) hasLimits &=
h->GetZaxis()->GetXmin() <
h->GetZaxis()->GetXmax();
33 if (
gDebug)
Info(
"Merge",
"Histogram Merge type is %d and new axis flag is %d",(
int) type,(
int)
fNewAxisFlag);
63 Error(
"TH1Merger",
"Unknown type of Merge for histogram %s",
fH0->GetName());
85 Error(
"AutoP2BuildAxes",
"undefined histogram: %p",
h);
91 Error(
"AutoP2BuildAxes",
"not in autobin-power-of-2 mode!");
99 Bool_t canextend = (
h->GetBinContent(0) > 0 ||
h->GetBinContent(a1->GetNbins() + 1) > 0) ?
kFALSE :
kTRUE;
103 a0->
Set(a1->GetNbins(), a1->GetXmin(), a1->GetXmax());
111 Double_t bwmin = (a1->GetXmax() - a1->GetXmin()) / a1->GetNbins();
114 std::swap(bwmax, bwmin);
119 Error(
"AutoP2BuildAxes",
"minimal bin width negative or null: %f", bwmin);
124 Double_t re = std::modf(bwmax / bwmin, &rt);
125 if (re > std::numeric_limits<Double_t>::epsilon()) {
127 Error(
"AutoP2BuildAxes",
"bin widths not in integer ratio: %f", re);
134 if (a0->
GetXmin() < a1->GetXmin()) {
135 if (a0->
GetXmax() < a1->GetXmin()) {
138 Error(
"AutoP2BuildAxes",
"ranges are disconnected and under/overflows: cannot merge");
141 xmax = a1->GetXmax();
145 if (a0->
GetXmax() >= a1->GetXmax()) {
146 xmax = a1->GetXmax();
147 xmin = a1->GetXmin();
151 xmin = a1->GetXmin();
156 if (a1->GetXmax() < a0->
GetXmin()) {
159 Error(
"AutoP2BuildAxes",
"ranges are disconnected and under/overflows: cannot merge");
163 xmin = a1->GetXmin();
166 if (a1->GetXmax() >= a0->
GetXmax()) {
171 xmax = a1->GetXmax();
179 re = std::modf(range / bwmax, &rt);
182 Error(
"MergeCompatibleHistograms",
"range smaller than bin width: %f %f %f", range, bwmax, rt);
185 if (re > std::numeric_limits<Double_t>::epsilon()) {
244 int dimension =
fH0->GetDimension();
258 if (
h->GetDimension() != dimension) {
259 Error(
"Merge",
"Cannot merge histogram - dimensions are different\n "
260 "%s has dim=%d and %s has dim=%d",
fH0->GetName(),dimension,
h->GetName(),
h->GetDimension());
266 haveWeights |=
h->GetSumw2N() != 0;
271 allHaveLimits = allHaveLimits && hasLimits;
272 allSameLimits &= allHaveLimits;
275 Error(
"Merge",
"Cannot merge histogram - some are in autobin-power-of-2 mode, but not %s!",
h->GetName());
279 Error(
"Merge",
"Cannot merge histogram - %s is in autobin-power-of-2 mode, but not the previous ones",
302 if (!initialLimitsFound) {
303 initialLimitsFound =
kTRUE;
304 if (
h->GetXaxis()->GetXbins()->GetSize() != 0)
305 fNewXAxis.Set(
h->GetXaxis()->GetNbins(),
h->GetXaxis()->GetXbins()->GetArray());
307 fNewXAxis.Set(
h->GetXaxis()->GetNbins(),
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax());
309 if (
h->GetYaxis()->GetXbins()->GetSize() != 0)
310 fNewYAxis.Set(
h->GetYaxis()->GetNbins(),
h->GetYaxis()->GetXbins()->GetArray());
312 fNewYAxis.Set(
h->GetYaxis()->GetNbins(),
h->GetYaxis()->GetXmin(),
h->GetYaxis()->GetXmax());
315 if (
h->GetZaxis()->GetXbins()->GetSize() != 0)
316 fNewZAxis.Set(
h->GetZaxis()->GetNbins(),
h->GetZaxis()->GetXbins()->GetArray());
318 fNewZAxis.Set(
h->GetZaxis()->GetNbins(),
h->GetZaxis()->GetXmin(),
h->GetZaxis()->GetXmax());
330 Error(
"Merge",
"Cannot merge histograms - limits are inconsistent:\n "
331 "first: %s (%d, %f, %f), second: %s (%d, %f, %f)",
fH0->GetName(),
333 h->GetName(),
h->GetXaxis()->GetNbins(),
h->GetXaxis()->GetXmin(),
334 h->GetXaxis()->GetXmax());
345 Error(
"Merge",
"Cannot merge histograms - limits are inconsistent:\n "
346 "first: %s (%d, %f, %f), second: %s (%d, %f, %f)",
fH0->GetName(),
348 h->GetName(),
h->GetYaxis()->GetNbins(),
h->GetYaxis()->GetXmin(),
349 h->GetYaxis()->GetXmax());
353 if(dimension > 2 && !
fH0->SameLimitsAndNBins(
fNewZAxis, *(
h->GetZaxis()))) {
356 Error(
"Merge",
"Cannot merge histograms - limits are inconsistent:\n "
357 "first: %s (%d, %f, %f), second: %s (%d, %f, %f)",
fH0->GetName(),
359 h->GetName(),
h->GetZaxis()->GetNbins(),
h->GetZaxis()->GetXmin(),
360 h->GetZaxis()->GetXmax());
364 allSameLimits = sameLimitsX && sameLimitsY && sameLimitsZ;
369 Bool_t histoIsEmpty =
h->IsEmpty();
374 if (allHaveLabels && !histoIsEmpty) {
375 THashList* hlabelsX =
h->GetXaxis()->GetLabels();
376 THashList* hlabelsY = (dimension > 1) ?
h->GetYaxis()->GetLabels() :
nullptr;
377 THashList* hlabelsZ = (dimension > 2) ?
h->GetZaxis()->GetLabels() :
nullptr;
378 Bool_t haveOneLabelX = hlabelsX !=
nullptr;
379 Bool_t haveOneLabelY = hlabelsY !=
nullptr;
380 Bool_t haveOneLabelZ = hlabelsZ !=
nullptr;
381 Bool_t haveOneLabel = haveOneLabelX || haveOneLabelY || haveOneLabelZ;
383 if (foundLabelHist && allHaveLabels && !haveOneLabel) {
384 Warning(
"Merge",
"Not all histograms have labels. I will ignore labels,"
385 " falling back to bin numbering mode.");
388 allHaveLabels &= (haveOneLabel);
391 foundLabelHist =
kTRUE;
396 if (labelAxisType ==
TH1::kNoAxis) labelAxisType = type;
400 allHaveLabels &= consistentLabels;
401 if (!consistentLabels)
402 Warning(
"TH1Merger::ExamineHistogram",
"Histogram %s has inconsistent labels: %d is not consistent with %d",
403 h->GetName(), (
int) type, (
int) labelAxisType );
404 if (
gDebug && consistentLabels)
405 Info(
"TH1Merger::ExamineHistogram",
"Histogram %s has consistent labels",
h->GetName() );
411 if (dimension > 1 &&
fH0->GetYaxis()->CanExtend()) extendAxisType |=
TH1::kYaxis;
412 if (dimension > 2 &&
fH0->GetZaxis()->CanExtend()) extendAxisType |=
TH1::kZaxis;
416 if (allHaveLabels && !labelAxisCanBeExtended) {
419 if (
fH0->IsEmpty() ) {
421 Info(
"TH1Merger::ExamineHistogram",
"Histogram %s to be merged is empty and we are merging with %s that has labels. Force the axis to be extended",
fH0->GetName(),
h->GetName());
422 fH0->SetCanExtend( labelAxisType );
426 Info(
"TH1Merger::ExamineHistogram",
"Histogram %s to be merged has labels but corresponding axis cannot be extended - using bin numeric mode to merge. Call TH1::SetCanExtend(TH1::kAllAxes) if want to merge using label mode",
fH0->GetName());
436 Info(
"TH1Merger::ExamineHistogram",
"Examine histogram %s - labels %d - same limits %d - axis found %d",
h->GetName(),allHaveLabels,allSameLimits,initialLimitsFound );
438 }
while ( (
h =
dynamic_cast<TH1*
> ( next() ) ) !=
nullptr );
440 if (!
h && (*next) ) {
441 Error(
"Merge",
"Attempt to merge object of class: %s to a %s",
442 (*next)->ClassName(),
fH0->ClassName());
447 if (haveWeights &&
fH0->GetSumw2N() == 0)
458 if (allHaveLabels && allSameLimits)
return kAllLabel;
460 if (!initialLimitsFound) {
493 if (!
fH0->IsEmpty() ) {
497 fHClone->SetDirectory(
nullptr);
511 fH0->fXaxis.SetRange(0,0);
512 if (
fNewXAxis.GetXbins()->GetSize() != 0)
518 fH0->fYaxis.SetRange(0,0);
519 if (
fNewYAxis.GetXbins()->GetSize() != 0)
525 fH0->fZaxis.SetRange(0,0);
526 if (
fNewZAxis.GetXbins()->GetSize() != 0)
533 fH0->fNcells =
fH0->fXaxis.GetNbins()+2;
534 if (
fH0->fDimension > 1)
fH0->fNcells *=
fH0->fYaxis.GetNbins()+2;
535 if (
fH0->fDimension > 2)
fH0->fNcells *=
fH0->fZaxis.GetNbins()+2;
536 fH0->SetBinsLength(
fH0->fNcells);
537 if (
fH0->fSumw2.fN)
fH0->fSumw2.Set(
fH0->fNcells);
539 if (
fH0->fDimension < 3)
fH0->fZaxis.Set(1,0,1);
540 if (
fH0->fDimension < 2)
fH0->fYaxis.Set(1,0,1);
543 if (newLimitsX)
Info(
"DefineNewAxis",
"A new X axis has been defined Nbins=%d , [%f,%f]",
fH0->fXaxis.GetNbins(),
544 fH0->fXaxis.GetXmin(),
fH0->fXaxis.GetXmax() );
545 if (newLimitsY)
Info(
"DefineNewAxis",
"A new Y axis has been defined Nbins=%d , [%f,%f]",
fH0->fYaxis.GetNbins(),
546 fH0->fYaxis.GetXmin(),
fH0->fYaxis.GetXmax() );
547 if (newLimitsZ)
Info(
"DefineNewAxis",
"A new Z axis has been defined Nbins=%d , [%f,%f]",
fH0->fZaxis.GetNbins(),
548 fH0->fZaxis.GetXmin(),
fH0->fZaxis.GetXmax() );
559 if (!hsrc || !hsrc->
fBuffer || !hdes ) {
560 void *p1 = hsrc ? hsrc->
fBuffer :
nullptr;
563 Warning(
"TH1Merger::CopyMerge",
"invalid inputs: %p, %p, %p, -> do nothing", hsrc, hdes, p1);
571 for (
Int_t i = 0; i < nbentries; i++)
575 auto h2 =
dynamic_cast<TH2 *
>(hdes);
577 for (
Int_t i = 0; i < nbentries; i++)
581 auto h3 =
dynamic_cast<TH3 *
>(hdes);
583 for (
Int_t i = 0; i < nbentries; i++)
592 TH1 *href =
nullptr, *hist =
nullptr;
597 while ((hist = (
TH1 *)nextref()) && !href) {
614 while ((hist = (
TH1 *)next())) {
617 Info(
"AutoP2BufferMerge",
"merging buffer of %s into %s", hist->GetName(), href->
GetName());
637 totstats[i] = stats[i] = 0;
644 if (!(
fH0->IsEmpty())) {
647 while ((hist = (
TH1 *)next())) {
655 Info(
"TH1Merger::AutoP2Merge",
"all histograms look empty!");
661 Error(
"TH1Merger::AutoP2Merge",
"cannot create axes from %s", hist->
GetName());
665 while ((
h = (
TH1 *)next())) {
667 Error(
"TH1Merger::AutoP2Merge",
"cannot merge histogram %s: not merge compatible",
h->GetName());
676 fH0->GetStats(totstats);
688 while ((hist = (
TH1 *)next())) {
693 Info(
"TH1Merger::AutoP2Merge",
"merging histogram %s into %s (entries: %f)", hist->
GetName(),
fH0->GetName(),
703 totstats[i] += stats[i];
718 fH0->AddBinContent(jbin, cu);
720 fH0->fSumw2.fArray[jbin] += e1sq;
724 fH0->PutStats(totstats);
734 while (
TH1* hist = (
TH1*)next()) {
739 Info(
"TH1Merger::BufferMerge",
"Merging histogram %s into %s",hist->GetName(),
fH0->GetName() );
751 if (
fH0->fBuffer)
fH0->BufferEmpty(1);
761 totstats[i] = stats[i] = 0;
763 fH0->GetStats(totstats);
767 while (
TH1* hist=(
TH1*)next()) {
772 Info(
"TH1Merger::SameAxesMerge",
"Merging histogram %s into %s",hist->GetName(),
fH0->GetName() );
775 if (hist->IsEmpty())
continue;
778 hist->GetStats(stats);
780 totstats[i] += stats[i];
785 for (
Int_t ibin = 0; ibin < hist->fNcells; ibin++) {
790 fH0->PutStats(totstats);
806 fH0->GetStats(totstats);
811 while (
TH1* hist=(
TH1*)next()) {
814 Info(
"TH1Merger::DifferentAxesMerge",
"Merging histogram %s into %s",hist->GetName(),
fH0->GetName() );
817 if (hist->IsEmpty())
continue;
820 hist->GetStats(stats);
822 totstats[i] += stats[i];
826 for (
Int_t ibin = 0; ibin < hist->fNcells; ibin++) {
829 if (
IsBinEmpty(hist, ibin, tProfileMergeCode))
832 Int_t binx,biny,binz;
833 hist->GetBinXYZ(ibin, binx, biny, binz);
836 if (binx <= 0 || binx >= hist->GetNbinsX() + 1) {
837 if (
fH0->fXaxis.CanExtend() || ( hist->fXaxis.GetBinCenter(binx) >
fH0->fXaxis.GetXmin() && hist->fXaxis.GetBinCenter(binx) <
fH0->fXaxis.GetXmax()) ) {
838 Error(
"TH1Merger::DifferentAxesMerge",
"Cannot merge histograms - the histograms %s can extend the X axis or have"
839 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
843 if (biny <= 0 || biny >= hist->GetNbinsY() + 1) {
844 if (
fH0->fYaxis.CanExtend() || ( hist->fYaxis.GetBinCenter(biny) >
fH0->fYaxis.GetXmin() && hist->fYaxis.GetBinCenter(biny) <
fH0->fYaxis.GetXmax()) ) {
845 Error(
"TH1Merger::DifferentAxesMerge",
"Cannot merge histograms - the histograms %s can extend the Y axis or have"
846 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
850 if (binz <= 0 || binz >= hist->GetNbinsZ() + 1) {
851 if (
fH0->fZaxis.CanExtend() || ( hist->fZaxis.GetBinCenter(binz) >
fH0->fZaxis.GetXmin() && hist->fZaxis.GetBinCenter(binz) <
fH0->fZaxis.GetXmax()) ) {
852 Error(
"TH1Merger::DifferentAxesMerge",
"Cannot merge histograms - the histograms %s can extend the Z axis or have"
853 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
864 ix =
fH0->fXaxis.FindBin(hist->GetXaxis()->GetBinCenter(binx));
865 if (
fH0->fDimension > 1)
866 iy =
fH0->fYaxis.FindBin(hist->GetYaxis()->GetBinCenter(biny));
867 if (
fH0->fDimension > 2)
868 iz =
fH0->fZaxis.FindBin(hist->GetZaxis()->GetBinCenter(binz));
871 if (ib < 0 || ib >
fH0->fNcells) {
872 Fatal(
"TH1Merger::LabelMerge",
"Fatal error merging histogram %s - bin number is %d and array size is %d",
873 fH0->GetName(), ib,
fH0->fNcells);
889 fH0->PutStats(totstats);
900 if (!labels)
return kFALSE;
902 for (
const auto * obj: *labels) {
903 auto objList = labels->GetListForObject(obj);
905 if (objList->GetSize() > 1 ) {
907 std::unordered_set<std::string> s;
908 for (
const auto * o: *objList) {
909 auto ret = s.insert(std::string(o->GetName() ));
935 Warning(
"TH1Merger::CheckForDuplicateLabels",
"Histogram %s has duplicate labels in the x axis. "
936 "Bin contents will be merged in a single bin",hist->
GetName());
940 Warning(
"TH1Merger::CheckForDuplicateLabels",
"Histogram %s has duplicate labels in the y axis. "
941 "Bin contents will be merged in a single bin",hist->
GetName());
945 Warning(
"TH1Merger::CheckForDuplicateLabels",
"Histogram %s has duplicate labels in the z axis. "
946 "Bin contents will be merged in a single bin",hist->
GetName());
962 fH0->GetStats(totstats);
969 while (
TH1* hist=(
TH1*)next()) {
972 Info(
"TH1Merger::LabelMerge",
"Merging histogram %s into %s",hist->GetName(),
fH0->GetName() );
975 if (hist->IsEmpty())
continue;
978 hist->GetStats(stats);
980 totstats[i] += stats[i];
983 auto labelsX = hist->GetXaxis()->GetLabels();
984 auto labelsY = hist->GetYaxis()->GetLabels();
985 auto labelsZ = hist->GetZaxis()->GetLabels();
986 R__ASSERT(!( labelsX ==
nullptr && labelsY ==
nullptr && labelsZ ==
nullptr));
988 Bool_t mergeLabelsX = labelsX &&
fH0->fXaxis.CanExtend() && hist->fXaxis.CanExtend();
989 Bool_t mergeLabelsY = labelsY &&
fH0->fYaxis.CanExtend() && hist->fYaxis.CanExtend();
990 Bool_t mergeLabelsZ = labelsZ &&
fH0->fZaxis.CanExtend() && hist->fZaxis.CanExtend();
994 Info(
"TH1Merger::LabelMerge",
"Merging X axis in label mode");
996 Info(
"TH1Merger::LabelMerge",
"Merging X axis in numeric mode");
998 Info(
"TH1Merger::LabelMerge",
"Merging Y axis in label mode");
999 else if (hist->GetDimension() > 1)
1000 Info(
"TH1Merger::LabelMerge",
"Merging Y axis in numeric mode");
1002 Info(
"TH1Merger::LabelMerge",
"Merging Z axis in label mode" );
1003 else if (hist->GetDimension() > 2)
1004 Info(
"TH1Merger::LabelMerge",
"Merging Z axis in numeric mode");
1013 std::cout <<
"Bins of original histograms\n";
1014 for (
int ix = 1; ix <=
fH0->GetXaxis()->GetNbins(); ++ix) {
1015 for (
int iy = 1; iy <=
fH0->GetYaxis()->GetNbins(); ++iy) {
1016 for (
int iz = 1; iz <=
fH0->GetZaxis()->GetNbins(); ++iz) {
1017 int i =
fH0->GetBin(ix,iy,iz);
1018 std::cout <<
"bin" << ix <<
"," << iy <<
"," << iz
1019 <<
" : " <<
fH0->RetrieveBinContent(i) << std::endl;
1024 for (
Int_t ibin = 0; ibin < hist->fNcells; ibin++) {
1029 Int_t binx,biny,binz;
1030 hist->GetBinXYZ(ibin, binx, biny, binz);
1033 const char * labelX = hist->GetXaxis()->GetBinLabel(binx);
1034 const char * labelY = (
fH0->fDimension > 1) ? hist->GetYaxis()->GetBinLabel(biny) :
nullptr;
1035 const char * labelZ = (
fH0->fDimension > 2) ? hist->GetYaxis()->GetBinLabel(binz) :
nullptr;
1041 Int_t iy = (
fH0->fDimension > 1) ? -1 : 0;
1042 Int_t iz = (
fH0->fDimension > 2) ? -1 : 0;
1051 if (binx <= 0 || binx >= hist->GetNbinsX() + 1) {
1053 ix = (binx <= 0) ? 0 :
fH0->fXaxis.GetNbins() +1;
1054 if (newLimits && !mergeLabelsX) {
1055 if (
fH0->fXaxis.CanExtend() || ( hist->fXaxis.GetBinCenter(binx) >
fH0->fXaxis.GetXmin() && hist->fXaxis.GetBinCenter(binx) <
fH0->fXaxis.GetXmax()) ) {
1056 Error(
"TH1Merger::LabelMerge",
"Cannot merge histograms - the histograms %s can extend the X axis or have"
1057 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
1062 if (
fH0->fDimension > 1 ) {
1063 if (biny <= 0 || biny >= hist->GetNbinsY() + 1) {
1065 iy = (biny <= 0) ? 0 :
fH0->fYaxis.GetNbins() +1;
1066 if (newLimits && !mergeLabelsY) {
1067 if (
fH0->fYaxis.CanExtend() || ( hist->fYaxis.GetBinCenter(biny) >
fH0->fYaxis.GetXmin() && hist->fYaxis.GetBinCenter(biny) <
fH0->fYaxis.GetXmax()) ) {
1068 Error(
"TH1Merger::LabelMerge",
"Cannot merge histograms - the histograms %s can extend the Y axis or have"
1069 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
1075 if (
fH0->fDimension > 2 ) {
1076 if (binz <= 0 || binz >= hist->GetNbinsZ() + 1) {
1078 iz = (binz <= 0) ? 0 :
fH0->fZaxis.GetNbins() +1;
1079 if (newLimits && !mergeLabelsZ) {
1080 if (
fH0->fZaxis.CanExtend() || ( hist->fZaxis.GetBinCenter(binz) >
fH0->fZaxis.GetXmin() && hist->fZaxis.GetBinCenter(binz) <
fH0->fZaxis.GetXmax()) ) {
1081 Error(
"TH1Merger::LabelMerge",
"Cannot merge histograms - the histograms %s can extend the Z axis or have"
1082 " different limits and underflows/overflows are present in the histogram %s.",
fH0->GetName(),hist->GetName());
1093 ix =
fH0->fXaxis.FindBin(labelX);
1100 if (iy == -1 &&
fH0->fDimension> 1 ) {
1102 iy=
fH0->fYaxis.FindBin(labelY);
1106 if (iz == -1 &&
fH0->fDimension> 2) {
1108 iz=
fH0->fZaxis.FindBin(labelZ);
1114 Info(
"TH1Merge::LabelMerge",
"Merge bin [%d,%d,%d] with label [%s,%s,%s] into bin [%d,%d,%d]",
1115 binx,biny,binz,labelX,labelY,labelZ,ix,iy,iz);
1119 if (ib < 0 || ib >=
fH0->fNcells) {
1120 Fatal(
"TH1Merger::LabelMerge",
"Fatal error merging histogram %s - bin number is %d and array size is %d",
1121 fH0->GetName(), ib,
fH0->fNcells);
1128 fH0->PutStats(totstats);
1140 bool profileCheck = (profileDim == 0);
1142 if (profileDim == 1) {
1143 auto prof =
static_cast<const TProfile *
>(hist);
1144 profileCheck = prof->fBinEntries.fArray[ibin] == 0;
1145 }
else if (profileDim == 2) {
1146 auto prof =
static_cast<const TProfile2D *
>(hist);
1147 profileCheck = prof->fBinEntries.fArray[ibin] == 0;
1148 }
else if (profileDim == 3) {
1149 auto prof =
static_cast<const TProfile3D *
>(hist);
1150 profileCheck = prof->fBinEntries.fArray[ibin] == 0;
1152 return cu == 0 && e1sq == 0 && profileCheck;
1160 fH0->AddBinContent(cbin, cu);
1161 if (
fH0->fSumw2.fN) {
1163 fH0->fSumw2.fArray[cbin] += e1sq;
1177template<
class TProfileType>
1180 TProfileType *p =
static_cast<TProfileType *
>(
fH0);
1181 p->fArray[pbin] +=
h->fArray[hbin];
1182 p->fSumw2.fArray[pbin] +=
h->fSumw2.fArray[hbin];
1183 p->fBinEntries.fArray[pbin] +=
h->fBinEntries.fArray[hbin];
1184 if (p->fBinSumw2.fN) {
1185 if (
h->fBinSumw2.fN)
1186 p->fBinSumw2.fArray[pbin] +=
h->fBinSumw2.fArray[hbin];
1188 p->fBinSumw2.fArray[pbin] +=
h->fArray[hbin];
1191 Info(
"TH1Merge::MergeProfileBin",
"Merge bin %d of profile %s with content %f in bin %d - result is %f", hbin,
1192 h->GetName(),
h->fArray[hbin], pbin, p->fArray[pbin]);
int Int_t
Signed integer 4 bytes (int).
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.
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 Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
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.
#define PRINTRANGE(a, b, bn)
Class to manage histogram axis.
void SetCanExtend(Bool_t canExtend)
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
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
Bool_t AutoP2BufferMerge()
static Bool_t AxesHaveLimits(const TH1 *h)
static Int_t CheckForDuplicateLabels(const TH1 *hist)
Check if histogram has duplicate labels Return an integer with bit set correponding on the axis that ...
Bool_t AutoP2BuildAxes(TH1 *)
Determine final boundaries and number of bins for histograms created in power-of-2 autobin mode.
Bool_t DifferentAxesMerge()
Merged histogram when axis can be different.
static Int_t FindFixBinNumber(Int_t ibin, const TAxis &inAxis, const TAxis &outAxis)
TH1 * fH0
! histogram on which the list is merged
void CopyBuffer(TH1 *hsrc, TH1 *hdes)
Bool_t LabelMerge(bool newLimits=false)
Merge histograms with labels and if newLimits is set support the case that one of the axis can set ne...
EMergerType ExamineHistograms()
Examine the list of histograms to find out which type of Merge we need to do Pass the input list cont...
static Bool_t HasDuplicateLabels(const THashList *labels)
Find a duplicate labels in an axis label list.
void MergeBin(const TH1 *hist, Int_t inbin, Int_t outbin)
Bool_t operator()()
Function performing the actual merge.
void DefineNewAxes()
Function to define new histogram axis when merging It is call only in case of merging with different ...
static Bool_t IsBinEmpty(const TH1 *hist, Int_t bin, Int_t profileDim=0)
helper function for merging
TH1 * fHClone
! copy of fH0 - managed by this class
void MergeProfileBin(const TProfileType *p, Int_t ibin, Int_t outbin)
TH1 is the base class of all histogram classes in ROOT.
Double_t * fBuffer
[fBufferSize] entry buffer
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
@ kAutoBinPTwo
different than 1.
static Bool_t RecomputeAxisLimits(TAxis &destAxis, const TAxis &anAxis)
Finds new limits for the axis for the Merge function.
static Bool_t SameLimitsAndNBins(const TAxis &axis1, const TAxis &axis2)
Same limits and bins.
Int_t fDimension
! Histogram dimension (1, 2 or 3 dim)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
virtual Double_t GetEntries() const
Return the current number of entries.
virtual Double_t RetrieveBinContent(Int_t bin) const =0
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Bool_t IsEmpty() const
Check if a histogram is empty (this is a protected method used mainly by TH1Merger ).
@ kNstat
Size of statistics data (up to TProfile3D).
TArrayD fSumw2
Array of sum of squares of weights.
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
@ kNoAxis
NOTE: Must always be 0 !!!
Service class for 2-D histogram classes.
The 3-D histogram classes derived from the 1-D histogram classes.
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.
Profile2D histograms are used to display the mean value of Z and its error for each cell in X,...
Profile3D histograms are used to display the mean value of T and its RMS for each cell in X,...