21 bool PlotCompareUtility::compare<Plot2D>(
HistoData *HD) {
27 if (hnew2d ==
nullptr || href2d ==
nullptr || hnew2d->GetEntries() <= 1 || href2d->GetEntries() <= 1) {
35 bool projectionsPassed =
true;
38 for (
int axis =
axisX; axis <=
axisY; ++axis) {
43 if (axis ==
axisX && href2d->GetNbinsY() != hnew2d->GetNbinsY()) {
44 std::cerr << HD->
getName() <<
" error: incorrect number of bins for X projection tests\n";
45 projectionsPassed =
false;
53 if (axis ==
axisY && href2d->GetNbinsX() != hnew2d->GetNbinsX()) {
54 std::cerr << HD->
getName() <<
" error: incorrect number of bins for Y projection tests\n";
55 projectionsPassed =
false;
60 int nBins = (axis ==
axisX) ? href2d->GetNbinsY() : href2d->GetNbinsX();
63 bool rebinned =
false;
67 href2d = (TH2F *)(((TH2F *)(href2d->Clone()))->RebinY(nGroups));
68 hnew2d = (TH2F *)(((TH2F *)(hnew2d->Clone()))->RebinY(nGroups));
69 nBins = href2d->GetNbinsY();
75 href2d = (TH2F *)(((TH2F *)(href2d->Clone()))->RebinX(nGroups));
76 hnew2d = (TH2F *)(((TH2F *)(hnew2d->Clone()))->RebinX(nGroups));
77 nBins = href2d->GetNbinsX();
86 TString projName = HD->
getName() + (axis ==
axisX ?
"_px" :
"_py");
88 TString newProjName =
"new_";
89 newProjName += projName;
90 TString refProjName =
"ref_";
91 refProjName += projName;
94 TH1D *hnew = (axis ==
axisX) ? hnew2d->ProjectionX(newProjName.Data(),
bin,
bin)
95 : hnew2d->ProjectionY(newProjName.Data(),
bin,
bin);
96 TH1D *
href = (axis ==
axisX) ? href2d->ProjectionX(refProjName.Data(),
bin,
bin)
97 : href2d->ProjectionY(refProjName.Data(),
bin,
bin);
100 hnew->GetXaxis()->SetTitle((axis ==
axisX ? hnew2d->GetXaxis()->GetTitle() : hnew2d->GetYaxis()->GetTitle()));
101 href->GetXaxis()->SetTitle((axis ==
axisX ? href2d->GetXaxis()->GetTitle() : href2d->GetYaxis()->GetTitle()));
104 hnew->SetBit(kCanDelete);
105 href->SetBit(kCanDelete);
113 if (hnew->GetEntries() <= 1 ||
href->GetEntries() <= 1 || hnew->Integral() == 0 ||
href->Integral() == 0)
117 projectionsPassed &= compare<Plot1D>(
proj);
120 float lowScore =
proj->getLowScore();
121 float highScore =
proj->getHighScore();
122 if (lowScore < HD->getLowScore())
142 return projectionsPassed;
146 void PlotCompareUtility::makePlots<Plot2D>(
HistoData *HD) {
155 std::vector<HistoData>::iterator hd;
157 makePlots<Plot1D>(&(*hd));
159 makePlots<Plot1D>(&(*hd));
162 for (
int axis =
axisX; axis <=
axisY; ++axis) {
165 if (
proj ==
nullptr ||
proj->empty())
173 int numHistos =
proj->size();
183 TCanvas projectionsCanvas(
184 "projectionsCanvas",
"projectionsCanvas", projectionsCanvasWidth, projectionsCanvasHeight);
185 projectionsCanvas.SetFrameFillColor(10);
186 projectionsCanvas.SetLogy(1);
191 projectionsCanvas.Draw();
194 TH1F projectionsSummary(
195 "projectionsSummary",
"Compatibility with Reference Histograms", numHistos, 1, numHistos + 1);
196 projectionsSummary.GetYaxis()->SetRangeUser(
getThreshold() / 10, 2);
197 projectionsSummary.SetStats(
false);
200 projectionsSummary.Draw(
"AH");
203 float xMin = hnew2d->GetXaxis()->GetXmin();
204 float xMax = hnew2d->GetXaxis()->GetXmax();
205 int ticksNDiv = numHistos * 20 + bodyWidth / 50;
206 TGaxis *
xAxis =
new TGaxis(1, 0, numHistos + 1, 0,
xMin,
xMax, ticksNDiv,
"");
208 xAxis->SetTitle(hnew2d->GetYaxis()->GetTitle());
210 xAxis->SetTitle(hnew2d->GetXaxis()->GetTitle());
217 yAxis->SetTitle(
"Compatibility");
221 std::vector<HistoData>::iterator pd;
222 for (pd =
proj->begin(); pd !=
proj->end(); pd++)
223 pd->drawResult(&projectionsSummary,
true,
false);
227 passLine.SetLineColor(kRed);
228 passLine.SetLineWidth(2);
229 passLine.SetLineStyle(2);
230 passLine.Draw(
"SAME");
234 projectionsCanvas.Print(gifName.c_str());
240 TH1D *
href = (axis ==
axisX) ? href2d->ProjectionY(refBinsProj.c_str()) : href2d->ProjectionX(refBinsProj.c_str());
241 TH1D *hnew = (axis ==
axisX) ? hnew2d->ProjectionY(newBinsProj.c_str()) : hnew2d->ProjectionX(newBinsProj.c_str());
244 href->SetBit(kCanDelete);
245 hnew->SetBit(kCanDelete);
253 makePlots<Plot1D>(&allBins);
262 if (currentTarget.empty() || (axis ==
axisY && currentTarget == xImgTarget))
340 void PlotCompareUtility::makeHTML<Plot2D>(
HistoData *HD) {
353 bool pfDone[2] = {
false,
false};
354 for (
int axis =
axisX; axis <=
axisY; axis++) {
357 if (
proj ==
nullptr ||
proj->empty())
363 std::string gifNameProjections =
Name + (axis ==
axisX ?
"_Results_px.gif" :
"_Results_py.gif");
374 int rightThumbPos = leftThumbPos + bodyWidth / 2;
379 std::ofstream
fout(htmlNameProfile.c_str());
382 fout <<
"<!DOCTYPE gif PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>" << std::endl
383 <<
"<html>" << std::endl
384 <<
" <head>" << std::endl
385 <<
" <title>Compatibility of Projections for " << HD->
getRefHisto()->GetTitle() <<
"</title>" << std::endl
386 <<
" <script type='text/javascript'>" << std::endl
388 <<
" function tn(target,image,class) {" << std::endl
389 <<
" clear()" << std::endl
391 "document.getElementById('thumb_div').setAttribute('class',class)"
394 "document.getElementById('thumb_div').setAttribute('className',"
397 <<
" document.getElementById('thumb_link').href = target" << std::endl
398 <<
" document.getElementById('thumb_img').src = image" << std::endl
399 <<
" document.getElementById('thumb_img').width = '" << thumbWidth <<
"'" << std::endl
400 <<
" document.getElementById('thumb_img').height = '" << thumbHeight <<
"'" << std::endl
401 <<
" document.getElementById('thumb_img').border = '1'" << std::endl
404 <<
" function clear() {" << std::endl
405 <<
" document.getElementById('thumb_link').href = '#'" << std::endl
406 <<
" document.getElementById('thumb_img').src = ''" << std::endl
407 <<
" document.getElementById('thumb_img').width = '0'" << std::endl
408 <<
" document.getElementById('thumb_img').height = '0'" << std::endl
409 <<
" document.getElementById('thumb_img').border = '0'" << std::endl
412 <<
" </script>" << std::endl
413 <<
" </head>" << std::endl
414 <<
" <body onClick=\"window.location.href='index.html'\">"
417 <<
" <style type='text/css'>" << std::endl
418 <<
" #thumb_div {}" << std::endl
419 <<
" div.thumb_left {position: absolute; left: " << leftThumbPos <<
"px; top: " << thumbsLoc <<
"px;}"
421 <<
" div.thumb_right {position: absolute; left: " << rightThumbPos <<
"px; top: " << thumbsLoc <<
"px;}"
423 <<
" #main_d {position: absolute; left: " <<
offset <<
"px;}" << std::endl
424 <<
" a:link {color: #000000}" << std::endl
425 <<
" a:visited {color: #000000}" << std::endl
426 <<
" a:hover {color: #000000}" << std::endl
427 <<
" a:active {color: #000000}" << std::endl
428 <<
" </style>" << std::endl
429 <<
" <div id='main_d'>"
433 <<
" <img src='" << gifNameProjections <<
"' usemap='#results' alt=''"
435 <<
" <map id='#results' name='results' onMouseOut=\"clear()\">" << std::endl;
438 std::vector<HistoData>::iterator pd;
439 for (pd =
proj->begin(); pd !=
proj->end(); pd++) {
441 int bin = pd->getBin();
451 fout <<
" <area shape='rect' alt='' coords='" <<
x1 <<
"," <<
y1 <<
"," <<
x2 <<
"," <<
y2 <<
"'"
452 <<
" href='" <<
target <<
"' onMouseOver=\"tn('" <<
target <<
"','" << image <<
"','" << tnClass <<
"')\" "
453 <<
"onMouseDown=\"window.location.href='" <<
target <<
"'\">" << std::endl;
456 fout <<
" <area shape='default' nohref='nohref' "
457 "onMouseDown='window.location.reload()' alt=''>"
459 <<
" </map>" << std::endl
460 <<
" <br><img src=\"" << gifNameAllProj <<
"\">" << std::endl
461 <<
" </div>" << std::endl
462 <<
" <div id='thumb_div'><a href='#' id='thumb_link'><img src='' "
463 "id='thumb_img' width=0 height=0 border=0></a></div>"
466 <<
" </body>" << std::endl
467 <<
"</html>" << std::endl;
481 fout <<
"<html>" << std::endl
482 <<
" <frameset rows=\"50%,50%\">" << std::endl
483 <<
" <frame src=\"" <<
Name <<
"_Results_py.html\">" << std::endl
484 <<
" <frame src=\"" <<
Name <<
"_Results_px.html\">" << std::endl
485 <<
" <noframes><body>" << std::endl
486 <<
" unable to display frames -- click to select desired page" << std::endl
487 <<
" <br><a href =\"" <<
Name <<
"_Results_py.html\">Y Projections</a>" << std::endl
488 <<
" <br><a href =\"" <<
Name <<
"_Results_px.html\">X Projections</a>" << std::endl
489 <<
" </body></noframes>" << std::endl
490 <<
" </frameset>" << std::endl
491 <<
"</html>" << std::endl;