/********************************************************************** * * * 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/RandomGeneratorConstant.h" #include "StatTools/Pdf/RandomGeneratorGaussian.h" #include "StatTools/Pdf/RandomGeneratorFlat.h" #include "StatTools/Pdf/RandomGeneratorIndependent.h" #include "StatTools/Fit/ExtendedLikelihood.h" #include "StatTools/Fit/UMLYieldFitter.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 sig = 10, bkg = 5; typedef Poissonian Fluctuation; // typedef Constant Fluctuation; Fluctuation fluctuationSig( sig ), fluctuationBkg( bkg ); typedef Independent PdfSig; typedef Independent PdfBkg; Gaussian g1( 0, 1 ), g2( 0, 0.5 ); PdfSig pdfSig( g1, g2 ); Flat f1( -5, 5 ), f2( -5, 5 ); PdfBkg pdfBkg( f1, f2 ); typedef Experiment ToySig; typedef Experiment ToyBkg; ToySig toySig( fluctuationSig, pdfSig ); ToyBkg toyBkg( fluctuationBkg, pdfBkg ); Experiment2 toy( toySig, toyBkg ); typedef ExtendedLikelihood2 Likelihood; Likelihood like( pdfSig, pdfBkg ); UMLYieldFitter fitter( like ); TFile file( "testyieldfitter.root", "RECREATE" ); TH1F pull1( "pull1", "pull sig", 200, -5, 5 ); TH1F pull2( "pull2", "pull bkg", 200, -5, 5 ); const int nmc = 50000; for ( int i = 0; i < nmc; i++ ) { Sample< Likelihood::types > sample; toy.generate( sample ); double s[] = { sig, bkg }; double err[] = { 1, 1 }; /* double logLike = */ fitter.fit( s, err, sample ); pull1.Fill( ( s[ 0 ] - sig ) / err[ 0 ] ); pull2.Fill( ( s[ 1 ] - bkg ) / err[ 1 ] ); } pull1.Write(); pull2.Write(); return 0; }