当前位置: 首页>>代码示例>>C++>>正文


C++ RooDataSet::write方法代码示例

本文整理汇总了C++中RooDataSet::write方法的典型用法代码示例。如果您正苦于以下问题:C++ RooDataSet::write方法的具体用法?C++ RooDataSet::write怎么用?C++ RooDataSet::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RooDataSet的用法示例。


在下文中一共展示了RooDataSet::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ZeeGammaMassFitSystematicStudy


//.........这里部分代码省略.........
  mframeFail_default->GetXaxis()->SetTitle("m_{ee#gamma} [GeV/c^{2}]");
  mframeFail_default->GetXaxis()->SetTitleOffset(1.05);
  mframeFail_default->SetTitle("");
  mframeFail_default->Draw();

  cv->SaveAs("DefaultModel.gif");

  RooPlot *mframeFail = m_default->frame(Bins(Int_t(130-60)/2));
  modelFail->plotOn(mframeFail);
  modelFail->plotOn(mframeFail,Components("ebackgroundFail_shifted"),LineStyle(kDashed),LineColor(kRed));
  modelFail->plotOn(mframeFail,Components("bkgexpFail_shifted"),LineStyle(kDashed),LineColor(kGreen+2));
  mframeFail->GetYaxis()->SetTitle("");
  mframeFail->GetYaxis()->SetTitleOffset(1.2);
  mframeFail->GetXaxis()->SetTitle("m_{ee#gamma} [GeV/c^{2}]");
  mframeFail->GetXaxis()->SetTitleOffset(1.05);
  mframeFail->SetTitle("");
  mframeFail->Draw();
  cv->SaveAs(Form("ShiftedModel_%d.gif",Option));


  //*************************************************************************************
  //Do Toys
  //*************************************************************************************
  for(uint t=0; t < NToys; ++t) {

    RooDataSet *pseudoData_pass    = modelPass_default->generate(*m_default, randomnumber->Poisson(npass));
    RooDataSet *pseudoData_fail  = 0;
    pseudoData_fail    = modelFail->generate(*m_default, randomnumber->Poisson(nfail));
    RooDataSet *pseudoDataCombined = new RooDataSet("pseudoDataCombined","pseudoDataCombined",RooArgList(*m_default),
                                                    RooFit::Index(sample),
                                                    RooFit::Import("Pass",*pseudoData_pass),
                                                    RooFit::Import("Fail",*pseudoData_fail));

    pseudoDataCombined->write(Form("toy%d.txt",t));

    RooFitResult *fitResult=0;
    fitResult = totalPdf->fitTo(*pseudoDataCombined,
                                RooFit::Extended(),
                                RooFit::Strategy(2),
                                //RooFit::Minos(RooArgSet(eff)),
                                RooFit::Save());

    cout << "\n\n";
    cout << "Eff Fit: " << eff->getVal() << " -" << fabs(eff->getErrorLo()) << " +" << eff->getErrorHi() << endl;

    //Fill Tree
    varEff = eff->getVal();
    varEffErrL = fabs(eff->getErrorLo());
    varEffErrH = eff->getErrorHi();
    outTree->Fill();


//   //*************************************************************************************
//   //Plot Toys
//   //*************************************************************************************
//   TCanvas *cv = new TCanvas("cv","cv",800,600);
//   char pname[50];
//   char binlabelx[100];
//   char binlabely[100];
//   char yield[50];
//   char effstr[100];
//   char nsigstr[100];
//   char nbkgstr[100];
//   char chi2str[100];

//   //
开发者ID:sixie,项目名称:HiggsAna,代码行数:67,代码来源:ZeeGammaMassFitSystematicStudy.C

示例2: gen

void gen(Int_t iToy, Int_t qSqBin){
    TString namestr("toy/toy_"); namestr+=iToy; namestr+="_"; namestr+=qSqBin; namestr+=".dat";

    Double_t bkgMin(5400), bkgMax(5970);

    TString bkgStr="Bplus_M > "; bkgStr+=bkgMin; bkgStr+=" && Bplus_M < "; bkgStr+=bkgMax;

    TFile * file(0);
    TTree * DecayTree(0);
    RooRealVar * cosTheta(0);
    RooRealVar * Bplus_M(0);
    RooDataSet * data(0);
   
    TString fname("~/lhcb/rd/Kll/tuples/fromPatrick/Kmm_Q"); fname+=qSqBin; fname+="_reduced.root";
    file = TFile::Open(fname);
    DecayTree = dynamic_cast<TTree*>(file->Get("finalTree_KMuMu"));
    cosTheta = new RooRealVar("cosThetaL", "cosThetaL", -1., 1.);
    Bplus_M  = new RooRealVar("Bplus_M", "Bplus_M", 5170., 5970.);
    data = new RooDataSet("data", "", DecayTree, RooArgList(*cosTheta,*Bplus_M));

    RooDataSet* data2 = dynamic_cast<RooDataSet*>(data->reduce(bkgStr));
    RooKeysPdf bkg("bkg","bkg",*cosTheta,*data2);

    Double_t g0, g1, g2, g3, g4, g5, g6, va, vb, ignore;
    Int_t nsig, nbkg;

    std::ifstream fin;

    //load efficiency parameters
    fin.open("../efficiencies/effParams_PIDonly_fixB_50.txt");
    Int_t row(0);
    fin >> row;
    while(row!=qSqBin) {
	    fin.ignore(256,'\n');
	    fin >> row;
    }
    fin >> ignore >> ignore >> va >> ignore >> vb >> ignore;
    std::cout << va << "\t" << vb << std::endl;

    fin.close();

    //load moments parameters
    fin.open("../MoM/moments.dat");
    fin >> row;
    while(row!=qSqBin) {
	    fin.ignore(256,'\n');
	    fin >> row;
    }
    fin >> g0 >> g1 >> g2 >> g3 >> g4 >> g5 >> g6;
    std::cout << g0 << "\t" << g1 << "\t" << g2 << "\t" << g3 << "\t" << g4 << "\t" << g5 << "\t" << g6 << std::endl;

    fin.close();

    //load sig/bkg yields
    TString yieldsname("../massFit/yields/"); yieldsname+= qSqBin; yieldsname+= ".dat";
    fin.open(yieldsname);
    fin >> nsig >> ignore >> nbkg;
    std::cout << nsig << "\t" << nbkg << std::endl;

    fin.close();

    RooRealVar G000("G000", "G000",  g0);
    RooRealVar G001("G001", "G001",  g1);
    RooRealVar G002("G002", "G002",  g2);
    RooRealVar G003("G003", "G003",  g3);
    RooRealVar G004("G004", "G004",  g4);
    RooRealVar G005("G005", "G005",  g5);
    RooRealVar G006("G006", "G006",  g6);
    RooRealVar    a("a",    "a",     va);
    RooRealVar    b("b",    "b",     vb);
    RooRealVar    n("n",    "n",    1.0);

    RooB2Kll sig("sig", "sig", *cosTheta, G000, G001, G002, G003, G004, G005, G006, a, b, n);

    TString vetoHistName("efficiencyHist_");
    vetoHistName+=qSqBin;
    TFile * fileK1 = TFile::Open("../efficiencies/Dveto_200.root");
    TH1D  * histK1  = dynamic_cast<TH1D*>(fileK1->Get(vetoHistName));
    RooDataHist * dataK1 = new RooDataHist("dataK1", "", RooArgSet(*cosTheta), histK1);
    RooHistPdf DVeto("DVeto","", RooArgSet(*cosTheta), *dataK1, 2);

    TFile * fileK2 = TFile::Open("../efficiencies/Psiveto_200.root");
    TH1D  * histK2  = dynamic_cast<TH1D*>(fileK2->Get(vetoHistName));
    RooDataHist * dataK2 = new RooDataHist("dataK2", "", RooArgSet(*cosTheta), histK2);
    RooHistPdf PsiVeto("PsiVeto","", RooArgSet(*cosTheta), *dataK2, 2);

    RooProdPdf sigeff("sigeff","sigeff", RooArgList(sig,DVeto,PsiVeto));

//    RooAddPdf pdf("pdf","pdf",RooArgList(sig,bkg), RooArgList(nsig,nbkg));
//    RooAddPdf pdfeff("pdfeff","pdfeff",RooArgList(sigeff,bkg), RooArgList(nsig,nbkg));

    RooRandom::randomGenerator()->SetSeed(iToy);

    RooDataSet * genData  = sigeff.generate(RooArgSet(*cosTheta), nsig);
//    RooDataSet * genData2 = bkg.generate(RooArgSet(*cosTheta), nsig);
//    genData->append(*genData2);
    genData->write(namestr);

    file->Close();
    fileK1->Close();
//.........这里部分代码省略.........
开发者ID:dcraik,项目名称:lhcb,代码行数:101,代码来源:gen.C


注:本文中的RooDataSet::write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。