本文整理汇总了C++中ModelConfig::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelConfig::Print方法的具体用法?C++ ModelConfig::Print怎么用?C++ ModelConfig::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelConfig
的用法示例。
在下文中一共展示了ModelConfig::Print方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StandardTestStatDistributionDemo
void StandardTestStatDistributionDemo(const char* infile = "",
const char* workspaceName = "combined",
const char* modelConfigName = "ModelConfig",
const char* dataName = "obsData"){
// the number of toy MC used to generate the distribution
int nToyMC = 1000;
// The parameter below is needed for asymptotic distribution to be chi-square,
// but set to false if your model is not numerically stable if mu<0
bool allowNegativeMu=true;
/////////////////////////////////////////////////////////////
// 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;
}
/////////////////////////////////////////////////////////////
// Now get the data and workspace
////////////////////////////////////////////////////////////
// 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;
}
mc->Print();
/////////////////////////////////////////////////////////////
// Now find the upper limit based on the asymptotic results
////////////////////////////////////////////////////////////
RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first();
ProfileLikelihoodCalculator plc(*data,*mc);
LikelihoodInterval* interval = plc.GetInterval();
double plcUpperLimit = interval->UpperLimit(*firstPOI);
delete interval;
cout << "\n\n--------------------------------------"<<endl;
cout <<"Will generate sampling distribution at " << firstPOI->GetName() << " = " << plcUpperLimit <<endl;
int nPOI = mc->GetParametersOfInterest()->getSize();
if(nPOI>1){
cout <<"not sure what to do with other parameters of interest, but here are their values"<<endl;
mc->GetParametersOfInterest()->Print("v");
}
/////////////////////////////////////////////
// create thte test stat sampler
ProfileLikelihoodTestStat ts(*mc->GetPdf());
// to avoid effects from boundary and simplify asymptotic comparison, set min=-max
if(allowNegativeMu)
firstPOI->setMin(-1*firstPOI->getMax());
// temporary RooArgSet
//.........这里部分代码省略.........
示例2: OneSidedFrequentistUpperLimitWithBands_intermediate
void OneSidedFrequentistUpperLimitWithBands_intermediate(const char* infile = "",
const char* workspaceName = "combined",
const char* modelConfigName = "ModelConfig",
const char* dataName = "obsData"){
double confidenceLevel=0.95;
// degrade/improve number of pseudo-experiments used to define the confidence belt.
// value of 1 corresponds to default number of toys in the tail, which is 50/(1-confidenceLevel)
double additionalToysFac = 1.;
int nPointsToScan = 30; // number of steps in the parameter of interest
int nToyMC = 100; // number of toys used to define the expected limit and band
TStopwatch t;
t.Start();
/////////////////////////////////////////////////////////////
// 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";
else
filename = infile;
// Check if example input file exists
TFile *file = TFile::Open(filename);
// if input file was specified byt not found, quit
if(!file && strcmp(infile,"")){
cout <<"file not found" << endl;
return;
}
// if default file not found, try to create it
if(!file ){
// 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;
}
// now try to access the file again
file = TFile::Open(filename);
if(!file){
// if it is still not there, then we can't continue
cout << "Not able to run hist2workspace to create example input" <<endl;
return;
}
/////////////////////////////////////////////////////////////
// Now get the data and workspace
////////////////////////////////////////////////////////////
// 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;
}
cout << "Found data and ModelConfig:" <<endl;
mc->Print();
/////////////////////////////////////////////////////////////
// Now get the POI for convenience
// you may want to adjust the range of your POI
////////////////////////////////////////////////////////////
RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first();
// firstPOI->setMin(0);
// firstPOI->setMax(10);
/////////////////////////////////////////////
// create and use the FeldmanCousins tool
// to find and plot the 95% confidence interval
// on the parameter of interest as specified
// in the model config
// REMEMBER, we will change the test statistic
// so this is NOT a Feldman-Cousins interval
FeldmanCousins fc(*data,*mc);
fc.SetConfidenceLevel(confidenceLevel);
fc.AdditionalNToysFactor(additionalToysFac); // improve sampling that defines confidence belt
// fc.UseAdaptiveSampling(true); // speed it up a bit, but don't use for expectd limits
fc.SetNBins(nPointsToScan); // set how many points per parameter of interest to scan
//.........这里部分代码省略.........
开发者ID:gerbaudo,项目名称:hlfv-fitmodel,代码行数:101,代码来源:OneSidedFrequentistUpperLimitWithBands_intermediate.C
示例3: ComputeTestStat
float ComputeTestStat(TString wsfile, double mu_susy_sig_val) {
gROOT->Reset();
TFile* wstf = new TFile( wsfile ) ;
RooWorkspace* ws = dynamic_cast<RooWorkspace*>( wstf->Get("ws") );
ws->Print() ;
ModelConfig* modelConfig = (ModelConfig*) ws->obj( "SbModel" ) ;
modelConfig->Print() ;
RooDataSet* rds = (RooDataSet*) ws->obj( "ra2b_observed_rds" ) ;
rds->Print() ;
rds->printMultiline(cout, 1, kTRUE, "") ;
RooAbsPdf* likelihood = modelConfig->GetPdf() ;
RooRealVar* rrv_mu_susy_sig = ws->var("mu_susy_all0lep") ;
if ( rrv_mu_susy_sig == 0x0 ) {
printf("\n\n\n *** can't find mu_susy_all0lep in workspace. Quitting.\n\n\n") ;
return ;
} else {
printf(" current value is : %8.3f\n", rrv_mu_susy_sig->getVal() ) ; cout << flush ;
rrv_mu_susy_sig->setConstant(kFALSE) ;
}
/*
// check the impact of varying the qcd normalization:
RooRealVar *rrv_qcd_0lepLDP_ratioH1 = ws->var("qcd_0lepLDP_ratio_H1");
RooRealVar *rrv_qcd_0lepLDP_ratioH2 = ws->var("qcd_0lepLDP_ratio_H2");
RooRealVar *rrv_qcd_0lepLDP_ratioH3 = ws->var("qcd_0lepLDP_ratio_H3");
rrv_qcd_0lepLDP_ratioH1->setVal(0.3);
rrv_qcd_0lepLDP_ratioH2->setVal(0.3);
rrv_qcd_0lepLDP_ratioH3->setVal(0.3);
rrv_qcd_0lepLDP_ratioH1->setConstant(kTRUE);
rrv_qcd_0lepLDP_ratioH2->setConstant(kTRUE);
rrv_qcd_0lepLDP_ratioH3->setConstant(kTRUE);
*/
printf("\n\n\n ===== Doing a fit with SUSY component floating ====================\n\n") ;
RooFitResult* fitResult = likelihood->fitTo( *rds, Save(true), PrintLevel(0) ) ;
double logLikelihoodSusyFloat = fitResult->minNll() ;
double logLikelihoodSusyFixed(0.) ;
double testStatVal(-1.) ;
if ( mu_susy_sig_val >= 0. ) {
printf("\n\n\n ===== Doing a fit with SUSY fixed ====================\n\n") ;
printf(" fixing mu_susy_sig to %8.2f.\n", mu_susy_sig_val ) ;
rrv_mu_susy_sig->setVal( mu_susy_sig_val ) ;
rrv_mu_susy_sig->setConstant(kTRUE) ;
fitResult = likelihood->fitTo( *rds, Save(true), PrintLevel(0) ) ;
logLikelihoodSusyFixed = fitResult->minNll() ;
testStatVal = 2.*(logLikelihoodSusyFixed - logLikelihoodSusyFloat) ;
printf("\n\n\n ======= test statistic : -2 * ln (L_fixed / ln L_max) = %8.3f\n\n\n", testStatVal ) ;
}
return testStatVal ;
}