Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made public TH1::CheckConsistency (2) #14077

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion hist/hist/inc/TH1.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
kNeutral = 2, ///< Adapt to the global flag
};

/// Enumeration specifying inconsistencies between two histograms,
/// in increasing severity.
enum EInconsistencyBits {
kFullyConsistent = 0,
kDifferentLabels = BIT(0),
kDifferentBinLimits = BIT(1),
kDifferentAxisLimits = BIT(2),
kDifferentNumberOfBins = BIT(3),
kDifferentDimensions = BIT(4)
};

friend class TH1Merger;

protected:
Expand Down Expand Up @@ -156,7 +167,6 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
static bool CheckBinLabels(const TAxis* a1, const TAxis* a2);
static bool CheckEqualAxes(const TAxis* a1, const TAxis* a2);
static bool CheckConsistentSubAxes(const TAxis *a1, Int_t firstBin1, Int_t lastBin1, const TAxis *a2, Int_t firstBin2=0, Int_t lastBin2=0);
static int CheckConsistency(const TH1* h1, const TH1* h2);
int LoggedInconsistency(const char* name, const TH1* h1, const TH1* h2, bool useMerge=false) const;

public:
Expand Down Expand Up @@ -199,6 +209,7 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
virtual Double_t Chi2Test(const TH1* h2, Option_t *option = "UU", Double_t *res = nullptr) const;
virtual Double_t Chi2TestX(const TH1* h2, Double_t &chi2, Int_t &ndf, Int_t &igood,Option_t *option = "UU", Double_t *res = nullptr) const;
virtual Double_t Chisquare(TF1 * f1, Option_t *option = "") const;
static Int_t CheckConsistency(const TH1* h1, const TH1* h2);
virtual void ClearUnderflowAndOverflow();
virtual Double_t ComputeIntegral(Bool_t onlyPositive = false);
TObject* Clone(const char *newname = "") const override;
Expand Down
19 changes: 3 additions & 16 deletions hist/hist/src/TH1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -594,21 +594,6 @@ extern void H1LeastSquareFit(Int_t n, Int_t m, Double_t *a);
extern void H1LeastSquareLinearFit(Int_t ndata, Double_t &a0, Double_t &a1, Int_t &ifail);
extern void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b);

namespace {

/// Enumeration specifying inconsistencies between two histograms,
/// in increasing severity.
enum EInconsistencyBits {
kFullyConsistent = 0,
kDifferentLabels = BIT(0),
kDifferentBinLimits = BIT(1),
kDifferentAxisLimits = BIT(2),
kDifferentNumberOfBins = BIT(3),
kDifferentDimensions = BIT(4)
};

} // namespace

ClassImp(TH1);

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1675,8 +1660,10 @@ bool TH1::CheckConsistentSubAxes(const TAxis *a1, Int_t firstBin1, Int_t lastBin

////////////////////////////////////////////////////////////////////////////////
/// Check histogram compatibility.
/// The returned integer is part of EInconsistencyBits
/// The value 0 means that the histograms are compatible

int TH1::CheckConsistency(const TH1* h1, const TH1* h2)
Int_t TH1::CheckConsistency(const TH1* h1, const TH1* h2)
{
if (h1 == h2) return kFullyConsistent;

Expand Down
Loading