本文整理汇总了C++中RooRealVar::getValV方法的典型用法代码示例。如果您正苦于以下问题:C++ RooRealVar::getValV方法的具体用法?C++ RooRealVar::getValV怎么用?C++ RooRealVar::getValV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooRealVar
的用法示例。
在下文中一共展示了RooRealVar::getValV方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logStatisticsPar
void logStatisticsPar(std::ostream& out, RooDataSet *dataSet, RooRealVar *realVar, int nBins, double chi2, const RooArgList &variables)
{
TH1 *histogram = dataSet->createHistogram(Form("h%s", dataSet->GetName()), *realVar, RooFit::Binning(nBins));
// Create the TeX file
out << "\\documentclass[10pt]{article}" << std::endl;
out << "\\usepackage[usenames]{color} %used for font color" << std::endl;
out << "\\usepackage{fontspec}" << std::endl;
out << "\\usepackage{xunicode}" << std::endl;
out << "\\usepackage{xltxtra}" << std::endl;
out << "\\defaultfontfeatures{Scale=MatchLowercase}" << std::endl;
out << "\\setromanfont[Mapping=tex-text]{Myriad Pro}" << std::endl;
out << "\\setsansfont[Mapping=tex-text]{Myriad Pro}" << std::endl;
out << "\\setmonofont{Monaco}" << std::endl;
out << "\\begin{document}" << std::endl;
out << "\\thispagestyle{empty}" << std::endl;
out << "\\setlength{\\tabcolsep}{1ex}" << std::endl;
out << "\\setlength{\\fboxsep}{0ex}" << std::endl;
out << "{\\fontsize{7pt}{0.9em}\\selectfont" << std::endl;
out << "\\framebox{\\begin{tabular*}{60pt}{[email protected]{\\extracolsep{\\fill}}r}" << std::endl;
// This is the particular info for the histogram
out << "Entries & " ;
formatNumber(histogram->GetEntries(), out) << " \\\\" << std::endl;
out << "Mean & " ;
formatNumber(histogram->GetMean(), out) << " \\\\" << std::endl;
out << "RMS & " ;
formatNumber(histogram->GetRMS(), out) << " \\\\" << std::endl;
if (chi2 > 0.0) {
out << "Fit $\\chi^{2}$ & " ;
formatNumber(chi2, out) << " \\\\" << std::endl;
}
RooRealVar *theVariable;
for (int index = 0; index < variables.getSize(); index++) {
theVariable = dynamic_cast<RooRealVar*>(variables.find(variables[index].GetName()));
out << theVariable->GetTitle() << " & $\\textrm{" ;
formatNumber(theVariable->getValV(), out) << "} \\pm \\textrm{" ;
formatNumber(theVariable->getError(), out) << "}$ \\\\" << std::endl;
}
out << "\\end{tabular*}}}" << std::endl;
out << "\\end{document}" << std::endl;
histogram->Delete();
}
示例2: extractParameter
bool extractParameter(string fileName, const char* parName, pair<double,double>& value)
{
TFile *f = new TFile( fileName.c_str() );
if (!f) {
cout << "[Error] " << fileName << " not found" << endl; return false;
}
RooWorkspace *ws = (RooWorkspace*) f->Get("workspace");
if (!ws) {
cout << "[ERROR] Workspace not found in " << fileName << endl; return false;
}
RooRealVar *var = ws->var(parName);
if (!var) {
value = make_pair( -999.9 , -999.9 ); return true;
}
value = make_pair( var->getValV() , var->getError() );
return true;
}
示例3: 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);
//.........这里部分代码省略.........
示例4: CreateDatacards
void CreateDatacards(float XMIN, float XMAX, int CAT_MIN,int CAT_MAX,int BRN_ORDER_NOM, int BRN_ORDER_VBF, TString TR, TString OUTPATH, TString CATVETO="", int MASS, float XMAXDIFF=0.)
{
TString PATH(TString::Format("%s/output/",OUTPATH.Data()).Data());
const int NCAT = 7;
const int NF = 6;
const int NMASS = 5;
//---- uncertainties -------------------------------------
const float UNC_BR[NMASS] = {1.024,1.028,1.032,1.037,1.043};
const float UNC_UEPS_VBF[NCAT] = {1.04,1.02,0.97,0.93,1.02,1.03,1.04};
const float UNC_JES_VBF[NCAT] = {1.06,1.08,1.09,1.10,1.06,1.08,1.10};
const float UNC_JER_VBF[NCAT] = {0.97,0.96,0.97,0.98,0.99,0.98,0.99};
const float UNC_TRIG_VBF[NCAT] = {1.03,1.04,1.05,1.06,1.01,1.01,1.02};
const float UNC_CSV_VBF[NCAT] = {1.03,0.99,0.97,0.94,1.01,0.94,0.91};
const float UNC_QGL_VBF[NCAT] = {1.03,1.01,1.00,0.98,1.03,1.01,0.98};
const float UNC_SCALE_VBF[NCAT] = {1.00,1.00,1.01,1.02,1.03,1.03,1.05};
const float UNC_PDF_VBF[NCAT] = {1.02,1.02,1.02,1.02,1.03,1.03,1.03};
const float UNC_PDFGlobal_VBF[NMASS] = {1.028,1.028,1.028,1.027,1.027};
const float UNC_SCALEGlobal_VBF[NMASS] = {1.002,1.002,1.002,1.002,1.002};
const float UNC_UEPS_GF[NCAT] = {1.25,1.10,0.80,0.90,0.65,1.65,1.45};
const float UNC_JES_GF[NCAT] = {1.08,1.10,1.12,1.12,1.04,1.09,1.10};
const float UNC_JER_GF[NCAT] = {0.99,0.99,0.95,0.96,0.91,0.99,0.95};
const float UNC_TRIG_GF[NCAT] = {1.05,1.05,1.10,1.15,1.09,1.09,1.19};
const float UNC_CSV_GF[NCAT] = {0.99,0.97,0.93,0.93,0.93,0.97,0.90};
const float UNC_QGL_GF[NCAT] = {1.03,1.01,1.00,0.98,1.03,1.01,0.98};
const float UNC_SCALE_GF[NCAT] = {1.00,1.00,1.01,1.02,1.03,1.03,1.05};
const float UNC_PDF_GF[NCAT] = {1.04,1.04,1.04,1.04,1.05,1.04,1.04};
const float UNC_PDFGlobal_GF[NMASS] = {1.076,1.075,1.075,1.075,1.074};
const float UNC_SCALEGlobal_GF[NMASS] = {1.081,1.079,1.078,1.077,1.077};
vector<int> vCATVETO = tokenize(CATVETO);
TString tCATVETO = tag(CATVETO);
bool FreeTF=false, TF=false;
if (TR!="" && TR!="BRN") TF=true;
if (TF && (TR(0,5)!="Fixed"&&TR!="EXPO")) FreeTF=true;
TString sTRF="";
if (TR(0,5)=="Fixed") sTRF = TR(5,4);
else sTRF = TR;
if (XMAXDIFF==0) TFile *fData = TFile::Open(PATH+"data_shapes_workspace_"+TString::Format("BRN%dp%d_B%.f-%.f",BRN_ORDER_NOM,BRN_ORDER_VBF,XMIN,XMAX)+"_Fit"+TR+".root");
else TFile *fData = TFile::Open(PATH+"data_shapes_workspace_"+TString::Format("BRN%dp%d_B%.f-%.f%.f",BRN_ORDER_NOM,BRN_ORDER_VBF,XMIN,XMAX,XMAX+XMAXDIFF)+"_Fit"+TR+".root");
if (XMAXDIFF==0) TFile *fSig = TFile::Open(PATH+"signal_shapes_workspace_"+TString::Format("B%.f-%.f.root",XMIN,XMAX));
else TFile *fSig = TFile::Open(PATH+"signal_shapes_workspace_"+TString::Format("B%.f-%.f%.f.root",XMIN,XMAX,XMAX+XMAXDIFF));
RooWorkspace *wData = (RooWorkspace*)fData->Get("w");
RooWorkspace *wSig = (RooWorkspace*)fSig->Get("w");
TString nameData = fData->GetName();
TString nameDataShort = nameData(nameData.Last('/')+1,nameData.Length());
TString nameSig = fSig->GetName();
TString nameSigShort = nameSig(nameSig.Last('/')+1,nameSig.Length());
char name[1000];
int H_MASS[5] = {115,120,125,130,135};
float nData[NCAT],nZ[NCAT],nTop[NCAT],nSigVBF[5][NCAT],nSigGF[5][NCAT];
for(int i=CAT_MIN;i<=CAT_MAX;i++) {
sprintf(name,"yield_data_CAT%d",i);
nData[i] = float((RooRealVar*)wData->var(name)->getValV());
sprintf(name,"yield_ZJets_CAT%d",i);
nZ[i] = ((RooRealVar*)wData->var(name))->getValV();
sprintf(name,"yield_Top_CAT%d",i);
nTop[i] = ((RooRealVar*)wData->var(name))->getValV();
for(int m=0;m<5;m++) {
if (H_MASS[m]!=MASS) continue;
sprintf(name,"yield_signalVBF_mass%d_CAT%d",H_MASS[m],i);
nSigVBF[m][i] = ((RooRealVar*)wSig->var(name))->getValV();
sprintf(name,"yield_signalGF_mass%d_CAT%d",H_MASS[m],i);
nSigGF[m][i] = ((RooRealVar*)wSig->var(name))->getValV();
}
}
makeDirs(OUTPATH);
makeDirs(OUTPATH+"/output/");
makeDirs(OUTPATH+"/output/datacards");
for(int m=0;m<5;m++) {
if (H_MASS[m]!=MASS) continue;
cout << m << endl;
ofstream datacard;
if (XMAXDIFF==0) sprintf(name,"%s/output/datacards/datacard_m%d_BRN%dp%d_B%.f-%.f_CAT%d-CAT%d%s_Fit%s.txt",OUTPATH.Data(),H_MASS[m],BRN_ORDER_NOM,BRN_ORDER_VBF,XMIN,XMAX,CAT_MIN,CAT_MAX,tCATVETO.Data(),TR.Data());
else sprintf(name,"%s/output/datacards/datacard_m%d_BRN%dp%d_B%.f-%.f%.f_CAT%d-CAT%d%s_Fit%s.txt",OUTPATH.Data(),H_MASS[m],BRN_ORDER_NOM,BRN_ORDER_VBF,XMIN,XMAX,XMAX+XMAXDIFF,CAT_MIN,CAT_MAX,tCATVETO.Data(),TR.Data());
cout<<"======================================="<<endl;
cout<<"Creating datacard: "<<name<<endl;
cout<<"======================================="<<endl;
datacard.open(name);
datacard.setf(ios::right);
datacard<<"imax "<<CAT_MAX-CAT_MIN+1-vCATVETO.size()<<"\n";
datacard<<"jmax *"<<"\n";
datacard<<"kmax *"<<"\n";
datacard<<"----------------"<<"\n";
datacard<<"shapes data_obs * "<<nameDataShort<<" w:data_hist_$CHANNEL"<<"\n";
datacard<<"shapes qcd * "<<nameDataShort<<" w:qcd_model_Fit"<<TR.Data()<<"_$CHANNEL"<<"\n";
datacard<<"shapes top * "<<nameDataShort<<" w:Top_model_$CHANNEL"<<"\n";
datacard<<"shapes zjets * "<<nameDataShort<<" w:Z_model_$CHANNEL"<<"\n";
datacard<<"shapes qqH * "<<nameSigShort<<" w:signal_model_m"<<H_MASS[m]<<"_$CHANNEL \n";
datacard<<"shapes ggH * "<<nameSigShort<<" w:signal_model_m"<<H_MASS[m]<<"_$CHANNEL \n";
datacard<<"----------------"<<"\n";
datacard<<"bin ";
//.........这里部分代码省略.........
示例5: ptBestFit
//.........这里部分代码省略.........
RooHist *hresid,*hresid0;
RooPlot *frame1 = x->frame();
RooPlot *frame2 = x->frame();
if (BLIND) {
//cout << "Blind case: " << ds_coarse.GetName() << endl;
ds_coarse.plotOn(frame1,LineColor(0),MarkerColor(0));
pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(3));
ds_blind.plotOn(frame1);
hresid = frame1->residHist();
frame2->addPlotable(hresid,"pE1");
}
else {
//cout << "Non-blind case: " << ds_coarse.GetName() << endl;
ds_coarse.plotOn(frame1);
pdfi->plotOn(frame1);
//cout << pdfi->getParameters(ds_coarse)->selectByAttrib("Constant",kFALSE)->getSize() << endl;
cout<<"chi2/ndof (bkg+sig) = "<<frame1->chiSquare()<<endl;
cout << ds_coarse.numEntries() << endl;
chi2sumS += frame1->chiSquare()*ds_coarse.numEntries();
nparsum += ds_coarse.numEntries();
//hresid0 = frame1->residHist();
//pdfi->plotOn(frame1,VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name),LineWidth(2),LineStyle(5),LineColor(kGreen+2));
pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack));
cout<<"chi2/ndof (bkg) = "<<frame1->chiSquare()<<endl;
chi2sumB += frame1->chiSquare()*ds_coarse.numEntries();
pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
hresid = frame1->residHist();
frame2->addPlotable(hresid,"pE1");
float yield_sig = rFit->getValV()*(yield_vbf->getValV()+yield_gf->getValV());
RooAbsPdf *signal_pdf = (RooAbsPdf*)w->pdf("shapeSig_qqH_"+ds_name);
signal_pdf->plotOn(frame2,LineWidth(2),LineColor(kRed),Normalization(yield_sig,RooAbsReal::NumEvent),MoveToBack());
}
// hresid0->Print();
// hresid->Print();
// double x2,y2;
// for (int i=0; i<3; ++i) {
// hresid0->GetPoint(i,x2,y2);
// cout << "BKG+SIG\t" << x2 << "\t" << y2 << endl;
// hresid->GetPoint(i,x2,y2);
// cout << "BKG\t" << x2 << "\t" << y2 << endl;
// ds_coarse.get(i);
// cout << ds_coarse.weightError(RooAbsData::SumW2) << endl;
// cout << endl;
// }
TCanvas* canFit = new TCanvas("Higgs_fit_"+ds_name,"Higgs_fit_"+ds_name,900,750);
canFit->cd(1)->SetBottomMargin(0.4);
frame1->SetMinimum(MIN_VAL);
frame1->SetMaximum(MAX_VAL);
frame1->GetYaxis()->SetNdivisions(510);
frame1->GetXaxis()->SetTitleSize(0);
frame1->GetXaxis()->SetLabelSize(0);
frame1->GetYaxis()->SetTitle(TString::Format("Events / %1.1f GeV",BIN_SIZE));
frame1->Draw();
gPad->Update();
TList *list = (TList*)gPad->GetListOfPrimitives();
//list->Print();
TH1F *hUncH = new TH1F("hUncH"+ds_name,"hUncH"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
TH1F *hUncL = new TH1F("hUncL"+ds_name,"hUncL"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);