Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 16 of file runRooInterface.cxx.
00017 { 00018 std::cout << "Running BAT via the BCRooInterface...\n"; 00019 00020 // retrieve the command line arguments 00021 char* rootFile = "bat_workspace.root"; 00022 char* wsName = "batWS"; 00023 char* outputFile = "bat_plots.ps"; 00024 int nMCMC = 1000000; 00025 00026 // display a quick help if no arguments are specified 00027 if (argc==0) { 00028 std::cout << "Run with: ./runRooInterface bat_workspace.root batWS bat_plots.ps\n"; 00029 std::cout << "the four arguments are:\n"; 00030 std::cout << " - the name of the ROOT file that contains a workspace. This workspace should contain:\n"; 00031 std::cout << " - data: a RooAbsData object holding the data measurements\n"; 00032 std::cout << " - model: a RooAbsPdf object holding the probability density function\n"; 00033 std::cout << " - priorPOI and priorNuisance: two RooAbsPdf objects representing respectively the prior probability on the parameter of interest and the nuisance parameters.\n"; 00034 std::cout << " - POI: a RooArgList holding one single object being the parameter of interest\n"; 00035 std::cout << " - parameters: a RooArgList holding all nuisance parameters\n"; 00036 std::cout << " - the name workspace to retrieve from the ROOT file\n"; 00037 std::cout << " - the name of the postscript file that will contain the resulting posterior probability plots\n"; 00038 std::cout << " - the number of MCMC iterations (default = 1000000)\n"; 00039 std::cout << "For more information see the README file of the BCRooInterface\n"; 00040 } 00041 00042 if (argc>=1) rootFile = argv[1]; 00043 if (argc>=2) wsName = argv[2]; 00044 //if (argc>=3) outputFile = argv[3]; 00045 //if (argc>=4) nMCMC = int(argv[4]); 00046 00047 std::cout << "The inputs will be retrieved from " << rootFile << " (workspace " << wsName << ") and the posterior probability plot will be stored in " << outputFile << std::endl; 00048 std::cout << nMCMC << " MCMC iteration will be performed\n"; 00049 00050 // set nice style for drawing than the ROOT default 00051 BCAux::SetStyle(); 00052 00053 // open log file with default level of logging 00054 BCLog::OpenLog("bat_log.txt"); 00055 BCLog::SetLogLevel(BCLog::detail); 00056 00057 // create new RooFit-based model 00058 BCRooInterface * _myRooInterface = new BCRooInterface(); 00059 _myRooInterface->Initialize(rootFile,wsName,"data","model","priorPOI","priorNuisance","parameters","POI"); 00060 00061 _myRooInterface -> MCMCSetNIterationsRun(nMCMC); 00062 00063 // perform your analysis here 00064 _myRooInterface -> MarginalizeAll(); 00065 _myRooInterface -> FindMode(); 00066 _myRooInterface -> PrintAllMarginalized(outputFile); 00067 _myRooInterface -> PrintResults("bat_results.txt"); 00068 00069 TFile* file = new TFile(rootFile); 00070 RooWorkspace* bat_ws = (RooWorkspace*) file->Get(wsName); 00071 TString parameterName = bat_ws->set("POI")->first()->GetName(); 00072 00073 std::cout << "\nThe results of the BAT calculations are:\n"; 00074 std::cout << " Signal " << std::endl; 00075 std::cout << " Mean " << _myRooInterface -> GetMarginalized(parameterName) -> GetMean() << std::endl; 00076 std::cout << " Median " << _myRooInterface -> GetMarginalized(parameterName) -> GetMedian() << std::endl; 00077 std::cout << " Mode " << _myRooInterface -> GetMarginalized(parameterName) -> GetMode() << std::endl; 00078 std::cout << " Mode " << (_myRooInterface -> GetBestFitParameters()).at(0) << std::endl; 00079 std::cout << " Quantile 0.16 " << _myRooInterface -> GetMarginalized(parameterName) -> GetQuantile(0.16) << std::endl; 00080 std::cout << " Quantile 0.84 " << _myRooInterface -> GetMarginalized(parameterName) -> GetQuantile(0.84) << std::endl; 00081 std::cout << " Quantile 0.90 " << _myRooInterface -> GetMarginalized(parameterName) -> GetQuantile(0.90) << std::endl; 00082 std::cout << " Quantile 0.95 " << _myRooInterface -> GetMarginalized(parameterName) -> GetQuantile(0.95) << std::endl; 00083 std::cout << "\nCheck " << outputFile << " and results.txt for more information on the results\n"; 00084 00085 // close log file 00086 BCLog::CloseLog(); 00087 00088 return 0; 00089 00090 }