本文整理汇总了C++中TH1D::KolmogorovTest方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1D::KolmogorovTest方法的具体用法?C++ TH1D::KolmogorovTest怎么用?C++ TH1D::KolmogorovTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1D
的用法示例。
在下文中一共展示了TH1D::KolmogorovTest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chi2
void chi2(int xmin = 0, int xmax = 200, TString filename="../DsubMC/met2j0bIso2ewkScale_0_200.root", int nparam = 2){
RooAbsData::ErrorType errorType = RooAbsData::SumW2;
file = new TFile(filename);
RooRealVar* h = new RooRealVar("h","h",xmin,xmax);
//Get Data
TH1D* hData = file->Get("dataih");
hData->SetName("hData");
//hData->Draw();
RooDataHist* data = new RooDataHist("data","data",*h,hData);
//Get Summed MC
TH1D* hMC = file->Get("hh");
hMC->SetName("hMC");
hMC->Draw();
RooDataHist rdhMC("MC","MC",*h,hMC);
RooHistPdf pdfMC("MCpdf","MCpdf",*h,rdhMC);
//make (plot) the curves
RooPlot* hFrame = h->frame(Name("hFrame"));
data->plotOn(hFrame,RooFit::DataError(errorType));
pdfMC.plotOn(hFrame,ProjWData(*data),Components(pdfMC),Name("h_total"));
//Determine Chi^2
double chi2fit = hFrame->chiSquare("h_total", "h_data", nparam);
cout<<"Chi 2 / dof: "<<chi2fit<<endl;
//Determine K-S
double ks = hMC->KolmogorovTest(hData);
cout<<"Kolmogorov-Smirnov: "<<ks<<endl;
}
示例2: fitWm
//.........这里部分代码省略.........
plotAntiMetmDiff.SetYRange(-8,8);
plotAntiMetmDiff.AddLine(0, 0,METMAX, 0,kBlack,1);
plotAntiMetmDiff.AddLine(0, 5,METMAX, 5,kBlack,3);
plotAntiMetmDiff.AddLine(0,-5,METMAX,-5,kBlack,3);
plotAntiMetmDiff.Draw(c,kTRUE,format,2);
plotAntiMetm.SetName("fitantimetmlog");
plotAntiMetm.SetLogy();
plotAntiMetm.SetYRange(1e-3*(hAntiDataMetm->GetMaximum()),10*(hAntiDataMetm->GetMaximum()));
plotAntiMetm.Draw(c,kTRUE,format,1);
//--------------------------------------------------------------------------------------------------------------
// Output
//==============================================================================================================
cout << "*" << endl;
cout << "* SUMMARY" << endl;
cout << "*--------------------------------------------------" << endl;
//
// Write fit results
//
ofstream txtfile;
char txtfname[100];
ios_base::fmtflags flags;
Double_t chi2prob, chi2ndf;
Double_t ksprob, ksprobpe;
chi2prob = hDataMet->Chi2Test(hPdfMet,"PUW");
chi2ndf = hDataMet->Chi2Test(hPdfMet,"CHI2/NDFUW");
ksprob = hDataMet->KolmogorovTest(hPdfMet);
ksprobpe = hDataMet->KolmogorovTest(hPdfMet,"DX");
sprintf(txtfname,"%s/fitresWm.txt",CPlot::sOutDir.Data());
txtfile.open(txtfname);
assert(txtfile.is_open());
flags = txtfile.flags();
txtfile << setprecision(10);
txtfile << " *** Yields *** " << endl;
txtfile << "Selected: " << hDataMet->Integral() << endl;
txtfile << " Signal: " << nSig.getVal() << " +/- " << nSig.getPropagatedError(*fitRes) << endl;
txtfile << " QCD: " << nQCD.getVal() << " +/- " << nQCD.getPropagatedError(*fitRes) << endl;
txtfile << " Other: " << nEWK.getVal() << " +/- " << nEWK.getPropagatedError(*fitRes) << endl;
txtfile << endl;
txtfile.flags(flags);
fitRes->printStream(txtfile,RooPrintable::kValue,RooPrintable::kVerbose);
txtfile << endl;
printCorrelations(txtfile, fitRes);
txtfile << endl;
printChi2AndKSResults(txtfile, chi2prob, chi2ndf, ksprob, ksprobpe);
txtfile.close();
chi2prob = hDataMetp->Chi2Test(hPdfMetp,"PUW");
chi2ndf = hDataMetp->Chi2Test(hPdfMetp,"CHI2/NDFUW");
ksprob = hDataMetp->KolmogorovTest(hPdfMetp);
ksprobpe = hDataMetp->KolmogorovTest(hPdfMetp,"DX");
sprintf(txtfname,"%s/fitresWmp.txt",CPlot::sOutDir.Data());
txtfile.open(txtfname);
assert(txtfile.is_open());
flags = txtfile.flags();
txtfile << setprecision(10);
示例3: fitWe
//.........这里部分代码省略.........
plotMetmDiff.SetYRange(-8,8);
plotMetmDiff.AddLine(0, 0,METMAX, 0,kBlack,1);
plotMetmDiff.AddLine(0, 5,METMAX, 5,kBlack,3);
plotMetmDiff.AddLine(0,-5,METMAX,-5,kBlack,3);
plotMetmDiff.Draw(c,kTRUE,format,2);
plotMetm.SetName("fitmetmlog");
plotMetm.SetLogy();
plotMetm.SetYRange(1e-3*(hDataMetm->GetMaximum()),10*(hDataMetm->GetMaximum()));
plotMetm.Draw(c,kTRUE,format,1);
//--------------------------------------------------------------------------------------------------------------
// Output
//==============================================================================================================
cout << "*" << endl;
cout << "* SUMMARY" << endl;
cout << "*--------------------------------------------------" << endl;
//
// Write fit results
//
ofstream txtfile;
char txtfname[100];
ios_base::fmtflags flags;
Double_t chi2prob, chi2ndf;
Double_t ksprob, ksprobpe;
chi2prob = hDataMet->Chi2Test(hPdfMet,"PUW");
chi2ndf = hDataMet->Chi2Test(hPdfMet,"CHI2/NDFUW");
ksprob = hDataMet->KolmogorovTest(hPdfMet);
ksprobpe = hDataMet->KolmogorovTest(hPdfMet,"DX");
sprintf(txtfname,"%s/fitresWe.txt",CPlot::sOutDir.Data());
txtfile.open(txtfname);
assert(txtfile.is_open());
flags = txtfile.flags();
txtfile << setprecision(10);
txtfile << " *** Yields *** " << endl;
txtfile << "Selected: " << hDataMet->Integral() << endl;
txtfile << " Signal: " << nSig.getVal() << " +/- " << nSig.getPropagatedError(*fitRes) << endl;
txtfile << " QCD: " << nQCD.getVal() << " +/- " << nQCD.getPropagatedError(*fitRes) << endl;
txtfile << " Other: " << nEWK.getVal() << " +/- " << nEWK.getPropagatedError(*fitRes) << endl;
txtfile << endl;
txtfile.flags(flags);
fitRes->printStream(txtfile,RooPrintable::kValue,RooPrintable::kVerbose);
txtfile << endl;
printCorrelations(txtfile, fitRes);
txtfile << endl;
printChi2AndKSResults(txtfile, chi2prob, chi2ndf, ksprob, ksprobpe);
txtfile.close();
chi2prob = hDataMetp->Chi2Test(hPdfMetp,"PUW");
chi2ndf = hDataMetp->Chi2Test(hPdfMetp,"CHI2/NDFUW");
ksprob = hDataMetp->KolmogorovTest(hPdfMetp);
ksprobpe = hDataMetp->KolmogorovTest(hPdfMetp,"DX");
sprintf(txtfname,"%s/fitresWep.txt",CPlot::sOutDir.Data());
txtfile.open(txtfname);
assert(txtfile.is_open());
flags = txtfile.flags();
txtfile << setprecision(10);
示例4: mdpBinsOfMet
//.........这里部分代码省略.........
Hlow->SetYTitle(ytitle);
//TString thetitle=btag.GetTitle();
TString thetitle="";
// thetitle += " (fail minDeltaPhi)";
Hhigh->SetTitle(thetitle);
Hmh->SetTitle(thetitle);
Hmed->SetTitle(thetitle);
Hlow->SetTitle(thetitle);
TString drawopt="hist e";
if (drawSIG) {Hhigh->Draw(drawopt); drawopt="hist e SAME"; if (customMax>0) Hhigh->SetMaximum(customMax);}
if (drawSB) {Hmh->Draw(drawopt); drawopt="hist e SAME"; if (customMax>0) Hmh->SetMaximum(customMax);}
if (drawMSB) {Hmed->Draw(drawopt); drawopt="hist e SAME"; if (customMax>0) Hmed->SetMaximum(customMax);}
if (drawLSB) {Hlow->Draw(drawopt); drawopt="hist e SAME"; if (customMax>0) Hlow->SetMaximum(customMax);}
// if (var=="minDeltaPhi") {
// Hhigh->SetMinimum(0);
// Hhigh->GetXaxis()->SetRangeUser(0,2);
// }
TLegend * leg = 0;
if(logy) leg = new TLegend(0.38,0.65,0.8,0.85);
else {leg = new TLegend(0.38,0.55,0.8,0.85);}
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetLineStyle(0);
leg->SetFillStyle(0);
leg->SetTextFont(132);
leg->SetTextSize(.04);
if(logy) leg->SetTextSize(0.03);
char label[100];
if (drawLSB) {
sprintf(label,"E_{T}^{miss} < 75 GeV (#mu=%3.2f)",Hlow->GetMean());
leg->AddEntry(Hlow,label);
}
if (drawMSB) {
sprintf(label,"75 < E_{T}^{miss} < 150 GeV (#mu=%3.2f)",Hmed->GetMean());
leg->AddEntry(Hmed,label);
}
if (drawSB) {
sprintf(label,"150 < E_{T}^{miss} < 225 Ge (#mu=%3.2f)",Hmh->GetMean());
leg->AddEntry(Hmh,label);
}
if (drawSIG) {
sprintf(label,"E_{T}^{miss} > 225 GeV (#mu=%3.2f)",Hhigh->GetMean());
leg->AddEntry(Hhigh,label);
}
leg->Draw();
// TLatex* text1=0;
// text1 = new TLatex(3.570061,23.08044,"CMS Simulation");
// text1->SetNDC();
// text1->SetTextAlign(13);
// text1->SetX(0.45);
// text1->SetY(.9);
// text1->SetTextFont(132);
// text1->SetTextSizePixels(24);
// text1->Draw();
if (doRatio) {
Hratio->Divide(Hmh,Hlow);
Hratio->SetLineWidth(2);
thecanvas->cd(2);
Hratio->Draw();
Hratio->SetMinimum(0);
Hratio->SetMaximum(3);
TLine* l1 = new TLine(min,1,max,1);
l1->SetLineColor(kMagenta);
l1->SetLineWidth(2);
l1->Draw();
cout<<"KS test results = "<<Hmh->KolmogorovTest(Hlow)<<endl;
}
// double chi2=0;
// for (int i=1; i<=nbins; i++) {
// double denom=Hlow->GetBinError(i)*Hlow->GetBinError(i) + Hmh->GetBinError(i)*Hmh->GetBinError(i);
// double c2= denom>0 ? pow( Hlow->GetBinContent(i) - Hmh->GetBinContent(i) ,2) / denom : 0;
// chi2+=c2;
// }
// cout<<"Hand chi^2 = "<<chi2<<endl;
// Hlow->Chi2Test(Hmh,"WW p");
if (plotTitle=="") {
if(logy) {thecanvas->Print("macros/qcd_control/plots/METcorrelation_"+var+"_logy.png");thecanvas->Print("macros/qcd_control/plots/METcorrelation_"+var+"_logy.pdf");}
else {thecanvas->Print("macros/qcd_control/plots/METcorrelation_"+var+".png"); thecanvas->Print("macros/qcd_control/plots/METcorrelation_"+var+".pdf"); }
}
else {
if(logy) {thecanvas->Print("macros/qcd_control/plots/"+plotTitle+"_logy.png");thecanvas->Print("macros/qcd_control/plots/"+plotTitle+"_logy.pdf");}
else {thecanvas->Print("macros/qcd_control/plots/"+plotTitle+".png"); thecanvas->Print("macros/qcd_control/plots/"+plotTitle+".pdf"); }
}
delete pypu;
delete Hlow;
delete Hmed;
delete Hmh;
delete Hhigh;
delete Hratio;
delete thecanvas;
}