StandardTestStatDistributionDemo.C
This simple script plots the sampling distribution of the profile likelihood ratio test statistic based on the input Model File. To do this one needs to specify the value of the parameter of interest that will be used for evaluating the test statistic and the value of the parameters used for generating the toy data. In this case, it uses the upper-limit estimated from the ProfileLikleihoodCalculator, which assumes the asymptotic chi-square distribution for -2 log profile likelihood ratio. Thus, the script is handy for checking to see if the asymptotic approximations are valid. To aid, that comparison, the script overlays a chi-square distribution as well. The most common parameter of interest is a parameter proportional to the signal rate, and often that has a lower-limit of 0, which breaks the standard chi-square distribution. Thus the script allows the parameter to be negative so that the overlay chi-square is the correct asymptotic distribution.
Processing /mnt/build/workspace/root-makedoc-v610/rootspi/rdoc/src/v6-10-00-patches/tutorials/roostats/StandardTestStatDistributionDemo.C...
bool useProof = false;
int nworkers = 0;
void StandardTestStatDistributionDemo(const char* infile = "",
const char* workspaceName = "combined",
const char* modelConfigName = "ModelConfig",
const char* dataName = "obsData"){
int nToyMC = 1000;
bool allowNegativeMu=true;
const char* filename = "";
if (!strcmp(infile,"")) {
filename = "results/example_combined_GaussExample_model.root";
if (!fileExist) {
#ifdef _WIN32
cout << "HistFactory file cannot be generated on Windows - exit" << endl;
return;
#endif
cout <<"will run standard hist2workspace example"<<endl;
gROOT->ProcessLine(
".! prepareHistFactory .");
gROOT->ProcessLine(
".! hist2workspace config/example.xml");
cout <<"\n\n---------------------"<<endl;
cout <<"Done creating example input"<<endl;
cout <<"---------------------\n\n"<<endl;
}
}
else
filename = infile;
if(!file ){
cout <<"StandardRooStatsDemoMacro: Input file " << filename << " is not found" << endl;
return;
}
if(!w){
cout <<"workspace not found" << endl;
return;
}
if(!data || !mc){
cout << "data or ModelConfig was not found" <<endl;
return;
}
double plcUpperLimit = interval->
UpperLimit(*firstPOI);
delete interval;
cout << "\n\n--------------------------------------"<<endl;
cout <<
"Will generate sampling distribution at " << firstPOI->
GetName() <<
" = " << plcUpperLimit <<endl;
if(nPOI>1){
cout <<"not sure what to do with other parameters of interest, but here are their values"<<endl;
}
if(allowNegativeMu)
cout << "tell it to use 1 event"<<endl;
}
firstPOI->
setVal(plcUpperLimit);
if (useProof) {
}
firstPOI->
setVal(plcUpperLimit);
allParameters.
Print(
"v");
TF1* f =
new TF1(
"f",
Form(
"2*ROOT::Math::chisquared_pdf(2*x,%d,0)",nPOI),min,max);
c1->
SaveAs(
"standard_test_stat_distribution.pdf");
}
- Author
- Kyle Cranmer
Definition in file StandardTestStatDistributionDemo.C.