Examples: Running an ensemble of PDF toy Monte Carlo experiments

There are a number of options used for generating Toy Monte Carlo experiments for fitting. These are described in the user guide. A simple way to generate an ensemble of toy samples from a likelihood is given below for the muon lifetime example.

  // build the fit model
  AFitMaster master("MuonLifetime.txt");
  RooAbsPdf * pdf = master.getPdf();

  // extract the discriminating variable to generate from the model
  RooArgSet * compSet = pdf->getComponents();
  RooArgSet * parSet  = pdf->getParameters(compSet);
  RooRealVar * t = (RooRealVar*)parSet->find("t");

  // instantiante the toy utility, and set the output directory
  AFitToy toy;

  // Generate toy data sets 
  for(int i=0; i < 10; i++){
    cout << "generating toy number " << i << endl;
    toy.setSeed(i);
    RooDataSet * data = toy.generateToySample(pdf, RooArgSet(*t), 1000, 0);

    // fit data/save to file
  }

By default the number of events generated according to a Poisson distribution with a mean corresponding to the number of events to generate (1000 in this example). This behaviour can be changed by

  toy.setPoisson(kFALSE);
This page is maintained by Adrian Bevan.