本文整理汇总了C++中RooRealVar::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ RooRealVar::Print方法的具体用法?C++ RooRealVar::Print怎么用?C++ RooRealVar::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooRealVar
的用法示例。
在下文中一共展示了RooRealVar::Print方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBkgTemplates
//.........这里部分代码省略.........
frame->Draw();
TPaveText *pave = new TPaveText(0.7,0.76,0.9,0.9,"NDC");
pave->SetTextAlign(11);
pave->SetFillColor(0);
pave->SetBorderSize(0);
pave->SetTextFont(62);
pave->SetTextSize(0.045);
pave->AddText(TString::Format("%s selection",SELNAME[isel].Data()));
pave->AddText(TString::Format("CAT%d",counter));
TText *lastline = pave->AddText("Z template");
pave->SetY1NDC(pave->GetY2NDC()-0.055*3);
TPaveText *paveorig = (TPaveText*)pave->Clone();
paveorig->Draw();
sprintf(name,"roohist_T_CAT%d",counter);
if (icat < 3) {
roohist_T[icat] = new RooDataHist(name,name,x,hTopYield);
}
else {
roohist_T[icat] = new RooDataHist(name,name,x,hSTYield);
}
sprintf(name,"Top_mean_CAT%d",counter);
RooRealVar mT(name,name,130,0,200);
sprintf(name,"Top_sigma_CAT%d",counter);
RooRealVar sT(name,name,50,0,200);
sprintf(name,"Top_mean_shifted_CAT%d",counter);
RooFormulaVar mTShift(name,"@0*@1",RooArgList(mT,*(kJES[isel])));
sprintf(name,"Top_sigma_shifted_CAT%d",counter);
RooFormulaVar sTShift(name,"@0*@1",RooArgList(sT,*(kJER[isel])));
sprintf(name,"Top_model_CAT%d",counter);
RooGaussian *modelT = new RooGaussian(name,name,x,mTShift,sTShift);
RooFitResult *resT = modelT->fitTo(*roohist_T[icat],Save(),SumW2Error(kTRUE),"q");
/*
TF1 *tmp_func = new TF1("tmpFunc","gaus",XMIN,XMAX);
tmp_func->SetParameters(1,a0.getVal(),a1.getVal());
if (icat < 3) {
float norm = tmp_func->Integral(XMIN,XMAX)/hTopYield->GetBinWidth(1);
tmp_func->SetParameter(0,hTopYield->Integral()/norm);
}
else {
float norm = tmp_func->Integral(XMIN,XMAX)/hSTYield->GetBinWidth(1);
tmp_func->SetParameter(0,hSTYield->Integral()/norm);
}
*/
canT->cd(icat+1);
RooPlot* frame = x.frame();
roohist_T[icat]->plotOn(frame);
modelT->plotOn(frame,RooFit::LineWidth(2));
//modelT->plotOn(frame,VisualizeError(*resT,1,kTRUE),FillColor(kGray),MoveToBack());
frame->GetXaxis()->SetTitle("M_{bb} (GeV)");
frame->Draw();
//tmp_func->Draw("sameL");
lastline->SetTitle("Top template");
pave->Draw();
mZ.setConstant(kTRUE);
sZ.setConstant(kTRUE);
aZ.setConstant(kTRUE);
nZ.setConstant(kTRUE);
Zb0.setConstant(kTRUE);
Zb1.setConstant(kTRUE);
Zb2.setConstant(kTRUE);
fZsig.setConstant(kTRUE);
mT.setConstant(kTRUE);
sT.setConstant(kTRUE);
w->import(modelZ);
w->import(*modelT);
w->import(*YieldZ);
w->import(*YieldT);
w->import(*YieldTT);
w->import(*YieldST);
YieldZ->Print();
YieldW->Print();
YieldT->Print();
YieldTT->Print();
YieldST->Print();
counter++;
}// category loop
system(TString::Format("[ ! -d %s/ ] && mkdir %s/",OUTPATH.Data(),OUTPATH.Data()).Data());
system(TString::Format("[ ! -d %s/plots ] && mkdir %s/plots",OUTPATH.Data(),OUTPATH.Data()).Data());
system(TString::Format("[ ! -d %s/plots/bkgTemplates ] && mkdir %s/plots/bkgTemplates",OUTPATH.Data(),OUTPATH.Data()).Data());
TString FULLPATH(OUTPATH+"/plots/bkgTemplates");
canT->SaveAs(TString::Format("%s/%s.png",FULLPATH.Data(),canT->GetName()));
canZ->SaveAs(TString::Format("%s/%s.png",FULLPATH.Data(),canZ->GetName()));
canT->SaveAs(TString::Format("%s/%s.pdf",FULLPATH.Data(),canT->GetName()));
canZ->SaveAs(TString::Format("%s/%s.pdf",FULLPATH.Data(),canZ->GetName()));
delete can;
}// selection loop
system(TString::Format("[ ! -d %s/ ] && mkdir %s/",OUTPATH.Data(),OUTPATH.Data()).Data());
system(TString::Format("[ ! -d %s/output ] && mkdir %s/output",OUTPATH.Data(),OUTPATH.Data()).Data());
w->Print();
w->writeToFile(TString::Format("%s/output/bkg_shapes_workspace%s.root",OUTPATH.Data(),tMERGE.Data()).Data());
}
示例2: generate
void FitterUtils::generate()
{
//***************Get the PDFs from the workspace
TFile fw(workspacename.c_str(), "UPDATE");
RooWorkspace* workspace = (RooWorkspace*)fw.Get("workspace");
RooRealVar *B_plus_M = workspace->var("B_plus_M");
RooRealVar *misPT = workspace->var("misPT");
RooRealVar *T = workspace->var("T");
RooRealVar *n = workspace->var("n");
RooRealVar *expoConst = workspace->var("expoConst");
RooRealVar *trueExp = workspace->var("trueExp");
RooRealVar *fractionalErrorJpsiLeak = workspace->var("fractionalErrorJpsiLeak");
cout<<"VALUE OF T IN GENERATE: "<<T->getVal()<<" +- "<<T->getError()<<endl;
cout<<"VALUE OF n IN GENERATE: "<<n->getVal()<<" +- "<<n->getError()<<endl;
RooHistPdf *histPdfSignalZeroGamma = (RooHistPdf *) workspace->pdf("histPdfSignalZeroGamma");
RooHistPdf *histPdfSignalOneGamma = (RooHistPdf *) workspace->pdf("histPdfSignalOneGamma");
RooHistPdf *histPdfSignalTwoGamma = (RooHistPdf *) workspace->pdf("histPdfSignalTwoGamma");
RooHistPdf *histPdfPartReco = (RooHistPdf *) workspace->pdf("histPdfPartReco");
RooHistPdf *histPdfJpsiLeak(0);
if(nGenJpsiLeak>1) histPdfJpsiLeak = (RooHistPdf *) workspace->pdf("histPdfJpsiLeak");
RooAbsPdf *combPDF;
if (fit2D)
{
combPDF = new RooPTMVis("combPDF", "combPDF", *misPT, *B_plus_M, *T, *n, *expoConst);
}
else
{
combPDF = new RooExponential("combPDF", "combPDF", *B_plus_M, *expoConst);
}
double trueExpConst(trueExp->getValV());
expoConst->setVal(trueExpConst);
//***************Prepare generation
int nGenSignalZeroGamma(floor(nGenFracZeroGamma*nGenSignal));
int nGenSignalOneGamma(floor(nGenFracOneGamma*nGenSignal));
int nGenSignalTwoGamma(floor(nGenSignal-nGenSignalZeroGamma-nGenSignalOneGamma));
RooArgSet argset2(*B_plus_M);
if (fit2D) argset2.add(*misPT);
cout<<"Preparing the generation of events 1";
RooRandom::randomGenerator()->SetSeed();
RooAbsPdf::GenSpec* GenSpecSignalZeroGamma = histPdfSignalZeroGamma->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenSignalZeroGamma)); cout<<" 2 ";
RooAbsPdf::GenSpec* GenSpecSignalOneGamma = histPdfSignalOneGamma->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenSignalOneGamma)); cout<<" 3 ";
RooAbsPdf::GenSpec* GenSpecSignalTwoGamma = histPdfSignalTwoGamma->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenSignalTwoGamma)); cout<<" 4 ";
RooAbsPdf::GenSpec* GenSpecPartReco = histPdfPartReco->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenPartReco)); cout<<" 5 "<<endl;
RooAbsPdf::GenSpec* GenSpecComb = combPDF->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenComb));
RooAbsPdf::GenSpec* GenSpecJpsiLeak(0);
if(nGenJpsiLeak>1) GenSpecJpsiLeak = histPdfJpsiLeak->prepareMultiGen(argset2, RooFit::Extended(1), NumEvents(nGenJpsiLeak));
cout<<"Variable loaded:"<<endl;
B_plus_M->Print(); expoConst->Print(); //B_plus_DTFM_M_zero->Print();
if (fit2D) misPT->Print();
//***************Generate some datasets
cout<<"Generating signal Zero Photon"<<endl;
RooDataSet* dataGenSignalZeroGamma = histPdfSignalZeroGamma->generate(*GenSpecSignalZeroGamma);//(argset, 250, false, true, "", false, true);
dataGenSignalZeroGamma->SetName("dataGenSignalZeroGamma"); dataGenSignalZeroGamma->SetTitle("dataGenSignalZeroGamma");
cout<<"Generating signal One Photon"<<endl;
RooDataSet* dataGenSignalOneGamma = histPdfSignalOneGamma->generate(*GenSpecSignalOneGamma);//(argset, 250, false, true, "", false, true);
dataGenSignalOneGamma->SetName("dataGenSignalOneGamma"); dataGenSignalOneGamma->SetTitle("dataGenSignalOneGamma");
cout<<"Generating signal two Photons"<<endl;
RooDataSet* dataGenSignalTwoGamma = histPdfSignalTwoGamma->generate(*GenSpecSignalTwoGamma);//(argset, 250, false, true, "", false, true);
dataGenSignalTwoGamma->SetName("dataGenSignalTwoGamma"); dataGenSignalTwoGamma->SetTitle("dataGenSignalTwoGamma");
cout<<"Generating combinatorial"<<endl;
RooDataSet* dataGenComb = combPDF->generate(*GenSpecComb);//(argset, 100, false, true, "", false, true);
dataGenComb->SetName("dataGenComb"); dataGenComb->SetTitle("dataGenComb");
cout<<"Generating PartReco"<<endl;
RooDataSet* dataGenPartReco = histPdfPartReco->generate(*GenSpecPartReco);//argset, 160, false, true, "", false, true);
dataGenPartReco->SetName("dataGenPartReco"); dataGenPartReco->SetTitle("dataGenPartReco");
RooDataSet* dataGenJpsiLeak(0);
if(nGenJpsiLeak>1)
{
cout<<"Generating Leaking JPsi"<<endl;
dataGenJpsiLeak = histPdfJpsiLeak->generate(*GenSpecJpsiLeak);//argset, 160, false, true, "", false, true);
dataGenJpsiLeak->SetName("dataGenJpsiLeak"); dataGenJpsiLeak->SetTitle("dataGenJpsiLeak");
}
//*************Saving the generated datasets in a workspace
RooWorkspace workspaceGen("workspaceGen", "workspaceGen");
workspaceGen.import(*dataGenSignalZeroGamma);
workspaceGen.import(*dataGenSignalOneGamma);
workspaceGen.import(*dataGenSignalTwoGamma);
workspaceGen.import(*dataGenComb);
//.........这里部分代码省略.........
示例3: RA4Mult
//.........这里部分代码省略.........
if ( !process || sumD<0.01 ) {
hExclusion->SetBinContent(ix,iy,limit.isInInterval);
hLowerLimit->SetBinContent(ix,iy,limit.lowerLimit);
hUpperLimit->SetBinContent(ix,iy,limit.upperLimit);
#ifndef DEBUG
continue;
#endif
}
double sigK(0.);
for ( unsigned int j=0; j<nf; ++j ) {
if ( workingPoints[j]->sigKappa_>sigK )
sigK = workingPoints[j]->sigKappa_;
// sigK += workingPoints[j]->sigKappa_;
}
// sigK /= nf;
double sigEffBase(0.15);
double sigEffLept(0.05);
double sigEffNLO(0.);
for ( unsigned int j=0; j<nf; ++j ) {
double sige = max(fabs(yields05[3][j]-yields[3][j]),
fabs(yields20[3][j]-yields[3][j]));
sige /= yields[3][j];
if ( sige>sigEffNLO ) sigEffNLO = sige;
}
double sigEff = sqrt(sigEffBase*sigEffBase+sigEffLept*sigEffLept+sigEffNLO*sigEffNLO);
std::cout << "Systematics are " << sigK << " " << sigEff << std::endl;
sigEff = 0.20;
if ( !noKappaSyst )
wspace->var("sigmaKappa")->setVal(sigK);
if ( !noSContSyst )
wspace->var("sigmaScont")->setVal(sigEff);
if ( !noEffSyst )
wspace->var("sigmaEff")->setVal(sigEff);
// wspace->var("sigmaKappa")->setVal(sqrt(0.129*0.129+0.1*0.1)*0.967);
// for the time being: work with yields
// if ( muChannel.valid_ ) {
// wspace->var("effM")->setVal(1.);
// wspace->var("sadM")->setVal(0.);
// wspace->var("sbdM")->setVal(0.);
// wspace->var("scdM")->setVal(0.);
// }
// if ( eleChannel.valid_ ) {
// wspace->var("effE")->setVal(1.);
// wspace->var("sadE")->setVal(0.);
// wspace->var("sbdE")->setVal(0.);
// wspace->var("scdE")->setVal(0.);
// }
#ifdef DEBUG
wspace->Print("v");
RooArgSet allVars = wspace->allVars();
// allVars.printLatex(std::cout,1);
TIterator* it = allVars.createIterator();
RooRealVar* var;
while ( var=(RooRealVar*)it->Next() ) {
var->Print("v");
var->printValue(std::cout);
std::cout << std::endl;
}
#endif
std::cout << "Checked ( " << hExclusion->GetXaxis()->GetBinCenter(ix) << " , "
<< hExclusion->GetYaxis()->GetBinCenter(iy) << " ) with signal "
<< yields[3][nf-1] << std::endl;
RooDataSet data("data","data",*wspace->set("obs"));
data.add(*wspace->set("obs"));
data.Print("v");
limit = computeLimit(wspace,&data,method);
std::cout << " Limit [ " << limit.lowerLimit << " , "
<< limit.upperLimit << " ] ; isIn = " << limit.isInInterval << std::endl;
double excl = limit.isInInterval;
if ( limit.upperLimit<limit.lowerLimit ) excl = -1;
hExclusion->SetBinContent(ix,iy,excl);
hLowerLimit->SetBinContent(ix,iy,limit.lowerLimit);
hUpperLimit->SetBinContent(ix,iy,limit.upperLimit);
// return;
}
}
TFile* out = new TFile("RA4abcd.root","RECREATE");
hExclusion->SetDirectory(out);
hExclusion->SetMinimum(); hExclusion->SetMaximum();
hExclusion->SetContour(1); hExclusion->SetContourLevel(0,0.5);
hLowerLimit->SetDirectory(out);
hLowerLimit->SetMinimum(); hLowerLimit->SetMaximum();
hUpperLimit->SetDirectory(out);
hUpperLimit->SetMinimum(); hUpperLimit->SetMaximum();
for ( unsigned int j=0; j<nf; ++j ) {
hYields[3][j]->SetDirectory(out);
hYields[3][j]->SetMinimum(); hYields[3][j]->SetMaximum();
}
out->Write();
delete out;
}
示例4: StandardHistFactoryPlotsWithCategories
void StandardHistFactoryPlotsWithCategories(const char* infile = "",
const char* workspaceName = "combined",
const char* modelConfigName = "ModelConfig",
const char* dataName = "obsData"){
double nSigmaToVary=5.;
double muVal=0;
bool doFit=false;
// -------------------------------------------------------
// First part is just to access a user-defined file
// or create the standard example file if it doesn't exist
const char* filename = "";
if (!strcmp(infile,"")) {
filename = "results/example_combined_GaussExample_model.root";
bool fileExist = !gSystem->AccessPathName(filename); // note opposite return code
// if file does not exists generate with histfactory
if (!fileExist) {
#ifdef _WIN32
cout << "HistFactory file cannot be generated on Windows - exit" << endl;
return;
#endif
// Normally this would be run on the command line
cout <<"will run standard hist2workspace example"<<endl;
gROOT->ProcessLine(".! prepareHistFactory .");
gROOT->ProcessLine(".! hist2workspace config/example.xml");
cout <<"\n\n---------------------"<<endl;
cout <<"Done creating example input"<<endl;
cout <<"---------------------\n\n"<<endl;
}
}
else
filename = infile;
// Try to open the file
TFile *file = TFile::Open(filename);
// if input file was specified byt not found, quit
if(!file ){
cout <<"StandardRooStatsDemoMacro: Input file " << filename << " is not found" << endl;
return;
}
// -------------------------------------------------------
// Tutorial starts here
// -------------------------------------------------------
// get the workspace out of the file
RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName);
if(!w){
cout <<"workspace not found" << endl;
return;
}
// get the modelConfig out of the file
ModelConfig* mc = (ModelConfig*) w->obj(modelConfigName);
// get the modelConfig out of the file
RooAbsData* data = w->data(dataName);
// make sure ingredients are found
if(!data || !mc){
w->Print();
cout << "data or ModelConfig was not found" <<endl;
return;
}
// -------------------------------------------------------
// now use the profile inspector
RooRealVar* obs = (RooRealVar*)mc->GetObservables()->first();
TList* list = new TList();
RooRealVar * firstPOI = dynamic_cast<RooRealVar*>(mc->GetParametersOfInterest()->first());
firstPOI->setVal(muVal);
// firstPOI->setConstant();
if(doFit){
mc->GetPdf()->fitTo(*data);
}
// -------------------------------------------------------
mc->GetNuisanceParameters()->Print("v");
int nPlotsMax = 1000;
cout <<" check expectedData by category"<<endl;
RooDataSet* simData=NULL;
RooSimultaneous* simPdf = NULL;
if(strcmp(mc->GetPdf()->ClassName(),"RooSimultaneous")==0){
cout <<"Is a simultaneous PDF"<<endl;
simPdf = (RooSimultaneous *)(mc->GetPdf());
} else {
cout <<"Is not a simultaneous PDF"<<endl;
}
//.........这里部分代码省略.........