ToyMC Package
Provides the possibility to generate multi-variate random samples according to the PDF. The probability distribution of the number of events in each component (typically poissonian or constant) can be specified by the user. The format of the random samples is the same as for the Fit package, so the randomly generated samples are ready to be used for fitting.

Contents

Conventions
  • the examples below assume one specifies the directive:
    using namespace ToyMC;
    otherwise the namespace ToyMC should be specified where appropriate.
Simulated experiments
  • Simuleted experiment (Experiment, from header ToyMC/Experiment.h) is templated helper classes that permit to generate random samples according to specified PDFs. The usage of this class reduces the need to use directly the interface of sample classes. Both unbinned and binned samples (in the case of one variable only, in this version of the toolkit) can be generated. Both the probability distribution functions for the number of events and for the event variables have to be specified.
  • The following example shows how to generate a sample with number of events distributed according to a poissonian with average 10, each event having two variables distributed according to a two-dimensional gaussian. Replacint Poissonian with Constant<unsigned int> would generate samples always with the same number of events:
Poissonian poisson( 10 );
typedef Independent<Gaussian, Gaussian> Pdf2D;
Gaussian g1( 0, 1 ), g2( 0, 2 );
Pdf2D gauss( g1, g2 );
Experiment<Poissonian, Pdf2D> experiment( poisson, gauss );
Sample< Pdf2D::types > s;
experiment.generate( s );
Combining more samples
  • It is often useful to generate samples with different contributions. Samples can be combined (up to a maximum of four, in the current version) as in the following example:
Poissonian nsig( 10 ), nbkg( 100 );
typedef Independent<Gaussian, Gaussian> PdfSig;
typedef Independent<Flat, Argus> PdfBkg;
Gaussian g1( 0, 0.01 ), g2( 5.28, 0.005 );
PdfSig sig( g1, g2 );
Flat f( -0.1, 0.1 ), Argus a( 5.2, 5.3, 1.0 );
PdfBkg bkg( f, a );
typedef Experiment<Poissonian, PdfSig> ExpSig;
typedef Experiment<Poissonian, PdfBkg> ExpBkg;
ExpSig expSig( nsig, sig );
ExpBkg expBkg( nbkg, bkg );
Experiment< ExpSig, ExpBkg > experiment;

Sample< Pdf2D::types > s;
experiment.generate( s );
Examples