Skip to content

Commit

Permalink
Merge pull request cms-sw#103 from gpetruc/fix_significance_discrete_…
Browse files Browse the repository at this point in the history
…toys

Closes cms-sw#95
  • Loading branch information
adavidzh committed Feb 19, 2014
2 parents 14cbd12 + 2eb7e4f commit d695ca1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/HybridNew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ float HybridNew::adaptiveToys_ = -1;
bool HybridNew::reportPVal_ = false;
float HybridNew::confidenceToleranceForToyScaling_ = 0.2;
float HybridNew::maxProbability_ = 0.999;
#define EPS 1e-9
#define EPS 1e-6

HybridNew::HybridNew() :
LimitAlgo("HybridNew specific options") {
Expand Down Expand Up @@ -291,7 +291,7 @@ bool HybridNew::runSignificance(RooWorkspace *w, RooStats::ModelConfig *mc_s, Ro
}
if (expectedFromGrid_) applyExpectedQuantile(*hcResult);
// I don't need to flip the P-values for significances, only for limits
hcResult->SetTestStatisticData(hcResult->GetTestStatisticData()+EPS); // issue with < vs <= in discrete models
hcResult->SetTestStatisticData(hcResult->GetTestStatisticData()-EPS); // issue with < vs <= in discrete models
double sig = hcResult->Significance();
double sigHi = RooStats::PValueToSignificance( (hcResult->CLb() - hcResult->CLbError()) ) - sig;
double sigLo = RooStats::PValueToSignificance( (hcResult->CLb() + hcResult->CLbError()) ) - sig;
Expand Down Expand Up @@ -643,6 +643,7 @@ std::auto_ptr<RooStats::HybridCalculator> HybridNew::create(RooWorkspace *w, Roo

RooArgSet poi(*mc_s->GetParametersOfInterest()), params(poi);
RooRealVar *r = dynamic_cast<RooRealVar *>(poi.first());
double rValOriginal = ((RooAbsReal*)rVals.first())->getVal();

if (poi.getSize() == 1) { // here things are a bit more convoluted, although they could probably be cleaned up
double rVal = ((RooAbsReal*)rVals.first())->getVal();
Expand Down Expand Up @@ -770,7 +771,14 @@ std::auto_ptr<RooStats::HybridCalculator> HybridNew::create(RooWorkspace *w, Roo
}
if (fitNuisances_ && paramsToFit.get()) { params.add(*paramsToFit); fitMu.writeTo(params); }
if (fitNuisances_ && paramsToFit.get()) { paramsZero.addClone(*paramsToFit); fitZero.writeTo(paramsZero); }
setup.modelConfig.SetSnapshot(params);
if (poi.getSize() == 1 && r->getVal() != rValOriginal) {
double rTmp = r->getVal();
r->setVal(rValOriginal);
setup.modelConfig.SetSnapshot(params);
r->setVal(rTmp);
} else {
setup.modelConfig.SetSnapshot(params);
}
setup.modelConfig_bonly.SetSnapshot(paramsZero);
TString paramsSnapName = TString::Format("%s_%s_snapshot", setup.modelConfig.GetName(), params.GetName());
TString paramsZSnapName = TString::Format("%s__snapshot", setup.modelConfig_bonly.GetName());
Expand Down

0 comments on commit d695ca1

Please sign in to comment.