本文整理汇总了C++中RooDataSet::GetTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ RooDataSet::GetTitle方法的具体用法?C++ RooDataSet::GetTitle怎么用?C++ RooDataSet::GetTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooDataSet
的用法示例。
在下文中一共展示了RooDataSet::GetTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rf403_weightedevts
void rf403_weightedevts()
{
// C r e a t e o b s e r v a b l e a n d u n w e i g h t e d d a t a s e t
// -------------------------------------------------------------------------------
// Declare observable
RooRealVar x("x","x",-10,10) ;
x.setBins(40) ;
// Construction a uniform pdf
RooPolynomial p0("px","px",x) ;
// Sample 1000 events from pdf
RooDataSet* data = p0.generate(x,1000) ;
// C a l c u l a t e w e i g h t a n d m a k e d a t a s e t w e i g h t e d
// -----------------------------------------------------------------------------------
// Construct formula to calculate (fake) weight for events
RooFormulaVar wFunc("w","event weight","(x*x+10)",x) ;
// Add column with variable w to previously generated dataset
RooRealVar* w = (RooRealVar*) data->addColumn(wFunc) ;
// Dataset d is now a dataset with two observable (x,w) with 1000 entries
data->Print() ;
// Instruct dataset wdata in interpret w as event weight rather than as observable
RooDataSet wdata(data->GetName(),data->GetTitle(),data,*data->get(),0,w->GetName()) ;
// Dataset d is now a dataset with one observable (x) with 1000 entries and a sum of weights of ~430K
wdata.Print() ;
// U n b i n n e d M L f i t t o w e i g h t e d d a t a
// ---------------------------------------------------------------
// Construction quadratic polynomial pdf for fitting
RooRealVar a0("a0","a0",1) ;
RooRealVar a1("a1","a1",0,-1,1) ;
RooRealVar a2("a2","a2",1,0,10) ;
RooPolynomial p2("p2","p2",x,RooArgList(a0,a1,a2),0) ;
// Fit quadratic polynomial to weighted data
// NOTE: A plain Maximum likelihood fit to weighted data does in general
// NOT result in correct error estimates, unless individual
// event weights represent Poisson statistics themselves.
//
// Fit with 'wrong' errors
RooFitResult* r_ml_wgt = p2.fitTo(wdata,Save()) ;
// A first order correction to estimated parameter errors in an
// (unbinned) ML fit can be obtained by calculating the
// covariance matrix as
//
// V' = V C-1 V
//
// where V is the covariance matrix calculated from a fit
// to -logL = - sum [ w_i log f(x_i) ] and C is the covariance
// matrix calculated from -logL' = -sum [ w_i^2 log f(x_i) ]
// (i.e. the weights are applied squared)
//
// A fit in this mode can be performed as follows:
RooFitResult* r_ml_wgt_corr = p2.fitTo(wdata,Save(),SumW2Error(kTRUE)) ;
// P l o t w e i g h e d d a t a a n d f i t r e s u l t
// ---------------------------------------------------------------
// Construct plot frame
RooPlot* frame = x.frame(Title("Unbinned ML fit, binned chi^2 fit to weighted data")) ;
// Plot data using sum-of-weights-squared error rather than Poisson errors
wdata.plotOn(frame,DataError(RooAbsData::SumW2)) ;
// Overlay result of 2nd order polynomial fit to weighted data
p2.plotOn(frame) ;
// M L F i t o f p d f t o e q u i v a l e n t u n w e i g h t e d d a t a s e t
// -----------------------------------------------------------------------------------------
// Construct a pdf with the same shape as p0 after weighting
RooGenericPdf genPdf("genPdf","x*x+10",x) ;
// Sample a dataset with the same number of events as data
RooDataSet* data2 = genPdf.generate(x,1000) ;
// Sample a dataset with the same number of weights as data
RooDataSet* data3 = genPdf.generate(x,43000) ;
// Fit the 2nd order polynomial to both unweighted datasets and save the results for comparison
RooFitResult* r_ml_unw10 = p2.fitTo(*data2,Save()) ;
//.........这里部分代码省略.........
示例2: MakePlots
void MakePlots(RooWorkspace* ws){
// Here we make plots of the discriminating variable (invMass) after the fit
// and of the control variable (isolation) after unfolding with sPlot.
std::cout << "make plots" << std::endl;
// make our canvas
TCanvas* cdata = new TCanvas("sPlot","sPlot demo", 400, 600);
cdata->Divide(1,3);
// get what we need out of the workspace
RooAbsPdf* model = ws->pdf("model");
RooAbsPdf* zModel = ws->pdf("zModel");
RooAbsPdf* qcdModel = ws->pdf("qcdModel");
RooRealVar* isolation = ws->var("isolation");
RooRealVar* invMass = ws->var("invMass");
// note, we get the dataset with sWeights
RooDataSet* data = (RooDataSet*) ws->data("dataWithSWeights");
// this shouldn't be necessary, need to fix something with workspace
// do this to set parameters back to their fitted values.
model->fitTo(*data, Extended() );
//plot invMass for data with full model and individual componenets overlayed
// TCanvas* cdata = new TCanvas();
cdata->cd(1);
RooPlot* frame = invMass->frame() ;
data->plotOn(frame ) ;
model->plotOn(frame) ;
model->plotOn(frame,Components(*zModel),LineStyle(kDashed), LineColor(kRed)) ;
model->plotOn(frame,Components(*qcdModel),LineStyle(kDashed),LineColor(kGreen)) ;
frame->SetTitle("Fit of model to discriminating variable");
frame->Draw() ;
// Now use the sWeights to show isolation distribution for Z and QCD.
// The SPlot class can make this easier, but here we demonstrait in more
// detail how the sWeights are used. The SPlot class should make this
// very easy and needs some more development.
// Plot isolation for Z component.
// Do this by plotting all events weighted by the sWeight for the Z component.
// The SPlot class adds a new variable that has the name of the corresponding
// yield + "_sw".
cdata->cd(2);
// create weightfed data set
RooDataSet * dataw_z = new RooDataSet(data->GetName(),data->GetTitle(),data,*data->get(),0,"zYield_sw") ;
RooPlot* frame2 = isolation->frame() ;
dataw_z->plotOn(frame2, DataError(RooAbsData::SumW2) ) ;
frame2->SetTitle("isolation distribution for Z");
frame2->Draw() ;
// Plot isolation for QCD component.
// Eg. plot all events weighted by the sWeight for the QCD component.
// The SPlot class adds a new variable that has the name of the corresponding
// yield + "_sw".
cdata->cd(3);
RooDataSet * dataw_qcd = new RooDataSet(data->GetName(),data->GetTitle(),data,*data->get(),0,"qcdYield_sw") ;
RooPlot* frame3 = isolation->frame() ;
dataw_qcd->plotOn(frame3,DataError(RooAbsData::SumW2) ) ;
frame3->SetTitle("isolation distribution for QCD");
frame3->Draw() ;
// cdata->SaveAs("SPlot.gif");
}
示例3: ws_v03
void ws_v03()
{
gROOT->ProcessLine(".x ./mystyle.C");
TFile *f1 = new TFile("K1_1270/ws_K1_1270.root");
TFile *f2 = new TFile("K1_1400/ws_K1_1400.root");
TFile *f3 = new TFile("K2_1430/ws_K2_1430.root");
RooWorkspace* ws_K1_1270 = (RooWorkspace*) f1->Get("ws_K1_1270");
RooWorkspace* ws_K1_1400 = (RooWorkspace*) f2->Get("ws_K1_1400");
RooWorkspace* ws_K2_1430 = (RooWorkspace*) f3->Get("ws_K2_1430");
ws_K1_1270->Print();
ws_K1_1400->Print();
ws_K2_1430->Print();
// Importing variables from workspaces
RooRealVar* m_Kpipi = ws_K1_1270 -> var("m_Kpipi");
RooAbsPdf* totalPdf_K1_1270 = ws_K1_1270 -> pdf("totalPdf_K1_1270");
RooAbsData* data_K1_1270 = ws_K1_1270 -> data("totalPdf_K1_1270Data");
RooHistPdf* pdf_K1_1270_to_Krho = ws_K1_1270 -> pdf("histPdf_K1toKrho");
/*RooRealVar* m_Kpipi = ws_K1_1400 -> var("m_Kpipi");*/
/*RooAbsPdf* totalPdf_K1_1400 = ws_K1_1400 -> pdf("totalPdf_K1_1400");*/
/*RooAbsData* data_K1_1400 = ws_K1_1400 -> data("totalPdf_K1_1400Data");*/
/*RooHistPdf* pdf_K1_1400_to_Krho = ws_K1_1400 -> pdf("histPdf_K1_1400toKrho");*/
/*RooRealVar* m_Kpipi = ws_K2_1430 -> var("m_Kpipi");*/
/*RooAbsPdf* totalPdf_K2_1430 = ws_K2_1430 -> pdf("totalPdf_K2_1430");*/
/*RooAbsData* data_K2_1430 = ws_K2_1430 -> data("totalPdf_K2_1430Data");*/
/*RooHistPdf* pdf_K2_1430_to_Krho = ws_K2_1430 -> pdf("histPdf_K2_1430toKrho");*/
// Plotting pdf
/*TCanvas* c1 = new TCanvas("c1","canvas",20,20,1200,600);*/
/*c1->Divide(3,1);*/
/*c1->cd(1);*/
/*RooPlot* frame_K1_1270 = m_Kpipi -> frame(Bins(200),Title("K1(1270) -> K#pi#pi"));*/
/*data_K1_1270->plotOn(frame_K1_1270,DrawOption("C"));*/
/*frame_K1_1270->Draw();*/
/*c1->cd(2);*/
/*RooPlot* frame_K1_1400 = m_Kpipi -> frame(Bins(200),Title("K1(1400) -> K#pi#pi"));*/
/*data_K1_1400->plotOn(frame_K1_1400,DrawOption("C"));*/
/*frame_K1_1400->Draw();*/
/*c1->cd(3);*/
/*RooPlot* frame_K2_1430= m_Kpipi -> frame(Bins(200),Title("K2*(1430) -> K#pi#pi"));*/
/*data_K2_1430->plotOn(frame_K2_1430,DrawOption("C"));*/
/*frame_K2_1430->Draw();*/
////////////////////////////////////////////////////////////////////////
TFile *Fworkspace = new TFile("workspace.root");
RooWorkspace* wsp = (RooWorkspace*) Fworkspace->Get("wsp");
wsp->Print();
RooRealVar* B_postcalib_M = wsp -> var("B_postcalib_M");
RooRealVar* nsig_sw = wsp-> var("nsig_sw");
RooRealVar* nbkg_sw = wsp-> var("nbkg_sw");
RooRealVar* B_M13_Subst3_gamma2pi0 = wsp-> var("B_M13_Subst3_gamma2pi0");
RooRealVar* B_M023 = wsp -> var("B_M023");
RooRealVar* K_1_1270_plus_M = wsp -> var("K_1_1270_plus_M");
RooRealVar* K_1_1270_plus_SMALLESTDELTACHI2 = wsp -> var("K_1_1270_plus_SMALLESTDELTACHI2");
RooRealVar* gamma_CL = wsp -> var("gamma_CL");
RooRealVar* piminus_PIDK = wsp -> var("piminus_PIDK");
RooRealVar* piplus_PIDK = wsp -> var("piplus_PIDK");
RooRealVar* Kplus_PIDp = wsp -> var("Kplus_PIDp");
RooRealVar* Kplus_PIDK = wsp -> var("Kplus_PIDK");
RooRealVar* B_M02 = wsp -> var("B_M02");
RooRealVar* L_nsig = wsp -> var("L_nsig");
RooRealVar* L_nbkg = wsp -> var("L_nbkg");
RooArgSet arg(*B_postcalib_M,*gamma_CL,*B_M13_Subst3_gamma2pi0,*B_M023,*piminus_PIDK,*piplus_PIDK,*Kplus_PIDK,*Kplus_PIDp);
arg.add(*K_1_1270_plus_M);
arg.add(*K_1_1270_plus_SMALLESTDELTACHI2);
arg.add(*B_M02);
arg.add(*nsig_sw);
arg.add(*L_nsig);
arg.add(*nbkg_sw);
arg.add(*L_nbkg);
arg.add(*m_Kpipi);
RooDataSet* DataSWeights = (RooDataSet*) wsp -> data("DataSWeights");
RooFormulaVar newMass("m_Kpipi", "m_Kpipi", "K_1_1270_plus_M", RooArgList(*(wsp->var("K_1_1270_plus_M"))));
DataSWeights->addColumn(newMass);
RooDataSet* splot = new RooDataSet(DataSWeights->GetName(),DataSWeights->GetTitle(),DataSWeights,RooArgSet(arg),"","nsig_sw");
// Defining here pdfs for other resonances to be fitted
// TRY TO ADD 2 SIMPLE BWs FOR K1 1270 AND K1 1400 AS WELL
// also, binned clone and try to fit a toy dataset
// K1(1270)
/*Double_t R = 0.0015; // was 3.1 GeV-1*/
/*RooRealVar mean_K1_1270("mean_K1_1270","",1272.,1262.,1282.);*/
/*RooRealVar width_K1_1270("width_K1_1270","",90.,70.,110.);*/
//.........这里部分代码省略.........
示例4: ws_v05
//.........这里部分代码省略.........
wsp->Print();
RooRealVar* B_postcalib_M = wsp -> var("B_postcalib_M");
RooRealVar* nsig_sw = wsp-> var("nsig_sw");
RooRealVar* nbkg_sw = wsp-> var("nbkg_sw");
RooRealVar* B_M13_Subst3_gamma2pi0 = wsp-> var("B_M13_Subst3_gamma2pi0");
RooRealVar* B_M023 = wsp -> var("B_M023");
RooRealVar* K_1_1270_plus_M = wsp -> var("K_1_1270_plus_M");
RooRealVar* K_1_1270_plus_SMALLESTDELTACHI2 = wsp -> var("K_1_1270_plus_SMALLESTDELTACHI2");
RooRealVar* gamma_CL = wsp -> var("gamma_CL");
RooRealVar* piminus_PIDK = wsp -> var("piminus_PIDK");
RooRealVar* piplus_PIDK = wsp -> var("piplus_PIDK");
RooRealVar* Kplus_PIDp = wsp -> var("Kplus_PIDp");
RooRealVar* Kplus_PIDK = wsp -> var("Kplus_PIDK");
RooRealVar* B_M02 = wsp -> var("B_M02");
RooRealVar* L_nsig = wsp -> var("L_nsig");
RooRealVar* L_nbkg = wsp -> var("L_nbkg");
RooArgSet arg(*B_postcalib_M,*gamma_CL,*B_M13_Subst3_gamma2pi0,*B_M023,*piminus_PIDK,*piplus_PIDK,*Kplus_PIDK,*Kplus_PIDp);
arg.add(*K_1_1270_plus_M);
arg.add(*K_1_1270_plus_SMALLESTDELTACHI2);
arg.add(*B_M02);
arg.add(*nsig_sw);
arg.add(*L_nsig);
arg.add(*nbkg_sw);
arg.add(*L_nbkg);
arg.add(*m_Kpipi);
RooDataSet* DataSWeights = (RooDataSet*) wsp -> data("DataSWeights");
RooFormulaVar newMass("m_Kpipi", "m_Kpipi", "K_1_1270_plus_M", RooArgList(*(wsp->var("K_1_1270_plus_M"))));
DataSWeights->addColumn(newMass);
RooDataSet* splot = new RooDataSet(DataSWeights->GetName(),DataSWeights->GetTitle(),DataSWeights,RooArgSet(arg),"","nsig_sw");
cout << "\n\n >>>> Defining components and fitting \n\n" << endl;
// Defining here pdfs for other resonances to be fitted
// K1(1270)
Double_t R = 0.0015; // was 3.1 GeV-1
RooRealVar mean_K1_1270("mean_K1_1270","",1272.,1262.,1282.);
RooRealVar width_K1_1270("width_K1_1270","",90.,70.,110.);
// K1(1270) -> K rho
/*RooBreitWigner totalPdf_K1_1270("totalPdf_K1_1270","",*m_Kpipi,mean_K1_1270,width_K1_1270);*/
/*RooRelBreitWigner totalPdf_K1_1270("totalPdf_K1_1270","totalPdf_K1_1270_rho",*m_Kpipi,mean_K1_1270,width_K1_1270,RooConst(0),RooConst(R),RooConst(770.),RooConst(493.7));*/
// K1(1270) -> K*0(1430) pi
/*RooBreitWigner totalPdf_K1_1270_Kst0_1430("totalPdf_K1_1270_Kst0_1430","totalPdf_K1_1270_Kst0_1430",*m_Kpipi,mean_K1_1270,width_K1_1270);*/
/*RooRelBreitWigner totalPdf_K1_1270_Kst0_1430("totalPdf_K1_1270_Kst0_1430","totalPdf_K1_1270_Kst0_1430",*m_Kpipi,mean_K1_1270,width_K1_1270,RooConst(0),RooConst(R),RooConst(1425.),RooConst(139.6));*/
// K1(1270) -> K*0(892) pi
/*RooBreitWigner totalPdf_K1_1270_Kst0_892("totalPdf_K1_1270_Kst0_892","totalPdf_K1_1270_Kst0_892",*m_Kpipi,mean_K1_1270,width_K1_1270);*/
/*RooRelBreitWigner totalPdf_K1_1270_Kst0_892("totalPdf_K1_1270_Kst0_892","totalPdf_K1_1270_Kst0_892",*m_Kpipi,mean_K1_1270,width_K1_1270,RooConst(0),RooConst(R),RooConst(895.5),RooConst(139.6));*/
// K1(1400)
RooRealVar mean_K1_1400("mean_K1_1400","",1403./*,1396.,1410.*/);
RooRealVar width_K1_1400("width_K1_1400","",174./*,151.,197.*/);
RooBreitWigner totalPdf_K1_1400("totalPdf_K1_1400","",*m_Kpipi,mean_K1_1400,width_K1_1400);
/*[>RooRelBreitWigner totalPdf_K1_1400("totalPdf_K1_1400","totalPdf_K1_1400",*m_Kpipi,mean_K1_1400,width_K1_1400,RooConst(0),RooConst(R),RooConst(895.),RooConst(139.6)); //K*(892) pi is 93%<]*/
// K2*(1430)
示例5: ws_v01
//.........这里部分代码省略.........
/*RooArgSet param(*m_Kpipi);*/
/*RooDataSet MCdataset("MCdataset","MCdataset",param);*/
/*Double_t K_1_1270_plus_TRUEM = 0.;*/
/*t_tree->SetBranchAddress("K_1_1270_plus_TRUEM",&K_1_1270_plus_TRUEM);*/
/*Int_t n = 0;*/
/*for (int i=0;i<t_tree->GetEntries();i++)*/
/*{*/
/*t_tree->GetEntry(i);*/
/**m_Kpipi_K1_1270 = K_1_1270_plus_TRUEM;*/
/*MCdataset.add(param);*/
/*n++;*/
/*}*/
/*pdf_K1_1270_to_Krho.fitTo(MCdataset,Extended(true));*/
/*TCanvas* canvas = new TCanvas("canvas","MC data for K1(1270) -> #rho K",20,20,800,600);*/
/*RooPlot* frame_MCdataset = m_Kpipi.frame(Bins(200));*/
/*pdf_K1_1270_to_Krho.paramOn(frame_MCdataset);*/
/*MCdataset.plotOn(frame_MCdataset,DrawOption("C"));*/
/*pdf_K1_1270_to_Krho->plotOn(frame_MCdataset);*/
/*frame_MCdataset->Draw();*/
////////////////////////////////////////////////////////////////////////
TFile *Fworkspace = new TFile("workspace.root");
RooWorkspace* wsp = (RooWorkspace*) Fworkspace->Get("wsp");
wsp->Print();
RooRealVar* B_postcalib_M = wsp -> var("B_postcalib_M");
RooRealVar* nsig_sw = wsp-> var("nsig_sw");
RooRealVar* nbkg_sw = wsp-> var("nbkg_sw");
RooRealVar* B_M13_Subst3_gamma2pi0 = wsp-> var("B_M13_Subst3_gamma2pi0");
RooRealVar* B_M023 = wsp -> var("B_M023");
RooRealVar* K_1_1270_plus_M = wsp -> var("K_1_1270_plus_M");
RooRealVar* K_1_1270_plus_SMALLESTDELTACHI2 = wsp -> var("K_1_1270_plus_SMALLESTDELTACHI2");
RooRealVar* gamma_CL = wsp -> var("gamma_CL");
RooRealVar* piminus_PIDK = wsp -> var("piminus_PIDK");
RooRealVar* piplus_PIDK = wsp -> var("piplus_PIDK");
RooRealVar* Kplus_PIDp = wsp -> var("Kplus_PIDp");
RooRealVar* Kplus_PIDK = wsp -> var("Kplus_PIDK");
RooRealVar* B_M02 = wsp -> var("B_M02");
RooRealVar* L_nsig = wsp -> var("L_nsig");
RooRealVar* L_nbkg = wsp -> var("L_nbkg");
RooArgSet arg(*B_postcalib_M,*gamma_CL,*B_M13_Subst3_gamma2pi0,*B_M023,*piminus_PIDK,*piplus_PIDK,*Kplus_PIDK,*Kplus_PIDp);
arg.add(*K_1_1270_plus_M);
arg.add(*K_1_1270_plus_SMALLESTDELTACHI2);
arg.add(*B_M02);
arg.add(*nsig_sw);
arg.add(*L_nsig);
arg.add(*nbkg_sw);
arg.add(*L_nbkg);
arg.add(*m_Kpipi);
RooDataSet* DataSWeights = (RooDataSet*) wsp -> data("DataSWeights");
RooFormulaVar newMass("m_Kpipi", "m_Kpipi", "K_1_1270_plus_M", RooArgList(*(wsp->var("K_1_1270_plus_M"))));
DataSWeights->addColumn(newMass);
RooDataSet* splot = new RooDataSet(DataSWeights->GetName(),DataSWeights->GetTitle(),DataSWeights,RooArgSet(arg),"","nsig_sw");
// here add pdfs and FIT sum of pdf to splot
RooRealVar K1_1270_y("K1_1270_y","K1_1270_y",1000.,0.,10000.);
RooRealVar K1_1400_y("K1_1400_y","K1_1400_y",100.,0.,10000.);
/*RooRealVar K2_1430_y("K2_1430_y","K2_1430_y",300.,0.,10000.);*/
RooFormulaVar K2_1430_y("K2_1430_y","K2_1430_y","K1_1270_y/3.",K1_1270_y); // K2_1430 yield is fixed to 1/3 of the K1_1270 yield (as found from Belle ... TO CHECK)
RooArgList shapes;
RooArgList yields;
shapes.add(*totalPdf_K1_1270);
shapes.add(*totalPdf_K1_1400);
shapes.add(*totalPdf_K2_1430);
yields.add(K1_1270_y);
yields.add(K1_1400_y);
yields.add(K2_1430_y);
RooAddPdf PDF("PDF","total Pdf for the resonances considered", shapes,yields);
PDF->fitTo(*splot,Extended(),SumW2Error(kTRUE),Range(1000,2000));
// Plotting
TCanvas* canvas_sPlot = new TCanvas("canvas_sPlot","sPlot with weights",40,20,800,600);
RooPlot* frame_splot = m_Kpipi->frame(1000,2000,80);
splot->plotOn(frame_splot);
PDF->paramOn(frame_splot);
PDF->plotOn(frame_splot,Components(*totalPdf_K1_1270),LineColor(kRed),LineStyle(kDashed));
PDF->plotOn(frame_splot,Components(*totalPdf_K1_1400),LineColor(1),LineStyle(kDashed));
PDF->plotOn(frame_splot,Components(*totalPdf_K2_1430),LineColor(51),LineStyle(kDashed));
PDF->plotOn(frame_splot);
frame_splot->Draw();
}