本文整理汇总了C++中ToyMCSampler::SetGenerateBinned方法的典型用法代码示例。如果您正苦于以下问题:C++ ToyMCSampler::SetGenerateBinned方法的具体用法?C++ ToyMCSampler::SetGenerateBinned怎么用?C++ ToyMCSampler::SetGenerateBinned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToyMCSampler
的用法示例。
在下文中一共展示了ToyMCSampler::SetGenerateBinned方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slrts
//.........这里部分代码省略.........
if (testStatType == 5) testStat = &maxll;
if (testStatType == 6) testStat = &nevtts;
if (testStat == 0) {
Error("StandardHypoTestInvDemo","Invalid - test statistic type = %d supported values are only :\n\t\t\t 0 (SLR) , 1 (Tevatron) , 2 (PLR), 3 (PLR1), 4(MLE)",testStatType);
return 0;
}
ToyMCSampler *toymcs = (ToyMCSampler*)hc->GetTestStatSampler();
if (toymcs && (type == 0 || type == 1) ) {
// look if pdf is number counting or extended
if (sbModel->GetPdf()->canBeExtended() ) {
if (useNumberCounting) Warning("StandardHypoTestInvDemo","Pdf is extended: but number counting flag is set: ignore it ");
}
else {
// for not extended pdf
if (!useNumberCounting ) {
int nEvents = data->numEntries();
Info("StandardHypoTestInvDemo","Pdf is not extended: number of events to generate taken from observed data set is %d",nEvents);
toymcs->SetNEventsPerToy(nEvents);
}
else {
Info("StandardHypoTestInvDemo","using a number counting pdf");
toymcs->SetNEventsPerToy(1);
}
}
toymcs->SetTestStatistic(testStat);
if (data->isWeighted() && !mGenerateBinned) {
Info("StandardHypoTestInvDemo","Data set is weighted, nentries = %d and sum of weights = %8.1f but toy generation is unbinned - it would be faster to set mGenerateBinned to true\n",data->numEntries(), data->sumEntries());
}
toymcs->SetGenerateBinned(mGenerateBinned);
toymcs->SetUseMultiGen(mOptimize);
if (mGenerateBinned && sbModel->GetObservables()->getSize() > 2) {
Warning("StandardHypoTestInvDemo","generate binned is activated but the number of ovservable is %d. Too much memory could be needed for allocating all the bins",sbModel->GetObservables()->getSize() );
}
// set the random seed if needed
if (mRandomSeed >= 0) RooRandom::randomGenerator()->SetSeed(mRandomSeed);
}
// specify if need to re-use same toys
if (reuseAltToys) {
hc->UseSameAltToys();
}
if (type == 1) {
HybridCalculator *hhc = dynamic_cast<HybridCalculator*> (hc);
assert(hhc);
hhc->SetToys(ntoys,ntoys/mNToysRatio); // can use less ntoys for b hypothesis
// remove global observables from ModelConfig (this is probably not needed anymore in 5.32)
bModel->SetGlobalObservables(RooArgSet() );
sbModel->SetGlobalObservables(RooArgSet() );
// check for nuisance prior pdf in case of nuisance parameters
if (bModel->GetNuisanceParameters() || sbModel->GetNuisanceParameters() ) {
// fix for using multigen (does not work in this case)
示例2: StandardHypoTestDemo
//.........这里部分代码省略.........
delete np;
((HybridCalculator*)hypoCalc)->ForcePriorNuisanceAlt(*nuisPdf);
((HybridCalculator*)hypoCalc)->ForcePriorNuisanceNull(*nuisPdf);
}
// hypoCalc->ForcePriorNuisanceAlt(*sbModel->GetPriorPdf());
// hypoCalc->ForcePriorNuisanceNull(*bModel->GetPriorPdf());
ToyMCSampler * sampler = (ToyMCSampler *)hypoCalc->GetTestStatSampler();
if (sampler && (calcType == 0 || calcType == 1) ) {
// look if pdf is number counting or extended
if (sbModel->GetPdf()->canBeExtended() ) {
if (useNC) Warning("StandardHypoTestDemo","Pdf is extended: but number counting flag is set: ignore it ");
}
else {
// for not extended pdf
if (!useNC) {
int nEvents = data->numEntries();
Info("StandardHypoTestDemo","Pdf is not extended: number of events to generate taken from observed data set is %d",nEvents);
sampler->SetNEventsPerToy(nEvents);
}
else {
Info("StandardHypoTestDemo","using a number counting pdf");
sampler->SetNEventsPerToy(1);
}
}
if (data->isWeighted() && !generateBinned) {
Info("StandardHypoTestDemo","Data set is weighted, nentries = %d and sum of weights = %8.1f but toy generation is unbinned - it would be faster to set generateBinned to true\n",data->numEntries(), data->sumEntries());
}
if (generateBinned) sampler->SetGenerateBinned(generateBinned);
// set the test statistic
if (testStatType == 0) sampler->SetTestStatistic(slrts);
if (testStatType == 1) sampler->SetTestStatistic(ropl);
if (testStatType == 2 || testStatType == 3) sampler->SetTestStatistic(profll);
}
HypoTestResult * htr = hypoCalc->GetHypoTest();
htr->SetPValueIsRightTail(true);
htr->SetBackgroundAsAlt(false);
htr->Print(); // how to get meaningfull CLs at this point?
delete sampler;
delete slrts;
delete ropl;
delete profll;
if (calcType != 2) {
HypoTestPlot * plot = new HypoTestPlot(*htr,100);
plot->SetLogYaxis(true);
plot->Draw();
}
else {
std::cout << "Asymptotic results " << std::endl;
}
// look at expected significances
// found median of S+B distribution
if (calcType != 2) {