Skip to content
Snippets Groups Projects
Commit 504060e1 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'rootcomp_labels' into 'master'

rootcomp: add option to sort bin labels

See merge request !34951
parents 57bd3fae 9be5c8ee
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!34951rootcomp: add option to sort bin labels
......@@ -45,6 +45,7 @@ class TRootCompare : public TFileLooper {
}
void drawNormalized(Bool_t norm = kTRUE) { m_drawNormalized = norm; }
void drawDiff(Bool_t diff = kTRUE) { m_drawDiff = diff; }
void sortLabels(Bool_t sort = kTRUE) { m_sortLabels = sort; }
Int_t matchingHist() const { return m_histMatch; }
Int_t totalHist() const { return m_histTotal; }
......@@ -52,6 +53,7 @@ class TRootCompare : public TFileLooper {
private:
Bool_t compareHist(const TH1& h, const TH1& href);
void sortAndDeflate(TH1& h);
void createDirectory(TFile* f, const char* dirpath);
void printCanvas(const char* filename);
......@@ -69,6 +71,7 @@ class TRootCompare : public TFileLooper {
Int_t m_histMissing;
Bool_t m_drawNormalized;
Bool_t m_drawDiff;
Bool_t m_sortLabels;
std::vector<std::string> m_noMatch;
......
#!/usr/bin/env python
#
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# @file: rootcomp.py
# @purpose: Script to compare the histograms in two root files
# @author: Frank Winklmeier, Will Buttinger
......@@ -62,6 +62,10 @@ def main():
action = "store_true",
help = "use axis comparison instead of bin-by-bin")
parser.add_option("-l", "--sortLabels",
action = "store_true",
help = "sort/deflate alphanumeric axis before comparing")
parser.add_option("-t", "--threshold",
action = "store", type="float",
help = "threshold for bin or chi2 comparison (default: 1e-6 or 0.95)")
......@@ -225,7 +229,7 @@ def main():
else:
valid.setPsFile(opts.outFile+".ps")
valid.sortLabels(opts.sortLabels)
valid.drawNormalized(opts.norm)
valid.drawDiff(not opts.noDiff)
......
......@@ -153,6 +153,13 @@ void TRootCompare::processKey(TDirectory& dir, TKey& key)
if (obj->IsA()->InheritsFrom("TH1")) {
TH1& h = *((TH1*)obj.get());
TH1& href = *((TH1*)refObj);
// For alphanumeric axes, sort and deflate
if (m_sortLabels) {
sortAndDeflate(h);
sortAndDeflate(href);
}
Bool_t match = compareHist(h,href);
m_histTotal++;
if (match) {
......@@ -451,6 +458,18 @@ Bool_t TRootCompare::compareHist(const TH1& h, const TH1& href)
return result;
}
// sort histogram axes and deflate
void TRootCompare::sortAndDeflate(TH1& h)
{
if (h.GetXaxis()->IsAlphanumeric()) {
h.GetXaxis()->LabelsOption("a");
h.LabelsDeflate("X");
}
if (h.GetYaxis()->IsAlphanumeric()) {
h.GetYaxis()->LabelsOption("a");
h.LabelsDeflate("Y");
}
}
// Create all directories in dirpath
void TRootCompare::createDirectory(TFile* f, const char* dirpath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment