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

move checkBinLabel as a static function in MonitorElement and use it fro... #4770

Merged
merged 1 commit into from Aug 5, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions DQMServices/Core/interface/MonitorElement.h
Expand Up @@ -96,6 +96,9 @@ class MonitorElement
return DQMNet::setOrder(data_, x.data_);
}

/// Check the consistency of the axis labels
static bool CheckBinLabels(const TAxis* a1, const TAxis * a2);

/// Get the type of the monitor element.
Kind kind(void) const
{ return Kind(data_.flags & DQMNet::DQM_PROP_TYPE_MASK); }
Expand Down
5 changes: 4 additions & 1 deletion DQMServices/Core/src/DQMStore.cc
Expand Up @@ -1489,7 +1489,10 @@ DQMStore::checkBinningMatches(MonitorElement *me, TH1 *h)
|| me->getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
|| me->getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
|| me->getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
|| me->getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax())
|| me->getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax()
|| !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetXaxis(),(TAxis*)h->GetXaxis())
|| !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetYaxis(),(TAxis*)h->GetYaxis())
|| !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetZaxis(),(TAxis*)h->GetZaxis()) )
{
// edm::LogWarning ("DQMStore")
std::cout << "*** DQMStore: WARNING:"
Expand Down
29 changes: 29 additions & 0 deletions DQMServices/Core/src/MonitorElement.cc
Expand Up @@ -6,6 +6,7 @@
#include "TClass.h"
#include "TMath.h"
#include "TList.h"
#include "THashList.h"
#include <iostream>
#include <cassert>
#include <cfloat>
Expand Down Expand Up @@ -228,6 +229,34 @@ MonitorElement::~MonitorElement(void)
delete refvalue_;
}

//utility function to check the consistency of the axis labels
//taken from TH1::CheckBinLabels which is not public
bool
MonitorElement::CheckBinLabels(const TAxis* a1, const TAxis * a2)
{
// check that axis have same labels
THashList *l1 = (const_cast<TAxis*>(a1))->GetLabels();
THashList *l2 = (const_cast<TAxis*>(a2))->GetLabels();

if (!l1 && !l2 )
return true;
if (!l1 || !l2 ) {
return false;
}
// check now labels sizes are the same
if (l1->GetSize() != l2->GetSize() ) {
return false;
}
for (int i = 1; i <= a1->GetNbins(); ++i) {
TString label1 = a1->GetBinLabel(i);
TString label2 = a2->GetBinLabel(i);
if (label1 != label2) {
return false;
}
}
return true;
}

/// "Fill" ME methods for string
void
MonitorElement::Fill(std::string &value)
Expand Down
34 changes: 3 additions & 31 deletions DQMServices/FwkIO/plugins/DQMRootSource.cc
Expand Up @@ -20,7 +20,6 @@
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "THashList.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
Expand Down Expand Up @@ -66,33 +65,6 @@
#include "format.h"

namespace {
//utility function to check the consistency of the axis labels
//taken from TH1::CheckBinLabels
bool CheckBinLabels(const TAxis* a1, const TAxis * a2)
{
// check that axis have same labels
THashList *l1 = (const_cast<TAxis*>(a1))->GetLabels();
THashList *l2 = (const_cast<TAxis*>(a2))->GetLabels();

if (!l1 && !l2 )
return true;
if (!l1 || !l2 ) {
return false;
}
// check now labels sizes are the same
if (l1->GetSize() != l2->GetSize() ) {
return false;
}
for (int i = 1; i <= a1->GetNbins(); ++i) {
TString label1 = a1->GetBinLabel(i);
TString label2 = a2->GetBinLabel(i);
if (label1 != label2) {
return false;
}
}
return true;
}

//adapter functions
MonitorElement* createElement(DQMStore& iStore, const char* iName, TH1F* iHist) {
//std::cout <<"create: hist size "<<iName <<" "<<iHist->GetEffectiveEntries()<<std::endl;
Expand All @@ -116,9 +88,9 @@ namespace {
iOriginal->GetNbinsZ() == iToAdd->GetNbinsZ() &&
iOriginal->GetZaxis()->GetXmin() == iToAdd->GetZaxis()->GetXmin() &&
iOriginal->GetZaxis()->GetXmax() == iToAdd->GetZaxis()->GetXmax() &&
CheckBinLabels(iOriginal->GetXaxis(),iToAdd->GetXaxis()) &&
CheckBinLabels(iOriginal->GetYaxis(),iToAdd->GetYaxis()) &&
CheckBinLabels(iOriginal->GetZaxis(),iToAdd->GetZaxis())) {
MonitorElement::CheckBinLabels(iOriginal->GetXaxis(),iToAdd->GetXaxis()) &&
MonitorElement::CheckBinLabels(iOriginal->GetYaxis(),iToAdd->GetYaxis()) &&
MonitorElement::CheckBinLabels(iOriginal->GetZaxis(),iToAdd->GetZaxis())) {
iOriginal->Add(iToAdd);
} else {
edm::LogError("MergeFailure")<<"Found histograms with different axis limits or different labels'"<<iOriginal->GetName()<<"' not merged.";
Expand Down