本文整理汇总了C++中ToyMCSampler::SetProofConfig方法的典型用法代码示例。如果您正苦于以下问题:C++ ToyMCSampler::SetProofConfig方法的具体用法?C++ ToyMCSampler::SetProofConfig怎么用?C++ ToyMCSampler::SetProofConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToyMCSampler
的用法示例。
在下文中一共展示了ToyMCSampler::SetProofConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slrts
//.........这里部分代码省略.........
nuisPdf = RooStats::MakeNuisancePdf(*sbModel,"nuisancePdf_sbmodel");
}
if (!nuisPdf ) {
if (bModel->GetPriorPdf()) {
nuisPdf = bModel->GetPriorPdf();
Info("StandardHypoTestInvDemo","No nuisance pdf given - try to use %s that is defined as a prior pdf in the B model",nuisPdf->GetName());
}
else {
Error("StandardHypoTestInvDemo","Cannnot run Hybrid calculator because no prior on the nuisance parameter is specified or can be derived");
return 0;
}
}
assert(nuisPdf);
Info("StandardHypoTestInvDemo","Using as nuisance Pdf ... " );
nuisPdf->Print();
const RooArgSet * nuisParams = (bModel->GetNuisanceParameters() ) ? bModel->GetNuisanceParameters() : sbModel->GetNuisanceParameters();
RooArgSet * np = nuisPdf->getObservables(*nuisParams);
if (np->getSize() == 0) {
Warning("StandardHypoTestInvDemo","Prior nuisance does not depend on nuisance parameters. They will be smeared in their full range");
}
delete np;
hhc->ForcePriorNuisanceAlt(*nuisPdf);
hhc->ForcePriorNuisanceNull(*nuisPdf);
}
}
else if (type == 2 || type == 3) {
if (testStatType == 3) ((AsymptoticCalculator*) hc)->SetOneSided(true);
if (testStatType != 2 && testStatType != 3)
Warning("StandardHypoTestInvDemo","Only the PL test statistic can be used with AsymptoticCalculator - use by default a two-sided PL");
}
else if (type == 0 || type == 1)
((FrequentistCalculator*) hc)->SetToys(ntoys,ntoys/mNToysRatio);
// Get the result
RooMsgService::instance().getStream(1).removeTopic(RooFit::NumIntegration);
HypoTestInverter calc(*hc);
calc.SetConfidenceLevel(0.95);
calc.UseCLs(useCLs);
calc.SetVerbose(true);
// can speed up using proof-lite
if (mUseProof && mNWorkers > 1) {
ProofConfig pc(*w, mNWorkers, "", kFALSE);
toymcs->SetProofConfig(&pc); // enable proof
}
if (npoints > 0) {
if (poimin > poimax) {
// if no min/max given scan between MLE and +4 sigma
poimin = int(poihat);
poimax = int(poihat + 4 * poi->getError());
}
std::cout << "Doing a fixed scan in interval : " << poimin << " , " << poimax << std::endl;
calc.SetFixedScan(npoints,poimin,poimax);
}
else {
//poi->setMax(10*int( (poihat+ 10 *poi->getError() )/10 ) );
std::cout << "Doing an automatic scan in interval : " << poi->getMin() << " , " << poi->getMax() << std::endl;
}
tw.Start();
HypoTestInverterResult * r = calc.GetInterval();
std::cout << "Time to perform limit scan \n";
tw.Print();
if (mRebuild) {
calc.SetCloseProof(1);
tw.Start();
SamplingDistribution * limDist = calc.GetUpperLimitDistribution(true,mNToyToRebuild);
std::cout << "Time to rebuild distributions " << std::endl;
tw.Print();
if (limDist) {
std::cout << "expected up limit " << limDist->InverseCDF(0.5) << " +/- "
<< limDist->InverseCDF(0.16) << " "
<< limDist->InverseCDF(0.84) << "\n";
//update r to a new updated result object containing the rebuilt expected p-values distributions
// (it will not recompute the expected limit)
if (r) delete r; // need to delete previous object since GetInterval will return a cloned copy
r = calc.GetInterval();
}
else
std::cout << "ERROR : failed to re-build distributions " << std::endl;
}
return r;
}
示例2: slrts
//.........这里部分代码省略.........
RatioOfProfiledLikelihoodsTestStat
ropl(*sbModel->GetPdf(), *bModel->GetPdf(), bModel->GetSnapshot());
ropl.SetSubtractMLE(false);
//MyProfileLikelihoodTestStat profll(*sbModel->GetPdf());
ProfileLikelihoodTestStat profll(*sbModel->GetPdf());
if (testStatType == 3) profll.SetOneSided(1);
if (optimize) profll.SetReuseNLL(true);
TestStatistic * testStat = &slrts;
if (testStatType == 1) testStat = &ropl;
if (testStatType == 2 || testStatType == 3) testStat = &profll;
HypoTestCalculatorGeneric * hc = 0;
if (type == 0) hc = new FrequentistCalculator(*data, *bModel, *sbModel);
else hc = new HybridCalculator(*data, *bModel, *sbModel);
ToyMCSampler *toymcs = (ToyMCSampler*)hc->GetTestStatSampler();
//=== DEBUG
///// toymcs->SetWS( w ) ;
//=== DEBUG
toymcs->SetNEventsPerToy(1);
toymcs->SetTestStatistic(testStat);
if (optimize) toymcs->SetUseMultiGen(true);
if (type == 1) {
HybridCalculator *hhc = (HybridCalculator*) hc;
hhc->SetToys(ntoys,ntoys);
// check for nuisance prior pdf
if (bModel->GetPriorPdf() && sbModel->GetPriorPdf() ) {
hhc->ForcePriorNuisanceAlt(*bModel->GetPriorPdf());
hhc->ForcePriorNuisanceNull(*sbModel->GetPriorPdf());
}
else {
if (bModel->GetNuisanceParameters() || sbModel->GetNuisanceParameters() ) {
Error("RA2bHypoTestInvDemo","Cannnot run Hybrid calculator because no prior on the nuisance parameter is specified");
return 0;
}
}
}
else
((FrequentistCalculator*) hc)->SetToys(ntoys,ntoys);
// Get the result
RooMsgService::instance().getStream(1).removeTopic(RooFit::NumIntegration);
TStopwatch tw; tw.Start();
const RooArgSet * poiSet = sbModel->GetParametersOfInterest();
RooRealVar *poi = (RooRealVar*)poiSet->first();
// fit the data first
sbModel->GetPdf()->fitTo(*data);
double poihat = poi->getVal();
HypoTestInverter calc(*hc);
calc.SetConfidenceLevel(0.95);
calc.UseCLs(useCls);
calc.SetVerbose(true);
// can speed up using proof-lite
if (useProof && nworkers > 1) {
ProofConfig pc(*w, nworkers, "", kFALSE);
toymcs->SetProofConfig(&pc); // enable proof
}
printf(" npoints = %d, poimin = %7.2f, poimax = %7.2f\n\n", npoints, poimin, poimax ) ;
cout << flush ;
if ( npoints==1 ) {
std::cout << "Evaluating one point : " << poimax << std::endl;
calc.RunOnePoint(poimax);
} else if (npoints > 0) {
if (poimin >= poimax) {
// if no min/max given scan between MLE and +4 sigma
poimin = int(poihat);
poimax = int(poihat + 4 * poi->getError());
}
std::cout << "Doing a fixed scan in interval : " << poimin << " , " << poimax << std::endl;
calc.SetFixedScan(npoints,poimin,poimax);
}
else {
//poi->setMax(10*int( (poihat+ 10 *poi->getError() )/10 ) );
std::cout << "Doing an automatic scan in interval : " << poi->getMin() << " , " << poi->getMax() << std::endl;
}
cout << "\n\n right before calc.GetInterval(), ntoys = " << ntoys << " \n\n" << flush ;
HypoTestInverterResult * r = calc.GetInterval();
return r;
}
示例3: OneSidedFrequentistUpperLimitWithBands
//.........这里部分代码省略.........
// but the tool takes care of a few things for us like which values
// of the nuisance parameters should be used to generate toys.
// so let's just change the test statistic and realize this is
// no longer "Feldman-Cousins" but is a fully frequentist Neyman-Construction.
/* ProfileLikelihoodTestStatModified onesided(*mc->GetPdf());*/
/* fc.GetTestStatSampler()->SetTestStatistic(&onesided);*/
/* ((ToyMCSampler*) fc.GetTestStatSampler())->SetGenerateBinned(true); */
ToyMCSampler* toymcsampler = (ToyMCSampler*) fc.GetTestStatSampler();
ProfileLikelihoodTestStat* testStat = dynamic_cast<ProfileLikelihoodTestStat*>(toymcsampler->GetTestStatistic());
testStat->SetOneSided(true);
// Since this tool needs to throw toy MC the PDF needs to be
// extended or the tool needs to know how many entries in a dataset
// per pseudo experiment.
// In the 'number counting form' where the entries in the dataset
// are counts, and not values of discriminating variables, the
// datasets typically only have one entry and the PDF is not
// extended.
if(!mc->GetPdf()->canBeExtended()){
if(data->numEntries()==1)
fc.FluctuateNumDataEntries(false);
else
cout <<"Not sure what to do about this model" <<endl;
}
// We can use PROOF to speed things along in parallel
// However, the test statistic has to be installed on the workers
// so either turn off PROOF or include the modified test statistic
// in your `$ROOTSYS/roofit/roostats/inc` directory,
// add the additional line to the LinkDef.h file,
// and recompile root.
if (useProof) {
ProofConfig pc(*w, nworkers, "", false);
toymcsampler->SetProofConfig(&pc); // enable proof
}
if(mc->GetGlobalObservables()){
cout << "will use global observables for unconditional ensemble"<<endl;
mc->GetGlobalObservables()->Print();
toymcsampler->SetGlobalObservables(*mc->GetGlobalObservables());
}
// Now get the interval
PointSetInterval* interval = fc.GetInterval();
ConfidenceBelt* belt = fc.GetConfidenceBelt();
// print out the interval on the first Parameter of Interest
cout << "\n95% interval on " <<firstPOI->GetName()<<" is : ["<<
interval->LowerLimit(*firstPOI) << ", "<<
interval->UpperLimit(*firstPOI) <<"] "<<endl;
// get observed UL and value of test statistic evaluated there
RooArgSet tmpPOI(*firstPOI);
double observedUL = interval->UpperLimit(*firstPOI);
firstPOI->setVal(observedUL);
double obsTSatObsUL = fc.GetTestStatSampler()->EvaluateTestStatistic(*data,tmpPOI);
// Ask the calculator which points were scanned
RooDataSet* parameterScan = (RooDataSet*) fc.GetPointsToScan();
RooArgSet* tmpPoint;
// make a histogram of parameter vs. threshold
TH1F* histOfThresholds = new TH1F("histOfThresholds","",
parameterScan->numEntries(),
示例4: OneSidedFrequentistUpperLimitWithBands_intermediate
//.........这里部分代码省略.........
// ProfileLikelihoodTestStatModified onesided(*mc->GetPdf());
// fc.GetTestStatSampler()->SetTestStatistic(&onesided);
// ((ToyMCSampler*) fc.GetTestStatSampler())->SetGenerateBinned(true);
ToyMCSampler* toymcsampler = (ToyMCSampler*) fc.GetTestStatSampler();
ProfileLikelihoodTestStat* testStat = dynamic_cast<ProfileLikelihoodTestStat*>(toymcsampler->GetTestStatistic());
testStat->SetOneSided(true);
// test speedups:
testStat->SetReuseNLL(true);
// toymcsampler->setUseMultiGen(true); // not fully validated
// Since this tool needs to throw toy MC the PDF needs to be
// extended or the tool needs to know how many entries in a dataset
// per pseudo experiment.
// In the 'number counting form' where the entries in the dataset
// are counts, and not values of discriminating variables, the
// datasets typically only have one entry and the PDF is not
// extended.
if(!mc->GetPdf()->canBeExtended()){
if(data->numEntries()==1)
fc.FluctuateNumDataEntries(false);
else
cout <<"Not sure what to do about this model" <<endl;
}
// We can use PROOF to speed things along in parallel
ProofConfig pc(*w, 4, "",false);
if(mc->GetGlobalObservables()){
cout << "will use global observables for unconditional ensemble"<<endl;
mc->GetGlobalObservables()->Print();
toymcsampler->SetGlobalObservables(*mc->GetGlobalObservables());
}
toymcsampler->SetProofConfig(&pc); // enable proof
// Now get the interval
PointSetInterval* interval = fc.GetInterval();
ConfidenceBelt* belt = fc.GetConfidenceBelt();
// print out the iterval on the first Parameter of Interest
cout << "\n95% interval on " <<firstPOI->GetName()<<" is : ["<<
interval->LowerLimit(*firstPOI) << ", "<<
interval->UpperLimit(*firstPOI) <<"] "<<endl;
// get observed UL and value of test statistic evaluated there
RooArgSet tmpPOI(*firstPOI);
double observedUL = interval->UpperLimit(*firstPOI);
firstPOI->setVal(observedUL);
double obsTSatObsUL = fc.GetTestStatSampler()->EvaluateTestStatistic(*data,tmpPOI);
// Ask the calculator which points were scanned
RooDataSet* parameterScan = (RooDataSet*) fc.GetPointsToScan();
RooArgSet* tmpPoint;
// make a histogram of parameter vs. threshold
TH1F* histOfThresholds = new TH1F("histOfThresholds","",
parameterScan->numEntries(),
firstPOI->getMin(),
firstPOI->getMax());
histOfThresholds->GetXaxis()->SetTitle(firstPOI->GetName());
histOfThresholds->GetYaxis()->SetTitle("Threshold");
// loop through the points that were tested and ask confidence belt
// what the upper/lower thresholds were.
开发者ID:gerbaudo,项目名称:hlfv-fitmodel,代码行数:67,代码来源:OneSidedFrequentistUpperLimitWithBands_intermediate.C