18 bool PlotCompareUtility::compare<Plot1D>(
HistoData *HD) {
21 TH1F *href = (TH1F *)HD->getRefHisto();
22 TH1F *hnew = (TH1F *)HD->getNewHisto();
25 if (hnew ==
NULL || href ==
NULL || hnew->GetEntries() <= 1 || href->GetEntries() <= 1) {
27 HD->setIsEmpty(
true);
return false;
31 if (HD->getDoAllow1DRebinning()) centerRebin(href,hnew);
34 double ksScore = hnew->KolmogorovTest(href,
"D");
35 double chi2Score = hnew->Chi2Test(href,
"uup");
38 renormalize(href,hnew);
41 HD->setKSScore(ksScore); HD->setChi2Score(chi2Score);
42 if (ksThreshold > 0 && chi2Threshold > 0) {
43 HD->setLowScore(ksScore < chi2Score ? ksScore : chi2Score);
44 HD->setHighScore(ksScore > chi2Score ? ksScore : chi2Score);
46 else if (ksThreshold > 0) { HD->setLowScore(ksScore); HD->setHighScore(ksScore); }
47 else if (chi2Threshold > 0) { HD->setLowScore(chi2Score); HD->setHighScore(chi2Score); }
48 else std::cerr <<
"error: no test performed? chi2Threshold and ksThreshold <= 0\n";
51 bool passed = (ksScore >= ksThreshold && chi2Score >= chi2Threshold);
52 HD->setResult(passed);
55 HD->setIsEmpty(
false);
61 void PlotCompareUtility::makePlots<Plot1D>(
HistoData *HD) {
63 std::cerr << HD->getName() <<
"makePlots<Plot1D>\n";
66 if (HD->getIsEmpty()) {
67 HD->setResultImage(
"NoData_Results.gif");
68 HD->setResultTarget(
"NoData_Results.gif");
73 TH1F *href = (TH1F *)HD->getRefHisto();
74 TH1F *hnew = (TH1F *)HD->getNewHisto();
78 href->SetLineWidth(2);
79 href->SetLineColor(14);
80 href->SetMarkerColor(14);
81 href->SetFillColor(18);
85 hnew->SetLineWidth(2);
86 hnew->SetLineColor(HD->getShadedLineColor());
87 hnew->SetFillStyle(HD->getShadedFillStyle());
88 hnew->SetFillColor(HD->getShadedFillColor());
91 TString
title = HD->getName();
92 if (ksThreshold > 0) {title +=
" KS Score = "; title += HD->getKSScore();}
93 if (chi2Threshold > 0) { title +=
" Chi^2 Score = "; title += HD->getChi2Score();}
96 int plotsCanvasWidth = plotsWidth + 4;
97 int plotsCanvasHeight = plotsHeight + 28;
100 TCanvas hCanvas(
"hCanvas",
"hCanvas",plotsCanvasWidth,plotsCanvasHeight);
101 hCanvas.SetTopMargin(
float(plotsTopMargin) / plotsHeight);
102 hCanvas.SetLeftMargin(
float(plotsLeftMargin) / plotsWidth);
103 hCanvas.SetRightMargin(
float(plotsRightMargin) / plotsWidth);
104 hCanvas.SetBottomMargin(
float(plotsBottomMargin) / plotsHeight);
105 hCanvas.SetFrameFillColor(10);
110 TText canvasTitle(0.1,0.97,title.Data());
111 canvasTitle.Draw(
"SAME");
116 if (HD->getDoDrawErrorBars()) hnew->Draw(
"E1SAME");
119 TLegend
legend(0.15,0.01,0.3, 0.08);
120 legend.AddEntry(hnew,
"New",
"lF");
121 legend.AddEntry(href,
"Reference",
"lF");
122 legend.SetFillColor(
kNone);
126 std::string gifName = HD->getName() +
"_Results.gif";
127 if (HD->getResultImage() ==
"") HD->setResultImage(gifName);
128 if (HD->getResultTarget() ==
"") HD->setResultTarget(gifName);
129 std::cerr <<
"About to print" << gifName <<
"\n";
130 hCanvas.Print(gifName.c_str());
135 void PlotCompareUtility::makeHTML<Plot1D>(
HistoData *HD) {