15 {
16 std::unique_ptr<TFile>
f1( TFile::Open(file1.c_str()) );
17 std::unique_ptr<TFile>
f2( TFile::Open(file2.c_str()) );
18
19 if (!f1 ||
f1->IsZombie() || !f2 ||
f2->IsZombie()) {
20 if (!f1 ||
f1->IsZombie()) {
21 std::cout << "could not open file1 " << file1 << std::endl;
22 }
23 if (!f2 ||
f2->IsZombie()) {
24 std::cout << "could not open file2 " << file2 << std::endl;
25 }
26
29 }
30 return;
31 }
32
33 const int hnum = 7;
34 const char hnames[hnum][100] = {
35 "h3_w", "h3_eta", "h3_phi", "h3_R",
36 "h3_eta_phi_response", "h3_eta_phi_offset",
37 "h1_run_index"};
38
39
40
41 int hdiff[hnum] = {
42 0, 0, 0, 0,
43 0, 0, 0};
44
45
46 char hresult[hnum][30] = {
47 "same", "not found", "different dimensions",
48 "different axes", "different bins", "different bin content"};
49
50 for (
int h = 0;
h < hnum;
h++) {
51 if (!(testOnly & (1 <<
h))) {
52 continue;
53 }
54
55
56 TH1*
h1 = (TH1*)
f1->Get(hnames[
h]);
57 if (h1) {
59 h1->SetName(Form(
"%s_h1", hnames[
h]));
60 }
61
62 TH1* h2 = (TH1*)
f2->Get(hnames[
h]);
63 if (h2) {
64 h2->SetDirectory(0);
65 h2->SetName(Form(
"%s_h2", hnames[
h]));
66 }
67
68 if (!h1 || !h2) {
69 if (!h1) {
70 std::cout <<
"could not find histogram " << hnames[
h] <<
" in file1 "
71 << file1 << std::endl;
72 }
73 if (!h2) {
74 std::cout <<
"could not find histogram " << hnames[
h] <<
" in file2 "
75 << file2 << std::endl;
76 }
77
78
80 continue;
81 }
82
83 int dim1 =
h1->GetDimension();
84 int dim2 = h2->GetDimension();
85 if (dim1 != dim2) {
86 std::cout <<
"h1 " <<
h1->GetName() <<
" has dimension " << dim1
87 << ", h2 " << h2->GetName() << " has dimension " << dim2
88 << std::endl;
89
91 continue;
92 }
93
94 if (
h1->GetNbinsX() != h2->GetNbinsX() ||
95 (dim1 > 1 &&
h1->GetNbinsY() != h2->GetNbinsY()) ||
96 (dim1 > 2 &&
h1->GetNbinsZ() != h2->GetNbinsZ())) {
97 if (
h1->GetNbinsX() != h2->GetNbinsX()) {
98 std::cout <<
"h1 " <<
h1->GetName() <<
" has " <<
h1->GetNbinsX()
99 << " bins in X, h2 " << h2->GetName() << " has "
100 << h2->GetNbinsX() << " bins in X" << std::endl;
101 }
102 if (
h1->GetNbinsY() != h2->GetNbinsY()) {
103 std::cout <<
"h1 " <<
h1->GetName() <<
" has " <<
h1->GetNbinsY()
104 << " bins in Y, h2 " << h2->GetName() << " has "
105 << h2->GetNbinsY() << " bins in Y" << std::endl;
106 }
107 if (
h1->GetNbinsZ() != h2->GetNbinsZ()) {
108 std::cout <<
"h1 " <<
h1->GetName() <<
" has " <<
h1->GetNbinsZ()
109 << " bins in Z, h2 " << h2->GetName() << " has "
110 << h2->GetNbinsZ() << " bins in Z" << std::endl;
111 }
112
113
115 continue;
116 }
117
118 int doBreak = 0;
119 int dim =
h1->GetDimension();
120 for (
int d = 1;
d <=
dim;
d++) {
121 TAxis* a1 = nullptr;
122 TAxis* a2 = nullptr;
123 if (d == 1) {
125 a2 = h2->GetXaxis();
126 }
127 if (d == 2) {
129 a2 = h2->GetYaxis();
130 }
131 if (d == 3) {
133 a2 = h2->GetZaxis();
134 }
135 if((not a1) or (not a2)) {
136 std::cout <<
"h1 " <<
h1->GetName() <<
" has pointer to " <<
char(
'W'+d)
137 << "-axis = " << a1 << ", h2 " << h2->GetName()
138 <<
" has pointer to " <<
char(
'W'+d) <<
"-axis = " << a2
139 << std::endl;
140
142 doBreak = 1;
143 break;
144 }
145 for (
int b = 1;
b <= a1->GetNbins() + 1; ++
b) {
146 if (a1->GetBinLowEdge(b) != a2->GetBinLowEdge(b)) {
147
149 std::cout <<
"h1 " <<
h1->GetName() <<
" has bin " <<
b
150 << " with low edge " << a1->GetBinLowEdge(b) << ", h2 "
151 << h2->GetName() <<
" has bin " <<
b <<
" with low edge "
152 << a2->GetBinLowEdge(b) << std::endl;
153 doBreak = 1;
154 break;
155 }
156 }
157 if (doBreak) {
158 break;
159 }
160 }
161 if (doBreak) {
162 continue;
163 }
164
165 for (
int bx = 1;
bx <=
h1->GetNbinsX(); ++
bx) {
166 for (
int by = 1;
by <=
h1->GetNbinsY(); ++
by) {
167 for (
int bz = 1;
bz <=
h1->GetNbinsZ(); ++
bz) {
168 if (TMath::Abs(
h1->GetBinContent(bx, by, bz) - h2->GetBinContent(bx, by, bz)) > eps) {
169
171 std::cout <<
"h1 " <<
h1->GetName() <<
" has "
172 <<
h1->GetBinContent(bx, by, bz) <<
" in bin " <<
bx
173 <<
"," <<
by <<
"," <<
bz <<
", h2 " << h2->GetName()
174 << " has " << h2->GetBinContent(bx, by, bz) << std::endl;
175 std::cout << "skipping the rest of bins" << std::endl;
176 doBreak = 1;
177 }
178 if (doBreak) {
179 break;
180 }
181 }
182 if (doBreak) {
183 break;
184 }
185 }
186 if (doBreak) {
187 break;
188 }
189 }
190 }
191
194 }
195
196 for (
int h = 0;
h < hnum;
h++) {
197 if (!(testOnly & (1 <<
h))) {
198 continue;
199 }
200 std::cout << hnames[
h] <<
": " << hresult[hdiff[
h]] << std::endl;
203 }
204 }
205
206 return;
207}
Header file for AthHistogramAlgorithm.