Method called for every key.
Only dummy implementation. Needs to be implemented in derived classes.
117{
119
121
122 if (TString(
key.GetName()).Contains(
"/")) {
123 cout <<
"IGNORE: " <<
key.GetName() <<
" contains '/'" << endl;
124 return;
125 }
126
127 std::unique_ptr<TObject>
obj(
key.ReadObj());
128
129
134 TString keyPath(dirName+
"/"+
key.GetName());
135
138 return;
139 }
140
141 TObject* refObj =
m_refFile->Get(keyPath);
142 if (!refObj) {
143 cout << "Cannot find " << keyPath << " in reference file" << endl;
145 return;
146 }
147
148 if (
obj->Class()!=refObj->Class()) {
149 cout <<
key.GetName() <<
" is of different type in file and reference file." << endl;
150 return;
151 }
152
153 if (
obj->IsA()->InheritsFrom(
"TH1")) {
154 TH1&
h = *
static_cast<TH1*
>(
obj.get());
155 TH1&
href = *
static_cast<TH1*
>(refObj);
156
157
161 }
162
167 }
168 else {
170
171
173
176 m_can->cd(1)->SetPad(0,1,1,0.90);
177 m_can->cd(2)->SetPad(0,0.90,1,0);
178 TVirtualPad* pad =
m_can->cd(2);
179
181 m_can->SetName(
h.GetName());
182 m_can->SetTitle(
h.GetTitle());
183
184 pad->cd(1);
187 if (
h.Integral())
h.Scale(1/
h.Integral());
188 }
189
190 Double_t
ymax = 1.05*
max(
h.GetMaximum(),
href.GetMaximum());
192 h.SetLineColor(kBlue);
195 TPaveStats* st1 = (TPaveStats*)gPad->GetPrimitive("stats");
196 if (st1) {
197 st1->SetName("stats1");
198 st1->SetLineColor(kBlue);
199 }
200
201 href.SetLineColor(kRed);
204 TPaveStats* st2 = (TPaveStats*)gPad->GetPrimitive("stats");
205 if (st1 && st2) {
206
207 Double_t
x1 = st1->GetX1NDC()-0.01;
208 st2->SetName("stats2");
209 Double_t
w = st2->GetX2NDC()-st2->GetX1NDC();
210 st2->SetX1NDC(x1-w);
211 st2->SetX2NDC(x1);
212 st2->SetLineColor(kRed);
214 }
215
216 TH1* hdiff = 0;
218 hdiff = (TH1*)
h.Clone();
219
220 if (hdiff->GetDimension()==1 &&
221 hdiff->GetNbinsX()==
href.GetNbinsX()) {
222
223 pad->cd(2);
224 hdiff->SetName(TString(
href.GetName())+
" (diff)");
225 hdiff->SetTitle(TString(
href.GetTitle())+
" (diff)");
226 hdiff->SetLineColor(kBlack);
227 hdiff->Add(&href,-1);
228 hdiff->Draw();
229 TPaveStats*
st = (TPaveStats*)gPad->GetPrimitive(
"stats1");
230 if (st)
st->SetLineColor(kBlack);
231 }
232 if(hdiff->GetDimension()==2 &&
233 hdiff->GetNbinsX()==
href.GetNbinsX() &&
234 hdiff->GetNbinsY()==
href.GetNbinsY()) {
235 pad->cd(2);
236 hdiff->SetName(TString(
href.GetName())+
" (diff)");
237 hdiff->SetTitle(TString(
href.GetTitle())+
" (diff)");
238 hdiff->SetLineColor(kBlack);
239 hdiff->Add(&href,-1);
240 if(hdiff->GetXaxis()->GetLabels()!=0 && hdiff->GetNbinsX()>100) {
241 TH1 * hdiffred = (TH1*)hdiff->Clone();
242 hdiffred->GetXaxis()->GetLabels()->Delete();
243 hdiffred->Reset();
244 hdiffred->SetName(TString(
href.GetName())+
" (diff reduced)");
245 hdiffred->SetTitle(TString(
href.GetTitle())+
" (diff reduced)");
246 int targetbin=1;
247 for(
int x=1;
x<=hdiff->GetNbinsX(); ++
x) {
248 bool isEmpty(true);
249 for(
int y=1;
y<=hdiff->GetNbinsY();++
y) {
250 if(hdiff->GetBinContent(
x,
y)!=0) { isEmpty=
false;
break; }
251 }
252 if(!isEmpty) {
253 for(
int y=1;
y<=hdiff->GetNbinsY();++
y) {
254 if(hdiff->GetBinContent(
x,
y)!=0)
255 hdiffred->SetBinContent(targetbin,
y,hdiff->GetBinContent(
x,
y));
256 }
257 hdiffred->GetXaxis()->SetBinLabel(targetbin,hdiff->GetXaxis()->GetBinLabel(
x));
258 targetbin++;
259 }
260 }
261 hdiffred->LabelsDeflate();
262 hdiffred->Draw("text");
263 } else {
264 hdiff->Draw("text");
265 }
266 TPaveStats*
st = (TPaveStats*)gPad->GetPrimitive(
"stats1");
267 if (st)
st->SetLineColor(kBlack);
268 }
269 }
270
271
274 text.SetTextSize(0.03);
275 text.SetTextAlign(22);
276 TString
page(
"page ");
278 text.DrawTextNDC(0.5,0.03,page);
279
283 text.DrawTextNDC(0.5,0.99,title);
284
285 const int maxchars = 120;
287 text.SetTextColor(kBlue);
289 text.DrawTextNDC(0.5,0.93,
s.substr(
max(0,
int(
s.size()-maxchars))).c_str());
290 }
292 text.SetTextColor(kRed);
294 text.DrawTextNDC(0.5,0.96,
s.substr(
max(0,
int(
s.size()-maxchars))).c_str());
295 }
296
298
299
303 }
304
305 if (hdiff) delete hdiff;
306 }
307 }
308 else if (
obj->IsA()->InheritsFrom(
"TEfficiency")) {
309 auto h =
static_cast<TEfficiency*
>(
obj.get());
310 auto href =
static_cast<TEfficiency*
>(refObj);
314
315
317 else m_noMatch.push_back(keyPath.Data());
318 }
319}
void createDirectory(TFile *f, const char *dirpath)
Bool_t compareHist(const TH1 &h, const TH1 &href)
void sortAndDeflate(TH1 &h)
bool match(std::string s1, std::string s2)
match the individual directories of two strings