18 bool PlotCompareUtility::compare<Plot1D>(
HistoData *HD) {
20 TH1F *
href = (TH1F *)HD->getRefHisto();
21 TH1F *hnew = (TH1F *)HD->getNewHisto();
24 if (hnew ==
nullptr || href ==
nullptr || hnew->GetEntries() <= 1 || href->GetEntries() <= 1) {
32 if (HD->getDoAllow1DRebinning())
33 centerRebin(href, hnew);
36 double ksScore = hnew->KolmogorovTest(href,
"D");
37 double chi2Score = hnew->Chi2Test(href,
"uup");
40 renormalize(href, hnew);
43 HD->setKSScore(ksScore);
44 HD->setChi2Score(chi2Score);
46 HD->setLowScore(ksScore < chi2Score ? ksScore : chi2Score);
47 HD->setHighScore(ksScore > chi2Score ? ksScore : chi2Score);
48 }
else if (ksThreshold > 0) {
49 HD->setLowScore(ksScore);
50 HD->setHighScore(ksScore);
52 HD->setLowScore(chi2Score);
53 HD->setHighScore(chi2Score);
55 std::cerr <<
"error: no test performed? chi2Threshold and ksThreshold <= 0\n";
59 HD->setResult(passed);
62 HD->setIsEmpty(
false);
67 void PlotCompareUtility::makePlots<Plot1D>(
HistoData *HD) {
68 std::cerr << HD->getName() <<
"makePlots<Plot1D>\n";
71 if (HD->getIsEmpty()) {
72 HD->setResultImage(
"NoData_Results.gif");
73 HD->setResultTarget(
"NoData_Results.gif");
78 TH1F *
href = (TH1F *)HD->getRefHisto();
79 TH1F *hnew = (TH1F *)HD->getNewHisto();
82 href->SetStats(
false);
83 href->SetLineWidth(2);
84 href->SetLineColor(14);
85 href->SetMarkerColor(14);
86 href->SetFillColor(18);
89 hnew->SetStats(
false);
90 hnew->SetLineWidth(2);
91 hnew->SetLineColor(HD->getShadedLineColor());
92 hnew->SetFillStyle(HD->getShadedFillStyle());
93 hnew->SetFillColor(HD->getShadedFillColor());
96 TString
title = HD->getName();
97 if (ksThreshold > 0) {
98 title +=
" KS Score = ";
99 title += HD->getKSScore();
102 title +=
" Chi^2 Score = ";
103 title += HD->getChi2Score();
108 int plotsCanvasWidth = plotsWidth + 4;
109 int plotsCanvasHeight = plotsHeight + 28;
112 TCanvas hCanvas(
"hCanvas",
"hCanvas", plotsCanvasWidth, plotsCanvasHeight);
113 hCanvas.SetTopMargin(
float(plotsTopMargin) / plotsHeight);
114 hCanvas.SetLeftMargin(
float(plotsLeftMargin) / plotsWidth);
115 hCanvas.SetRightMargin(
float(plotsRightMargin) / plotsWidth);
116 hCanvas.SetBottomMargin(
float(plotsBottomMargin) / plotsHeight);
117 hCanvas.SetFrameFillColor(10);
122 TText canvasTitle(0.1, 0.97, title.Data());
123 canvasTitle.Draw(
"SAME");
128 if (HD->getDoDrawErrorBars())
129 hnew->Draw(
"E1SAME");
132 TLegend
legend(0.15, 0.01, 0.3, 0.08);
133 legend.AddEntry(hnew,
"New",
"lF");
134 legend.AddEntry(href,
"Reference",
"lF");
135 legend.SetFillColor(
kNone);
139 std::string gifName = HD->getName() +
"_Results.gif";
140 if (HD->getResultImage().empty())
141 HD->setResultImage(gifName);
142 if (HD->getResultTarget().empty())
143 HD->setResultTarget(gifName);
144 std::cerr <<
"About to print" << gifName <<
"\n";
145 hCanvas.Print(gifName.c_str());
149 void PlotCompareUtility::makeHTML<Plot1D>(
HistoData *HD) {