/********************************************************************** * * * Copyright (c) 2003 INFN - Sezione di Napoli * * * * For more information (including a list of authors) see * * the README file * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this library (see file COPYING); if not, write to the * * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * * Boston, MA 02111-1307 USA, or contact the authors. * * * **********************************************************************/ #include "StatTools/Pdf/Ext/Defaults.h" #include "StatTools/Fit/Ext/Defaults.h" #include "StatTools/Pdf/RandomGeneratorPoissonian.h" #include "StatTools/Pdf/RandomGeneratorGaussian.h" #include "StatTools/Pdf/RandomGeneratorFlat.h" #include "StatTools/Pdf/RandomGeneratorIndependent.h" #include "StatTools/Fit/ExtendedLikelihood.h" #include "StatTools/ToyMC/Experiment.h" #include "TFile.h" #include "TH1.h" using namespace Pdf; using namespace Fit; using namespace ToyMC; int main() { const int variables = 2; const double sig = 10, bkg = 5; Poissonian poissonSig( sig ), poissonBkg( bkg ); typedef Independent PdfSig; typedef Independent PdfBkg; PdfSig pdfSig( Gaussian( 0, 1 ), Gaussian( 0, 2 ) ); PdfBkg pdfBkg( Flat( -5, 5 ), Flat( -5, 5 ) ); typedef Experiment ToySig; typedef Experiment ToyBkg; ToySig toySig( poissonSig, pdfSig ); ToyBkg toyBkg( poissonBkg, pdfBkg ); Experiment2 toy( toySig, toyBkg ); ExtendedLikelihood2 like( pdfSig, pdfBkg ); const double s[ variables ] = { sig, bkg }; like.setYield( s ); TFile f("testlike.root", "RECREATE" ); TH1F size ("size", "sample size", 50, -0.5, 49.5 ); TH1F histo ("like", "log likelihood", 100, -300, 0 ); for( int i = 0; i < 10000; i++ ) { Sample< PdfSig::types > sample; toy.generate( sample ); size.Fill( sample.size() ); // appearently gcc 3.2 donesn't like template methods // used in another template implementation. // so, a const container& has to be passed double logLike = like.log( sample, sample.begin(), sample.end() ); histo.Fill( logLike ); } size.Write(); histo.Write(); return 0; }