本文整理汇总了C++中RooRealVar::getBinning方法的典型用法代码示例。如果您正苦于以下问题:C++ RooRealVar::getBinning方法的具体用法?C++ RooRealVar::getBinning怎么用?C++ RooRealVar::getBinning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooRealVar
的用法示例。
在下文中一共展示了RooRealVar::getBinning方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjustBinning
void THSEventsPDF::adjustBinning(Int_t* offset1) const
{
RooRealVar* xvar = fx_off ;
if (!dynamic_cast<RooRealVar*>(xvar)) {
coutE(InputArguments) << "RooDataHist::adjustBinning(" << GetName() << ") ERROR: dimension " << xvar->GetName() << " must be real" << endl ;
assert(0) ;
}
Double_t xlo = xvar->getMin() ;
Double_t xhi = xvar->getMax() ;
//adjust bin range limits with new scale parameter
//cout<<scale<<" "<<fMean<<" "<<xlo<<" "<<xhi<<endl;
xlo=(xlo-fMean)/scale+fMean;
xhi=(xhi-fMean)/scale+fMean;
if(xvar->getBinning().lowBound()==xlo&&xvar->getBinning().highBound()==xhi) return;
xvar->setRange(xlo,xhi) ;
// Int_t xmin(0) ;
// cout<<"THSEventsPDF::adjustBinning( "<<xlo <<" "<<xhi<<endl;
//now adjust fitting range to bin limits??Possibly not
if (fRHist->GetXaxis()->GetXbins()->GetArray()) {
RooBinning xbins(fRHist->GetNbinsX(),fRHist->GetXaxis()->GetXbins()->GetArray()) ;
Double_t tolerance = 1e-6*xbins.averageBinWidth() ;
// Adjust xlo/xhi to nearest boundary
Double_t xloAdj = xbins.binLow(xbins.binNumber(xlo+tolerance)) ;
Double_t xhiAdj = xbins.binHigh(xbins.binNumber(xhi-tolerance)) ;
xbins.setRange(xloAdj,xhiAdj) ;
xvar->setBinning(xbins) ;
if (fabs(xloAdj-xlo)>tolerance||fabs(xhiAdj-xhi)<tolerance) {
coutI(DataHandling) << "RooDataHist::adjustBinning(" << GetName() << "): fit range of variable " << xvar->GetName() << " expanded to nearest bin boundaries: ["
<< xlo << "," << xhi << "] --> [" << xloAdj << "," << xhiAdj << "]" << endl ;
}
} else {
RooBinning xbins(fRHist->GetXaxis()->GetXmin(),fRHist->GetXaxis()->GetXmax()) ;
xbins.addUniform(fRHist->GetNbinsX(),fRHist->GetXaxis()->GetXmin(),fRHist->GetXaxis()->GetXmax()) ;
Double_t tolerance = 1e-6*xbins.averageBinWidth() ;
// Adjust xlo/xhi to nearest boundary
Double_t xloAdj = xbins.binLow(xbins.binNumber(xlo+tolerance)) ;
Double_t xhiAdj = xbins.binHigh(xbins.binNumber(xhi-tolerance)) ;
xbins.setRange(xloAdj,xhiAdj) ;
xvar->setRange(xloAdj,xhiAdj) ;
//xvar->setRange(xlo,xhi) ;
}
return;
}
示例2: fabs
TGraphAsymmErrors *plotEffPt(RooDataSet *a, int aa) {
const RooArgSet *set = a->get();
RooRealVar *xAx = (RooRealVar*)set->find("pt");
RooRealVar *eff = (RooRealVar*)set->find("efficiency");
const int nbins = xAx->getBinning().numBins();
double tx[nbins], txhi[nbins], txlo[nbins];
double ty[nbins], tyhi[nbins], tylo[nbins];
for (int i=0; i<nbins; i++) {
a->get(i);
ty[i] = eff->getVal();
tx[i] = xAx->getVal();
txhi[i] = fabs(xAx->getErrorHi());
txlo[i] = fabs(xAx->getErrorLo());
tyhi[i] = fabs(eff->getErrorHi());
tylo[i] = fabs(eff->getErrorLo());
}
cout<<"NBins : "<<nbins<<endl;
const double *x = tx;
const double *xhi = txhi;
const double *xlo = txlo;
const double *y = ty;
const double *yhi = tyhi;
const double *ylo = tylo;
TGraphAsymmErrors *b = new TGraphAsymmErrors();
if(aa == 1) {
*b = TGraphAsymmErrors(nbins,x,y,xlo,xhi,ylo,yhi);
}
if(aa == 0) {
*b = TGraphAsymmErrors(nbins,x,y,0,0,ylo,yhi);
}
b->SetMaximum(1.1);
b->SetMinimum(0.0);
b->SetMarkerStyle(20);
b->SetMarkerColor(kRed+2);
b->SetMarkerSize(1.0);
b->SetTitle("");
b->GetXaxis()->SetTitleSize(0.05);
b->GetYaxis()->SetTitleSize(0.05);
b->GetXaxis()->SetTitle("p_{T} [GeV/c]");
b->GetYaxis()->SetTitle("Efficiency");
b->GetXaxis()->CenterTitle();
//b->Draw("apz");
for (int i=0; i<nbins; i++) {
cout << x[i] << " " << y[i] << " " << yhi[i] << " " << ylo[i] << endl;
}
return b;
}
示例3:
TH2F *plotEff2D(RooDataSet *a, TString b) {
const RooArgSet *set = a->get();
RooRealVar *yAx = (RooRealVar*)set->find("pt");
RooRealVar *xAx = (RooRealVar*)set->find("eta");
RooRealVar *eff = (RooRealVar*)set->find("efficiency");
// const int xnbins = xAx->getBinning().numBins();
// const int ynbins = yAx->getBinning().numBins();
//double xbins[] = {-2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4};
//double ybins[] = {0, 2, 3, 5, 8, 10, 20};
const double *xvbins = xAx->getBinning().array();
const double *yvbins = yAx->getBinning().array();
TH2F* h = new TH2F(b, "", xAx->getBinning().numBins(), xvbins, yAx->getBinning().numBins(), yvbins);
gStyle->SetPaintTextFormat("5.2f");
gStyle->SetPadRightMargin(0.12);
gStyle->SetPalette(1);
h->SetOption("colztexte");
h->GetZaxis()->SetRangeUser(-0.001,1.001);
h->SetStats(kFALSE);
h->GetYaxis()->SetTitle("p_{T} [GeV/c]");
h->GetXaxis()->SetTitle("#eta");
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->GetXaxis()->SetTitleSize(0.05);
h->GetYaxis()->SetTitleSize(0.05);
h->GetYaxis()->SetTitleOffset(0.8);
h->GetXaxis()->SetTitleOffset(0.9);
for(int i=0; i<a->numEntries(); i++) {
a->get(i);
h->SetBinContent(h->FindBin(xAx->getVal(), yAx->getVal()), eff->getVal());
h->SetBinError(h->FindBin(xAx->getVal(), yAx->getVal()), (eff->getErrorHi()-eff->getErrorLo())/2.);
}
return h;
}
示例4: ImportModelData
void GenericModel::ImportModelData(Int_t parameter_num, RooArgList* plist)
{
// Import all model datasets corresponding to the defined parameters, ranges & binnings
RooArgList PLIST;
if (plist) PLIST.addClone(*plist);
RooRealVar* par = dynamic_cast<RooRealVar*>(fParameters.at(parameter_num));
RooAbsBinning& bins = par->getBinning();
Int_t N = bins.numBins();
RooRealVar* par_in_list = (RooRealVar*)PLIST.find(par->GetName());
if (!par_in_list) {
PLIST.addClone(RooRealVar(par->GetName(), par->GetTitle(), 0.));
par_in_list = (RooRealVar*)PLIST.find(par->GetName());
}
for (int i = 0; i < N; i++) {
par_in_list->setMax(bins.binHigh(i));
par_in_list->setMin(bins.binLow(i));
par_in_list->setVal(bins.binCenter(i));
if ((parameter_num + 1) < GetNumberOfParameters())
ImportModelData(parameter_num + 1, &PLIST);
else {
AddModelData(PLIST, GetModelDataSet(PLIST));
}
}
}