本文整理汇总了C++中ToyMCSampler::SetMaxToys方法的典型用法代码示例。如果您正苦于以下问题:C++ ToyMCSampler::SetMaxToys方法的具体用法?C++ ToyMCSampler::SetMaxToys怎么用?C++ ToyMCSampler::SetMaxToys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToyMCSampler
的用法示例。
在下文中一共展示了ToyMCSampler::SetMaxToys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frequentist
//void RunToyScan5(TString fileName, double startVal, double stopVal, TString outFile) {
void frequentist(TString fileName) {
cout << "Starting frequentist " << time(NULL) << endl;
double startVal = 0;
double stopVal = 200;
TString outFile = "";
int nToys = 1 ;
int nscanpoints = 2 ;
/*
gROOT->LoadMacro("RooBetaPdf.cxx+") ;
gROOT->LoadMacro("RooRatio.cxx+") ;
gROOT->LoadMacro("RooPosDefCorrGauss.cxx+") ;
*/
// get relevant objects out of the "ws" file
TFile *file = TFile::Open(fileName);
if(!file){
cout <<"file not found" << endl;
return;
}
RooWorkspace* w = (RooWorkspace*) file->Get("workspace");
if(!w){
cout <<"workspace not found" << endl;
return;
}
ModelConfig* mc = (ModelConfig*) w->obj("S+B_model");
RooAbsData* data = w->data("data");
if( !data || !mc ){
w->Print();
cout << "data or ModelConfig was not found" <<endl;
return;
}
RooRealVar* myPOI = (RooRealVar*) mc->GetParametersOfInterest()->first();
myPOI->setRange(0, 1000.);
ModelConfig* bModel = (ModelConfig*) w->obj("B_model");
ModelConfig* sbModel = (ModelConfig*) w->obj("S+B_model");
ProfileLikelihoodTestStat profll(*sbModel->GetPdf());
profll.SetPrintLevel(2);
profll.SetOneSided(1);
TestStatistic * testStat = &profll;
HypoTestCalculatorGeneric * hc = 0;
hc = new FrequentistCalculator(*data, *bModel, *sbModel);
ToyMCSampler *toymcs = (ToyMCSampler*)hc->GetTestStatSampler();
toymcs->SetMaxToys(10000);
toymcs->SetNEventsPerToy(1);
toymcs->SetTestStatistic(testStat);
((FrequentistCalculator *)hc)->SetToys(nToys,nToys);
HypoTestInverter calc(*hc);
calc.SetConfidenceLevel(0.95);
calc.UseCLs(true);
//calc.SetVerbose(true);
calc.SetVerbose(2);
cout << "About to set fixed scan " << time(NULL) << endl;
calc.SetFixedScan(nscanpoints,startVal,stopVal);
cout << "About to do inverter " << time(NULL) << endl;
HypoTestInverterResult * res_toysCLs_calculator = calc.GetInterval();
cout << "CLs = " << res_toysCLs_calculator->UpperLimit()
<< " CLs_exp = " << res_toysCLs_calculator->GetExpectedUpperLimit(0)
<< " CLs_exp(-1s) = " << res_toysCLs_calculator->GetExpectedUpperLimit(-1)
<< " CLs_exp(+1s) = " << res_toysCLs_calculator->GetExpectedUpperLimit(1) << endl ;
/*
// dump results string to output file
ofstream outStream ;
outStream.open(outFile,ios::app) ;
outStream << "CLs = " << res_toysCLs_calculator->UpperLimit()
<< " CLs_exp = " << res_toysCLs_calculator->GetExpectedUpperLimit(0)
<< " CLs_exp(-1s) = " << res_toysCLs_calculator->GetExpectedUpperLimit(-1)
<< " CLs_exp(+1s) = " << res_toysCLs_calculator->GetExpectedUpperLimit(1) << endl ;
outStream.close() ;
*/
cout << "End of frequentist " << time(NULL) << endl;
return ;
}