--- a/LimitFrequentist.cxx +++ b/LimitFrequentist.cxx @@ -121,9 +121,10 @@ LimitBase::LimitResult LimitFrequentist::GetLimit( RooWorkspace *ws, RooStats::M hypoCalc -> SetToys(m_nToys,m_nToys/10.);// null toys, alt toys RooStats::ToyMCSampler *toymcs = (RooStats::ToyMCSampler*)hypoCalc->GetTestStatSampler(); toymcs->SetTestStatistic(testStat); + RooStats::ProofConfig * pc = nullptr; if(m_nWorkers>0) { - RooStats::ProofConfig pc(*ws, m_nWorkers, "", false); - toymcs->SetProofConfig(&pc); // enable proof + pc = new RooStats::ProofConfig(*ws, m_nWorkers, "", false); + toymcs->SetProofConfig(pc); // enable proof } // @@ -151,5 +152,7 @@ LimitBase::LimitResult LimitFrequentist::GetLimit( RooWorkspace *ws, RooStats::M res.ExpP1s = m_pHTIR -> GetExpectedUpperLimit(1); res.ExpP2s = m_pHTIR -> GetExpectedUpperLimit(2); + if (pc) delete pc; + return res; }