84template<
class HypoTestType>
87 static void SetToys(HypoTestType *
h,
int toyNull,
int toyAlt) {
h->SetToys(toyNull,toyAlt); }
119 if (!modelSB || ! modelB)
120 oocoutF(
nullptr,InputArguments) <<
"HypoTestInverter - model are not existing" << std::endl;
121 assert(modelSB && modelB);
123 oocoutI(
nullptr,InputArguments) <<
"HypoTestInverter ---- Input models: \n"
124 <<
"\t\t using as S+B (null) model : "
126 <<
"\t\t using as B (alternate) model : "
127 << modelB->
GetName() <<
"\n" << std::endl;
132 if (!bPdf || !bObs) {
133 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - B model has no pdf or observables defined" << std::endl;
136 std::unique_ptr<RooArgSet> bParams{bPdf->
getParameters(*bObs)};
138 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - pdf of B model has no parameters" << std::endl;
141 if (bParams->find(scanVariable.
GetName() ) ) {
143 if (!poiB || !poiB->
find(scanVariable.
GetName()) ||
145 oocoutW(
nullptr, InputArguments)
146 <<
"HypoTestInverter - using a B model with POI " << scanVariable.
GetName() <<
" not equal to zero "
147 <<
" user must check input model configurations " << endl;
149 if (poiB)
delete poiB;
159 fCalculator0(nullptr),
160 fScannedVariable(nullptr),
166 fCalcType(kUndefined),
167 fNBins(0), fXmin(1), fXmax(1),
185 fCalculator0(nullptr),
186 fScannedVariable(scannedVariable),
192 fCalcType(kUndefined),
193 fNBins(0), fXmin(1), fXmax(1),
201 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Cannot guess the variable to scan " << std::endl;
224 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Type of hypotest calculator is not supported " <<std::endl;
240 fScannedVariable(scannedVariable),
247 fNBins(0), fXmin(1), fXmax(1),
255 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Cannot guess the variable to scan " << std::endl;
273 fScannedVariable(scannedVariable),
279 fCalcType(kFrequentist),
280 fNBins(0), fXmin(1), fXmax(1),
288 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Cannot guess the variable to scan " << std::endl;
306 fScannedVariable(scannedVariable),
312 fCalcType(kAsymptotic),
313 fNBins(0), fXmin(1), fXmax(1),
321 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Cannot guess the variable to scan " << std::endl;
338 fCalculator0(nullptr),
339 fScannedVariable(scannedVariable),
346 fNBins(0), fXmin(1), fXmax(1),
358 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - Cannot guess the variable to scan " << std::endl;
373 fCalculator0(nullptr), fScannedVariable(nullptr),
386 if (
this == &rhs)
return *
this;
451 TString results_name =
"result_";
454 TString title =
"HypoTestInverter Result For ";
485 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::GetInterval - return an already existing interval " << std::endl;
490 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::GetInterval - run a fixed scan" << std::endl;
493 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::GetInterval - error running a fixed scan " << std::endl;
496 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::GetInterval - run an automatic scan" << std::endl;
501 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::GetInterval - error running an auto scan " << std::endl;
524 if (hcResult ==
nullptr) {
525 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::Eval - HypoTest failed" << std::endl;
555 while (clsMidErr >=
fgCLAccuracy && (clsTarget == -1 || std::abs(clsMid-clsTarget) < 3*clsMidErr) ) {
556 std::unique_ptr<HypoTestResult> more(hc.
GetHypoTest());
561 hcResult->
Append(more.get());
564 if (
fVerbose) std::cout << (
fUseCLs ?
"\tCLs = " :
"\tCLsplusb = ") << clsMid <<
" +/- " << clsMidErr << std::endl;
571 "\tCLs = " << hcResult->
CLs() <<
" +/- " << hcResult->
CLsError() <<
"\n" <<
572 "\tCLb = " << hcResult->
CLb() <<
" +/- " << hcResult->
CLbError() <<
"\n" <<
606 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - Please provide nBins>0\n";
609 if ( nBins==1 && xMin!=xMax ) {
610 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - nBins==1 -> I will run for xMin (" << xMin <<
")\n";
612 if ( xMin==xMax && nBins>1 ) {
613 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - xMin==xMax -> I will enforce nBins==1\n";
617 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - Please provide xMin ("
618 << xMin <<
") smaller than xMax (" << xMax <<
")\n";
622 if (xMin < fScannedVariable->getMin()) {
624 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - xMin < lower bound, using xmin = "
625 << xMin << std::endl;
629 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RunFixedScan - xMax > upper bound, using xmax = "
630 << xMax << std::endl;
633 if (xMin <= 0. && scanLog) {
634 oocoutE(
nullptr, InputArguments) <<
"HypoTestInverter::RunFixedScan - cannot go in log steps if xMin <= 0" << std::endl;
639 for (
int i=0; i<nBins; i++) {
643 thisX = exp( log(xMin) + i*(log(xMax)-log(xMin))/(nBins-1) );
645 thisX = xMin + i * (xMax - xMin) / (nBins - 1);
652 if ( status==
false ) {
653 oocoutW(
nullptr,
Eval) <<
"HypoTestInverter::RunFixedScan - The hypo test for point " << thisX <<
" failed. Skipping." << std::endl;
669 if ( rVal < fScannedVariable->getMin() ) {
670 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::RunOnePoint - Out of range: using the lower bound "
672 <<
" on the scanned variable rather than " << rVal<<
"\n";
678 oocoutE(
nullptr, InputArguments) <<
"HypoTestInverter::RunOnePoint - Out of range: using the upper bound "
696 const_cast<ModelConfig*
>(sbModel)->SetSnapshot(poi);
709 const double nullPV =
result->NullPValue();
710 const double altPV =
result->AlternatePValue();
711 if (!std::isfinite(nullPV) || nullPV < 0. || nullPV > 1. || !std::isfinite(altPV) || altPV < 0. || altPV > 1.) {
719 else lastXtested = -999;
724 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunOnePoint - Merge with previous result for "
732 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunOnePoint - replace previous empty result\n";
771 if ((hint !=
nullptr) && (*hint >
r->getMin())) {
772 r->setMax(std::min<double>(3.0 * (*hint),
r->getMax()));
773 r->setMin(std::max<double>(0.3 * (*hint),
r->getMin()));
774 oocoutI(
nullptr,InputArguments) <<
"HypoTestInverter::RunLimit - Use hint value " << *hint
775 <<
" search in interval " <<
r->getMin() <<
" , " <<
r->getMax() << std::endl;
782 typedef std::pair<double,double> CLs_t;
783 double clsTarget =
fSize;
787 double rMin =
r->getMin();
788 double rMax =
r->getMax();
789 limit = 0.5*(rMax + rMin);
790 limitErr = 0.5*(rMax - rMin);
793 TF1 expoFit(
"expoFit",
"[0]*exp([1]*(x-[2]))", rMin, rMax);
795 fLimitPlot = std::make_unique<TGraphErrors>();
797 if (
fVerbose > 0) std::cout <<
"Search for upper limit to the limit" << std::endl;
798 for (
int tries = 0; tries < 6; ++tries) {
800 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypotest failed at upper limit of scan range: " << rMax << std::endl;
805 if (clsMax.first == 0 || clsMax.first + 3 * std::abs(clsMax.second) < clsTarget )
break;
808 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Cannot determine upper limit of scan range. At " <<
r->GetName()
809 <<
" = " << rMax <<
" still getting "
810 << (
fUseCLs ?
"CLs" :
"CLsplusb") <<
" = " << clsMax.first << std::endl;
815 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Search for lower limit to the limit" << std::endl;
823 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypotest failed at lower limit of scan range: " << rMin << std::endl;
828 if (clsMin.first != 1 && clsMin.first - 3 * std::abs(clsMin.second) < clsTarget) {
834 for (
int tries = 0; tries < 6; ++tries) {
836 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypotest failed at lower limit of scan range: " << rMin << std::endl;
837 rMin = rMin == 0. ? 0.1 : rMin * 1.1;
841 if (clsMin.first == 1 || clsMin.first - 3 * std::abs(clsMin.second) > clsTarget)
break;
844 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Cannot determine lower limit of scan range. At " <<
r->GetName()
845 <<
" = " << rMin <<
" still get " << (
fUseCLs ?
"CLs" :
"CLsplusb")
846 <<
" = " << clsMin.first << std::endl;
854 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Now doing proper bracketing & bisection" << std::endl;
859 oocoutW(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - maximum number of toys reached " << std::endl;
865 limit = 0.5*(rMin+rMax); limitErr = 0.5*(rMax-rMin);
866 if (
fgAlgo ==
"logSecant" && clsMax.first != 0) {
867 double logMin = log(clsMin.first);
868 double logMax = log(clsMax.first);
869 double logTarget = log(clsTarget);
870 limit = rMin + (rMax-rMin) * (logTarget - logMin)/(logMax - logMin);
871 if (clsMax.second != 0 && clsMin.second != 0) {
872 limitErr = hypot((logTarget-logMax) * (clsMin.second/clsMin.first), (logTarget-logMin) * (clsMax.second/clsMax.first));
873 limitErr *= (rMax-rMin)/((logMax-logMin)*(logMax-logMin));
876 r->setError(limitErr);
879 if (limitErr < std::max(absAccuracy, relAccuracy * limit)) {
881 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - reached accuracy " << limitErr <<
" below "
882 << std::max(absAccuracy, relAccuracy * limit) << std::endl;
889 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypo test failed at x=" << limit <<
" when trying to find limit." << std::endl;
894 if (clsMid.second == -1) {
895 std::cerr <<
"Hypotest failed" << std::endl;
900 if (std::abs(clsMid.first-clsTarget) >= 2*clsMid.second) {
901 if ((clsMid.first>clsTarget) == (clsMax.first>clsTarget)) {
902 rMax = limit; clsMax = clsMid;
904 rMin = limit; clsMin = clsMid;
907 if (
fVerbose > 0) std::cout <<
"Trying to move the interval edges closer" << std::endl;
908 double rMinBound = rMin;
909 double rMaxBound = rMax;
911 while (clsMin.second == 0 || std::abs(rMin-limit) > std::max(absAccuracy, relAccuracy * limit)) {
912 rMin = 0.5*(rMin+limit);
914 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypo test failed at x=" << rMin <<
" when trying to find limit from below." << std::endl;
918 if (std::abs(clsMin.first-clsTarget) <= 2*clsMin.second)
break;
921 while (clsMax.second == 0 || std::abs(rMax-limit) > std::max(absAccuracy, relAccuracy * limit)) {
922 rMax = 0.5*(rMax+limit);
924 oocoutE(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Hypo test failed at x=" << rMin <<
" when trying to find limit from above." << std::endl;
928 if (std::abs(clsMax.first-clsTarget) <= 2*clsMax.second)
break;
931 expoFit.
SetRange(rMinBound,rMaxBound);
938 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Before fit --- \n";
939 std::cout <<
"Limit: " <<
r->GetName() <<
" < " << limit <<
" +/- " << limitErr <<
" [" << rMin <<
", " << rMax <<
"]\n";
943 expoFit.
SetParameter(1,log(clsMax.first/clsMin.first)/(rMax-rMin));
947 expoFit.
GetRange(rMinBound, rMaxBound);
948 limitErr = std::max(std::abs(rMinBound-limit), std::abs(rMaxBound-limit));
955 for (
int j = 0; j <
fLimitPlot->GetN(); ++j) {
958 for (
int i = 0, imax = 8; i <= imax; ++i, ++npoints) {
968 if (limitErr < std::max(absAccuracy, relAccuracy * limit))
break;
973 if (!
RunOnePoint(rTry,
true,clsTarget) )
return false;
985 double xmin =
r->getMin();
986 double xmax =
r->getMax();
987 for (
int j = 0; j <
fLimitPlot->GetN(); ++j) {
993 fLimitPlot->GetYaxis()->SetRangeUser(0.5*clsTarget, 1.5*clsTarget);
995 expoFit.
Draw(
"SAME");
1005 oocoutI(
nullptr,
Eval) <<
"HypoTestInverter::RunLimit - Result: \n"
1006 <<
"\tLimit: " <<
r->GetName() <<
" < " << limit <<
" +/- " << limitErr <<
" @ " << (1-
fSize) * 100 <<
"% CL\n";
1031 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::GetLowerLimitDistribution(false) - result not existing\n";
1037 TList * clsDist =
nullptr;
1038 TList * clsbDist =
nullptr;
1058 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::GetUpperLimitDistribution(false) - result not existing\n";
1064 TList * clsDist =
nullptr;
1065 TList * clsbDist =
nullptr;
1093 if (!bModel || ! sbModel)
return nullptr;
1100 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RebuildDistribution - background snapshot not existing"
1101 <<
" assume is for POI = 0" << std::endl;
1106 paramPoint.
assign(*poibkg);
1110 if (!toymcSampler) {
1111 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter::RebuildDistribution - no toy MC sampler existing" << std::endl;
1129 bool storePValues = clsDist || clsbDist || clbDist;
1130 if (
fNBins <=0 && storePValues) {
1131 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter::RebuildDistribution - cannot return p values distribution with the auto scan" << std::endl;
1132 storePValues =
false;
1139 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - result is not existing and number of point to scan is not set"
1145 if (nToys <= 0) nToys = 100;
1147 std::vector<std::vector<double> > CLs_values(nPoints);
1148 std::vector<std::vector<double> > CLsb_values(nPoints);
1149 std::vector<std::vector<double> > CLb_values(nPoints);
1152 for (
int i = 0; i < nPoints; ++i) {
1153 CLs_values[i].reserve(nToys);
1154 CLb_values[i].reserve(nToys);
1155 CLsb_values[i].reserve(nToys);
1159 std::vector<double> limit_values; limit_values.reserve(nToys);
1161 oocoutI(
nullptr,InputArguments) <<
"HypoTestInverter - rebuilding the p value distributions by generating ntoys = "
1162 << nToys << std::endl;
1165 oocoutI(
nullptr,InputArguments) <<
"Rebuilding using parameter of interest point: ";
1168 oocoutI(
nullptr,InputArguments) <<
"And using nuisance parameters: ";
1172 assert(bModel->
GetPdf() );
1178 std::unique_ptr<TFile> fileOut{
TFile::Open(outputfile,
"RECREATE")};
1180 oocoutE(
nullptr,InputArguments) <<
"HypoTestInverter - RebuildDistributions - Error opening file " << outputfile
1181 <<
" - the resulting limits will not be stored" << std::endl;
1184 TH1D * hL =
new TH1D(
"lowerLimitDist",
"Rebuilt lower limit distribution",100,1.,0.);
1185 TH1D * hU =
new TH1D(
"upperLimitDist",
"Rebuilt upper limit distribution",100,1.,0.);
1186 TH1D * hN =
new TH1D(
"nObs",
"Observed events",100,1.,0.);
1189 std::vector<TH1*> hCLb;
1190 std::vector<TH1*> hCLsb;
1191 std::vector<TH1*> hCLs;
1193 for (
int i = 0; i < nPoints; ++i) {
1194 hCLb.push_back(
new TH1D(
TString::Format(
"CLbDist_bin%d",i),
"CLb distribution",100,1.,0.));
1195 hCLs.push_back(
new TH1D(
TString::Format(
"ClsDist_bin%d",i),
"CLs distribution",100,1.,0.));
1196 hCLsb.push_back(
new TH1D(
TString::Format(
"CLsbDist_bin%d",i),
"CLs+b distribution",100,1.,0.));
1202 for (
int itoy = 0; itoy < nToys; ++itoy) {
1204 oocoutP(
nullptr,
Eval) <<
"\nHypoTestInverter - RebuildDistributions - running toy # " << itoy <<
" / "
1205 << nToys << std::endl;
1208 printf(
"\n\nshnapshot of s+b model \n");
1213 allParams->assign(saveParams);
1226 oocoutP(
nullptr,Generation) <<
"Generate observables are : ";
1230 for (std::size_t i = 0; i < genObs.
size(); ++i) {
1232 if (
x) nObs +=
x->getVal();
1247 if (
r ==
nullptr)
continue;
1249 double value = (isUpper) ?
r->UpperLimit() :
r->LowerLimit();
1250 limit_values.push_back(
value );
1251 hU->
Fill(
r->UpperLimit() );
1252 hL->
Fill(
r->LowerLimit() );
1255 std::cout <<
"The computed upper limit for toy #" << itoy <<
" is " <<
value << std::endl;
1258 if (itoy%10 == 0 || itoy == nToys-1) {
1264 if (!storePValues)
continue;
1266 if (nPoints < r->ArraySize()) {
1267 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter: skip extra points" << std::endl;
1269 else if (nPoints >
r->ArraySize()) {
1270 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter: missing some points" << std::endl;
1274 for (
int ipoint = 0; ipoint < nPoints; ++ipoint) {
1277 CLs_values[ipoint].push_back( hr->
CLs() );
1278 CLsb_values[ipoint].push_back( hr->
CLsplusb() );
1279 CLb_values[ipoint].push_back( hr->
CLb() );
1280 hCLs[ipoint]->Fill( hr->
CLs() );
1281 hCLb[ipoint]->Fill( hr->
CLb() );
1282 hCLsb[ipoint]->Fill( hr->
CLsplusb() );
1285 oocoutW(
nullptr,InputArguments) <<
"HypoTestInverter: missing result for point: x = "
1290 if (itoy%10 == 0 || itoy == nToys-1) {
1291 for (
int ipoint = 0; ipoint < nPoints; ++ipoint) {
1305 if (clsDist) clsDist->
SetOwner(
true);
1306 if (clbDist) clbDist->
SetOwner(
true);
1307 if (clsbDist) clsbDist->
SetOwner(
true);
1309 oocoutI(
nullptr,InputArguments) <<
"HypoTestInverter: storing rebuilt p values " << std::endl;
1311 for (
int ipoint = 0; ipoint < nPoints; ++ipoint) {
1331 for (
int i = 0; i < nPoints && storePValues; ++i) {
1338 const char * disName = (isUpper) ?
"upperLimit_dist" :
"lowerLimit_dist";
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
Storage_t::size_type size() const
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract base class for binned and unbinned datasets.
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual const RooArgSet * get() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract interface for all probability density functions.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
Does a frequentist hypothesis test.
Same purpose as HybridCalculatorOriginal, but different implementation.
Common base class for the Hypothesis Test Calculators.
const ModelConfig * GetNullModel(void) const
void SetData(RooAbsData &data) override
Set the DataSet.
HypoTestResult * GetHypoTest() const override
inherited methods from HypoTestCalculator interface
const ModelConfig * GetAlternateModel(void) const
TestStatSampler * GetTestStatSampler(void) const
Returns instance of TestStatSampler.
Class to plot a HypoTestInverterResult, the output of the HypoTestInverter calculator.
HypoTestInverterResult class holds the array of hypothesis test results and compute a confidence inte...
SamplingDistribution * GetLowerLimitDistribution() const
get expected lower limit distributions implemented using interpolation The size for the sampling dist...
HypoTestResult * GetResult(int index) const
return a pointer to the i^th result object
int ArraySize() const
number of entries in the results array
std::vector< double > fXValues
void UseCLs(bool on=true)
flag to switch between using CLsb (default) or CLs as confidence level
double GetXValue(int index) const
function to return the value of the parameter of interest for the i^th entry in the results
double GetLastYError() const
TList fExpPValues
list of expected sampling distribution for each point
bool fIsTwoSided
two sided scan (look for lower/upper limit)
double GetLastYValue() const
TList fYObjects
list of HypoTestResult for each point
void SetConfidenceLevel(double cl) override
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
SamplingDistribution * GetUpperLimitDistribution() const
get expected upper limit distributions implemented using interpolation
A class for performing a hypothesis test inversion by scanning the hypothesis test results of a HypoT...
static void CheckInputModels(const HypoTestCalculatorGeneric &hc, const RooRealVar &scanVar)
check the model given the given hypotestcalculator
RooRealVar * fScannedVariable
pointer to the constrained variable
static double fgCLAccuracy
std::unique_ptr< HypoTestCalculatorGeneric > fHC
! pointer to the generic hypotest calculator used
bool RunLimit(double &limit, double &limitErr, double absTol=0, double relTol=0, const double *hint=nullptr) const
Run an automatic scan until the desired accuracy is reached.
void SetData(RooAbsData &) override
Set the DataSet ( add to the workspace if not already there ?)
HypoTestInverterResult * fResults
pointer to the result
SamplingDistribution * RebuildDistributions(bool isUpper=true, int nToys=100, TList *clsDist=nullptr, TList *clsbDist=nullptr, TList *clbDist=nullptr, const char *outputfile="HypoTestInverterRebuiltDist.root")
function to rebuild the distributions
int fMaxToys
maximum number of toys to run
HypoTestInverter()
default constructor (used only for I/O)
~HypoTestInverter() override
destructor
double ConfidenceLevel() const override
Get the Confidence level for the test.
bool SetTestStatistic(TestStatistic &stat)
set the test statistic
HypoTestInverterResult * GetInterval() const override
Run a fixed scan or the automatic scan depending on the configuration.
SamplingDistribution * GetUpperLimitDistribution(bool rebuild=false, int nToys=100)
get the distribution of lower limit if rebuild = false (default) it will re-use the results of the sc...
static unsigned int fgNToys
void Clear()
delete contained result and graph
TestStatistic * GetTestStatistic() const
get the test statistic
static std::string fgAlgo
std::unique_ptr< TGraphErrors > fLimitPlot
! plot of limits
bool RunFixedScan(int nBins, double xMin, double xMax, bool scanLog=false) const
Run a fixed scan.
bool RunOnePoint(double thisX, bool adaptive=false, double clTarget=-1) const
run only one point at the given POI value
ECalculatorType fCalcType
SamplingDistribution * GetLowerLimitDistribution(bool rebuild=false, int nToys=100)
get the upper/lower limit distribution
HypoTestInverter & operator=(const HypoTestInverter &rhs)
assignment
HypoTestCalculatorGeneric * fCalculator0
pointer to the calculator passed in the constructor
static double fgRelAccuracy
void CreateResults() const
create a new HypoTestInverterResult to hold all computed results
static double fgAbsAccuracy
static RooRealVar * GetVariableToScan(const HypoTestCalculatorGeneric &hc)
helper functions
HypoTestResult * Eval(HypoTestCalculatorGeneric &hc, bool adaptive, double clsTarget) const
run the hybrid at a single point
HypoTestResult is a base class for results from hypothesis tests.
virtual double CLsplusb() const
Convert AlternatePValue into a "confidence level".
double GetTestStatisticData(void) const
virtual void Append(const HypoTestResult *other)
add values from another HypoTestResult
double CLsError() const
The error on the ratio .
void SetBackgroundAsAlt(bool l=true)
bool GetPValueIsRightTail(void) const
double CLbError() const
The error on the "confidence level" of the null hypothesis.
void SetTestStatisticData(const double tsd)
double CLsplusbError() const
The error on the "confidence level" of the alternative hypothesis.
SamplingDistribution * GetNullDistribution(void) const
virtual double CLs() const
is simply (not a method, but a quantity)
virtual double CLb() const
Convert NullPValue into a "confidence level".
SamplingDistribution * GetAltDistribution(void) const
IntervalCalculator is an interface class for a tools which produce RooStats ConfIntervals.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return nullptr if not existing)
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return nullptr if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return nullptr if not existing)
const RooArgSet * GetObservables() const
get RooArgSet for observables (return nullptr if not existing)
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
This class simply holds a sampling distribution of some test statistic.
Int_t GetSize() const
size of samples
double fUpperLimit
upper interval limit
double fLowerLimit
lower interval limit
TestStatSampler is an interface class for a tools which produce RooStats SamplingDistributions.
virtual TestStatistic * GetTestStatistic() const =0
Get the TestStatistic.
virtual void SetTestStatistic(TestStatistic *testStatistic)=0
Set the TestStatistic (want the argument to be a function of the data & parameter points.
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
ToyMCSampler is an implementation of the TestStatSampler interface.
void SetParametersForTestStat(const RooArgSet &nullpoi) override
Set the Pdf, add to the workspace if not already there.
void SetObservables(const RooArgSet &o) override
specify the observables in the dataset (needed to evaluate the test statistic)
virtual RooAbsData * GenerateToyData(RooArgSet ¶mPoint, RooAbsPdf &pdf) const
generates toy data without weight
void SetNuisanceParameters(const RooArgSet &np) override
specify the nuisance parameters (eg. the rest of the parameters)
void SetPdf(RooAbsPdf &pdf) override
Set the Pdf, add to the workspace if not already there.
void SetGlobalObservables(const RooArgSet &o) override
specify the conditional observables
virtual void SetNEventsPerToy(const Int_t nevents)
Forces the generation of exactly n events even for extended PDFs.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
virtual void SetParameter(Int_t param, Double_t value)
virtual void FixParameter(Int_t ipar, Double_t value)
Fix the value of a parameter for a fit operation The specified value will be used in the fit and the ...
virtual Double_t GetParameter(Int_t ipar) const
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a double per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetBuffer(Int_t buffersize, Option_t *option="")
Set the maximum number of entries to be kept in the buffer.
Use the TLine constructor to create a simple line.
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
@ kOverwrite
overwrite existing object with same name
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Namespace for the RooStats classes.
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)
useful function to print in one line the content of a set with their values
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
Comparing floating points.
static void SetToys(HypoTestType *h, int toyNull, int toyAlt)