本文整理汇总了C++中ToyMCSampler::SetUseMultiGen方法的典型用法代码示例。如果您正苦于以下问题:C++ ToyMCSampler::SetUseMultiGen方法的具体用法?C++ ToyMCSampler::SetUseMultiGen怎么用?C++ ToyMCSampler::SetUseMultiGen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToyMCSampler
的用法示例。
在下文中一共展示了ToyMCSampler::SetUseMultiGen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slrts
//.........这里部分代码省略.........
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)
toymcs->SetUseMultiGen(false);
ToyMCSampler::SetAlwaysUseMultiGen(false);
示例2: slrts
//.........这里部分代码省略.........
}
}
SimpleLikelihoodRatioTestStat slrts(*sbModel->GetPdf(),*bModel->GetPdf());
if (sbModel->GetSnapshot()) slrts.SetNullParameters(*sbModel->GetSnapshot());
if (bModel->GetSnapshot()) slrts.SetAltParameters(*bModel->GetSnapshot());
// ratio of profile likelihood - need to pass snapshot for the alt
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();