CMS 3D CMS Logo

List of all members | Static Public Member Functions
DQMTTreeIO::DQMMergeHelper Class Reference

Static Public Member Functions

static bool CheckBinLabels (const TAxis *a1, const TAxis *a2)
 
static void mergeTogether (TH1 *original, TH1 *toAdd)
 

Detailed Description

Definition at line 61 of file DQMRootSource.cc.

Member Function Documentation

◆ CheckBinLabels()

static bool DQMTTreeIO::DQMMergeHelper::CheckBinLabels ( const TAxis *  a1,
const TAxis *  a2 
)
inlinestatic

Definition at line 65 of file DQMRootSource.cc.

References testProducerWithPsetDescEmpty_cfi::a2, mps_fire::i, HLT_2022v15_cff::label1, and HLT_2022v15_cff::label2.

Referenced by mergeTogether().

65  {
66  // Check that axis have same labels
67  THashList* l1 = (const_cast<TAxis*>(a1))->GetLabels();
68  THashList* l2 = (const_cast<TAxis*>(a2))->GetLabels();
69 
70  if (!l1 && !l2)
71  return true;
72  if (!l1 || !l2) {
73  return false;
74  }
75 
76  // Check now labels sizes are the same
77  if (l1->GetSize() != l2->GetSize()) {
78  return false;
79  }
80 
81  for (int i = 1; i <= a1->GetNbins(); ++i) {
82  std::string_view label1 = a1->GetBinLabel(i);
83  std::string_view label2 = a2->GetBinLabel(i);
84  if (label1 != label2) {
85  return false;
86  }
87  }
88 
89  return true;
90  }

◆ mergeTogether()

static void DQMTTreeIO::DQMMergeHelper::mergeTogether ( TH1 *  original,
TH1 *  toAdd 
)
inlinestatic

Definition at line 93 of file DQMRootSource.cc.

References CheckBinLabels(), definitions::original, and HLT_2022v15_cff::toAdd.

Referenced by DQMTTreeIO::TreeObjectReader< T >::read().

93  {
94  if (original->CanExtendAllAxes() && toAdd->CanExtendAllAxes()) {
95  TList list;
96  list.Add(toAdd);
97  if (original->Merge(&list) == -1) {
98  edm::LogError("MergeFailure") << "Failed to merge DQM element " << original->GetName();
99  }
100  } else {
101  // TODO: Redo. This is both more strict than what ROOT checks for yet
102  // allows cases where ROOT fails with merging.
103  if (original->GetNbinsX() == toAdd->GetNbinsX() &&
104  original->GetXaxis()->GetXmin() == toAdd->GetXaxis()->GetXmin() &&
105  original->GetXaxis()->GetXmax() == toAdd->GetXaxis()->GetXmax() &&
106  original->GetNbinsY() == toAdd->GetNbinsY() &&
107  original->GetYaxis()->GetXmin() == toAdd->GetYaxis()->GetXmin() &&
108  original->GetYaxis()->GetXmax() == toAdd->GetYaxis()->GetXmax() &&
109  original->GetNbinsZ() == toAdd->GetNbinsZ() &&
110  original->GetZaxis()->GetXmin() == toAdd->GetZaxis()->GetXmin() &&
111  original->GetZaxis()->GetXmax() == toAdd->GetZaxis()->GetXmax() &&
112  CheckBinLabels(original->GetXaxis(), toAdd->GetXaxis()) &&
113  CheckBinLabels(original->GetYaxis(), toAdd->GetYaxis()) &&
114  CheckBinLabels(original->GetZaxis(), toAdd->GetZaxis())) {
115  original->Add(toAdd);
116  } else {
117  edm::LogError("MergeFailure") << "Found histograms with different axis limits or different labels '"
118  << original->GetName() << "' not merged.";
119  }
120  }
121  }
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Log< level::Error, false > LogError