<commit_before>// Standard demo of the numerical Bayesian calculator

/*


Author: <NAME>
date: Dec. 2010

This is a standard demo that can be used with any ROOT file
prepared in the standard way.  You specify:
 - name for input ROOT file
 - name of workspace inside ROOT file that holds model and data
 - name of ModelConfig that specifies details for calculator tools
 - name of dataset

With default parameters the macro will attempt to run the
standard hist2workspace example and read the ROOT file
that it produces.

The actual heart of the demo is only about 10 lines long.

The BayesianCalculator is based on Bayes's theorem
and performs the integration using ROOT's numeric integration utilities
*/

#include "TFile.h"
#include "TROOT.h"
#include "RooWorkspace.h"
#include "RooAbsData.h"
#include "RooRealVar.h"

#include "RooUniform.h"
#include "RooStats/ModelConfig.h"
#include "RooStats/BayesianCalculator.h"
#include "RooStats/SimpleInterval.h"
#include "RooStats/RooStatsUtils.h"
#include "RooPlot.h"
#include "TSystem.h"

using namespace RooFit;
using namespace RooStats;


TString integrationType = "";  // integration Type (default is adaptive (numerical integration)
                               // possible values are "TOYMC" (toy MC integration, work when nuisances have a constraints pdf)
                               //  "VEGAS" , "MISER", or "PLAIN"  (these are all possible MC integration)
int nToys = 10000;             // number of toys used for the MC integrations - for Vegas should be probably set to an higher value
bool scanPosterior = false;    // flag to compute interval by scanning posterior (it is more robust but maybe less precise)
int nScanPoints = 50;          // number of points for scanning the posterior (if scanPosterior = false it is used only for plotting)
int intervalType = 1;          // type of interval (0 is shortest, 1 central, 2 upper limit)
double   maxPOI = -999;        // force a different value of POI for doing the scan (default is given value)

void StandardBayesianNumericalDemo(const char* infile = "",
                                   const char* workspaceName = "combined",
                                   const char* modelConfigName = "ModelConfig",
                                   const char* dataName = "obsData") {

  /////////////////////////////////////////////////////////////
  // First part is just to access a user-defined file
  // or create the standard example file if it doesn't exist
  ////////////////////////////////////////////////////////////

   const char* filename = "";
   if (!strcmp(infile,"")) {
      filename = "results/example_combined_GaussExample_model.root";<commit_msg>Speed up tutorial by plotting the posterior in less points (20 instead of 50)<commit_after>// Standard demo of the numerical Bayesian calculator

/*


Author: <NAME>
date: Dec. 2010

This is a standard demo that can be used with any ROOT file
prepared in the standard way.  You specify:
 - name for input ROOT file
 - name of workspace inside ROOT file that holds model and data
 - name of ModelConfig that specifies details for calculator tools
 - name of dataset

With default parameters the macro will attempt to run the
standard hist2workspace example and read the ROOT file
that it produces.

The actual heart of the demo is only about 10 lines long.

The BayesianCalculator is based on Bayes's theorem
and performs the integration using ROOT's numeric integration utilities
*/

#include "TFile.h"
#include "TROOT.h"
#include "RooWorkspace.h"
#include "RooAbsData.h"
#include "RooRealVar.h"

#include "RooUniform.h"
#include "RooStats/ModelConfig.h"
#include "RooStats/BayesianCalculator.h"
#include "RooStats/SimpleInterval.h"
#include "RooStats/RooStatsUtils.h"
#include "RooPlot.h"
#include "TSystem.h"

using namespace RooFit;
using namespace RooStats;


TString integrationType = "";  // integration Type (default is adaptive (numerical integration)
                               // possible values are "TOYMC" (toy MC integration, work when nuisances have a constraints pdf)
                               //  "VEGAS" , "MISER", or "PLAIN"  (these are all possible MC integration)
int nToys = 10000;             // number of toys used for the MC integrations - for Vegas should be probably set to an higher value
bool scanPosterior = false;    // flag to compute interval by scanning posterior (it is more robust but maybe less precise)
int nScanPoints = 20;          // number of points for scanning the posterior (if scanPosterior = false it is used only for plotting). Use by default a low value to speed-up tutorial
int intervalType = 1;          // type of interval (0 is shortest, 1 central, 2 upper limit)
double   maxPOI = -999;        // force a different value of POI for doing the scan (default is given value)

void StandardBayesianNumericalDemo(const char* infile = "",
                                   const char* workspaceName = "combined",
                                   const char* modelConfigName = "ModelConfig",
                                   const char* dataName = "obsData") {

  /////////////////////////////////////////////////////////////
  // First part is just to access a user-defined file
  // or create the standard example file if it doesn't exist
  ////////////////////////////////////////////////////////////

   const char* filename = "";
   if (!strcmp(infile,"")) {
      filename = "results/example_combined_GaussExample_model.root";
{'fraction_non_alphanumeric': 0.11332480350941326, 'fraction_numerical': 0.008407969292633887, 'mean_word_length': 2.5099422706863375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6196547', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1381, 'n_words': 629}