本文整理汇总了C++中RooAbsReal::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ RooAbsReal::GetName方法的具体用法?C++ RooAbsReal::GetName怎么用?C++ RooAbsReal::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RooAbsReal
的用法示例。
在下文中一共展示了RooAbsReal::GetName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFlatNuisances
//#include <typeinfo.h>
void addFlatNuisances(std::string fi){
gSystem->Load("libHiggsAnalysisCombinedLimit.so");
TFile *fin = TFile::Open(fi.c_str());
RooWorkspace *wspace = (RooWorkspace*)fin->Get("w_hmumu");
wspace->Print("");
RooStats::ModelConfig *mc = (RooStats::ModelConfig*)wspace->genobj("ModelConfig");
RooArgSet *nuis = (RooArgSet*) mc->GetNuisanceParameters();
std::cout << "Before...." << std::endl;
nuis->Print();
RooRealVar *mgg = (RooRealVar*)wspace->var("mmm");
// Get all of the "flat" nuisances to be added to the nusiances:
RooArgSet pdfs = (RooArgSet) wspace->allVars();
RooAbsReal *pdf;
TIterator *it_pdf = pdfs.createIterator();
while ( (pdf=(RooAbsReal*)it_pdf->Next()) ){
if (!(std::string(pdf->GetName()).find("zmod") != std::string::npos )) {
if (!(std::string(pdf->GetName()).find("__norm") != std::string::npos )) {
continue;
}
}
pdf->Print();
RooArgSet* pdfpars = (RooArgSet*)pdf->getParameters(RooArgSet(*mgg));
pdfpars->Print();
std::string newname_pdf = (std::string("unconst_")+std::string(pdf->GetName()));
wspace->import(*pdf,RooFit::RenameVariable(pdf->GetName(),newname_pdf.c_str()));
pdf->SetName(newname_pdf.c_str());
nuis->add(*pdf);
}
wspace->var("MH")->setVal(125.0);
std::cout << "After..." << std::endl;
nuis->Print();
mc->SetNuisanceParameters(*nuis);
//RooWorkspace *wspace_new = wspace->Clone();
//mc->SetWorkspace(*wspace_new);
//wspace_new->import(*mc,true);
TFile *finew = new TFile((std::string(fin->GetName())+std::string("_unconst.root")).c_str(),"RECREATE");
//wspace_new->SetName("w");
finew->WriteTObject(wspace);
finew->Close();
}
示例2: RooAbsPdf
THSEventsPDF::THSEventsPDF(const char *name, const char *title,
RooAbsReal& _x,
RooAbsReal& _alpha,
RooAbsReal& _offset,
RooAbsReal& _scale,
Int_t NAlphBins ) :
RooAbsPdf(name,title),
x("x","x",this,_x),
offset("offset","offset",this,_offset),
scale("scale","scale",this,_scale),
alpha("alpha","alpha",this,_alpha),
fx_off(0),
falpha(0),
fHist(0),
fHistPdf(0),
fRHist(0),
fWeightHist(0),
fTree(0)
{
RooRealVar *rx=dynamic_cast<RooRealVar*>(&_x);
RooRealVar *ra=dynamic_cast<RooRealVar*>(&_alpha);
RooRealVar *rs=dynamic_cast<RooRealVar*>(&_scale);
RooRealVar *ro=dynamic_cast<RooRealVar*>(&_offset);
//Work out number of bins for x axis
//Take bin width as being 1/10 of the alpha range (arbitrary!) or 100 whichever is larger
// NbinX=40;
Double_t rsmin=1;
fOldScale=rs->getVal();
if(rs->getMin()) rsmin=rs->getMin();
else cout<<"THSEventsPDF::THSEventsPDF Warning no scale minimum set take = 1"<<endl;
Double_t mid=(rx->getMax()+rx->getMin())/2;
Double_t diff=(rx->getMax()-rx->getMin())/2;
Double_t rMin=mid-diff/rsmin - ro->getMin(); //additional range for possible tranformation or scaling
Double_t rMax=mid+diff/rsmin + ro->getMax();
Int_t NbinX=200/rsmin;
cout<<GetName()<<" hist ranges "<<rMin<<" to "<<rMax<<endl;
if(NbinX<10) NbinX=10;
fRHist=new TH2F(TString("hmc_model_")+_x.GetName()+name,TString("MC model for ")+_x.GetName(),NbinX,rMin,rMax,NAlphBins,ra->getMin(),ra->getMax());
fRHist->Sumw2();
// fRHist=new TH2F(TString("hmc_model_")+_x.GetName()+name,TString("MC model for ")+_x.GetName(),NbinX,rx->getMin(),rx->getMax(),NAlphBins,ra->getMin(),ra->getMax());
fx=new RooRealVar(_x.GetName(),"Vx",0,x.min(),x.max());
fx_off=new RooRealVar(_x.GetName(),"Vx_off",0,rMin,rMax);
falpha=new RooRealVar("Valpha","Valpha",0,alpha.min(),alpha.max());
fNWdim=0;
}
示例3: fillInitialNorms
// grab the initial normalization from a datacard converted in workspace
// with: scripts/text2workspace.py -b -o model.root datacards/hww-12.1fb.mH125.comb_0j1j2j_shape.txt
void fillInitialNorms(RooArgSet *args, std::map<std::string, std::pair<double,double> > &vals, std::string workspace){
TFile *fw_ = TFile::Open(workspace.c_str());
RooWorkspace *ws = (RooWorkspace*)fw_->Get("w");
TIterator* iter(args->createIterator());
for (TObject *a = iter->Next(); a != 0; a = iter->Next()) {
RooAbsReal *rar = (RooAbsReal*)ws->obj(a->GetName());
std::string name = rar->GetName();
std::pair<double,double> valE(rar->getVal(),0.0);
vals.insert( std::pair<std::string,std::pair<double ,double> > (name,valE)) ;
}
}
示例4: constrained_scan
void constrained_scan( const char* wsfile = "outputfiles/ws.root",
const char* new_poi_name="mu_bg_4b_msig_met1",
double constraintWidth=1.5,
int npoiPoints = 20,
double poiMinVal = 0.,
double poiMaxVal = 10.0,
double ymax = 9.,
int verbLevel=1 ) {
TString outputdir("outputfiles") ;
gStyle->SetOptStat(0) ;
TFile* wstf = new TFile( wsfile ) ;
RooWorkspace* ws = dynamic_cast<RooWorkspace*>( wstf->Get("ws") );
ws->Print() ;
RooDataSet* rds = (RooDataSet*) ws->obj( "hbb_observed_rds" ) ;
cout << "\n\n\n ===== RooDataSet ====================\n\n" << endl ;
rds->Print() ;
rds->printMultiline(cout, 1, kTRUE, "") ;
RooRealVar* rv_sig_strength = ws->var("sig_strength") ;
if ( rv_sig_strength == 0x0 ) { printf("\n\n *** can't find sig_strength in workspace.\n\n" ) ; return ; }
RooAbsPdf* likelihood = ws->pdf("likelihood") ;
if ( likelihood == 0x0 ) { printf("\n\n *** can't find likelihood in workspace.\n\n" ) ; return ; }
printf("\n\n Likelihood:\n") ;
likelihood -> Print() ;
/////rv_sig_strength -> setConstant( kFALSE ) ;
rv_sig_strength -> setVal(0.) ;
rv_sig_strength -> setConstant( kTRUE ) ;
likelihood->fitTo( *rds, Save(false), PrintLevel(0), Hesse(true), Strategy(1) ) ;
//RooFitResult* fitResult = likelihood->fitTo( *rds, Save(true), PrintLevel(0), Hesse(true), Strategy(1) ) ;
//double minNllSusyFloat = fitResult->minNll() ;
//double susy_ss_atMinNll = rv_sig_strength -> getVal() ;
RooMsgService::instance().getStream(1).removeTopic(Minimization) ;
RooMsgService::instance().getStream(1).removeTopic(Fitting) ;
//-- Construct the new POI parameter.
RooAbsReal* new_poi_rar(0x0) ;
new_poi_rar = ws->var( new_poi_name ) ;
if ( new_poi_rar == 0x0 ) {
printf("\n\n New POI %s is not a variable. Trying function.\n\n", new_poi_name ) ;
new_poi_rar = ws->function( new_poi_name ) ;
if ( new_poi_rar == 0x0 ) {
printf("\n\n New POI %s is not a function. I quit.\n\n", new_poi_name ) ;
return ;
} else {
printf("\n Found it.\n\n") ;
}
} else {
printf("\n\n New POI %s is a variable with current value %.1f.\n\n", new_poi_name, new_poi_rar->getVal() ) ;
}
double startPoiVal = new_poi_rar->getVal() ;
RooAbsReal* nll = likelihood -> createNLL( *rds, Verbose(true) ) ;
RooRealVar* rrv_poiValue = new RooRealVar( "poiValue", "poiValue", 0., -10000., 10000. ) ;
RooRealVar* rrv_constraintWidth = new RooRealVar("constraintWidth","constraintWidth", 0.1, 0.1, 1000. ) ;
rrv_constraintWidth -> setVal( constraintWidth ) ;
rrv_constraintWidth -> setConstant(kTRUE) ;
RooMinuit* rminuit( 0x0 ) ;
RooMinuit* rminuit_uc = new RooMinuit( *nll ) ;
rminuit_uc->setPrintLevel(verbLevel-1) ;
rminuit_uc->setNoWarn() ;
rminuit_uc->migrad() ;
rminuit_uc->hesse() ;
RooFitResult* rfr_uc = rminuit_uc->fit("mr") ;
double floatParInitVal[10000] ;
char floatParName[10000][100] ;
int nFloatParInitVal(0) ;
RooArgList ral_floats = rfr_uc->floatParsFinal() ;
TIterator* floatParIter = ral_floats.createIterator() ;
{
RooRealVar* par ;
while ( (par = (RooRealVar*) floatParIter->Next()) ) {
sprintf( floatParName[nFloatParInitVal], "%s", par->GetName() ) ;
floatParInitVal[nFloatParInitVal] = par->getVal() ;
nFloatParInitVal++ ;
}
//.........这里部分代码省略.........
示例5: outputdir
//.........这里部分代码省略.........
likelihood->Print("v") ;
printf("\n\n ======= debug nll print\n\n") ;
nll->Print("v") ;
}
//----------------------------------------------------------------------------------------------
RooMinuit* rminuit( 0x0 ) ;
RooMinuit* rminuit_uc = new RooMinuit( *nll ) ;
rminuit_uc->setPrintLevel(verbLevel-1) ;
rminuit_uc->setNoWarn() ;
rminuit_uc->migrad() ;
rminuit_uc->hesse() ;
RooFitResult* rfr_uc = rminuit_uc->fit("mr") ;
double floatParInitVal[10000] ;
char floatParName[10000][100] ;
int nFloatParInitVal(0) ;
RooArgList ral_floats = rfr_uc->floatParsFinal() ;
TIterator* floatParIter = ral_floats.createIterator() ;
{
RooRealVar* par ;
while ( (par = (RooRealVar*) floatParIter->Next()) ) {
sprintf( floatParName[nFloatParInitVal], "%s", par->GetName() ) ;
floatParInitVal[nFloatParInitVal] = par->getVal() ;
nFloatParInitVal++ ;
}
}
//-------
printf("\n\n Unbiased best value for new POI %s is : %7.1f\n\n", new_poi_rar->GetName(), new_poi_rar->getVal() ) ;
double best_poi_val = new_poi_rar->getVal() ;
char minuit_formula[10000] ;
sprintf( minuit_formula, "%s+%s*(%s-%s)*(%s-%s)",
nll->GetName(),
rrv_constraintWidth->GetName(),
new_poi_rar->GetName(), rrv_poiValue->GetName(),
new_poi_rar->GetName(), rrv_poiValue->GetName()
) ;
printf("\n\n Creating new minuit variable with formula: %s\n\n", minuit_formula ) ;
RooFormulaVar* new_minuit_var = new RooFormulaVar("new_minuit_var", minuit_formula,
RooArgList( *nll,
*rrv_constraintWidth,
*new_poi_rar, *rrv_poiValue,
*new_poi_rar, *rrv_poiValue
) ) ;
printf("\n\n Current value is %.2f\n\n",
new_minuit_var->getVal() ) ;
rminuit = new RooMinuit( *new_minuit_var ) ;