/********************************************************************** * * * 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/RandomGeneratorGaussian.h" #include "StatTools/Pdf/RandomGeneratorConstant.h" #include "StatTools/Fit/Likelihood.h" #include "StatTools/Fit/UMLParameterFitter.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 = 100; double mean = 0, sigma = 1; Constant p( sig ); Gaussian q( mean, sigma ); Experiment, Gaussian> experiment( p, q ); Gaussian pdf( mean, sigma ); Likelihood like( pdf ); UMLParameterFitter > fitter( like ); TFile file( "testparfitter.root", "RECREATE" ); TH1F pull1( "pullm", "pull mean", 200, -5, 5 ); TH1F pull2( "pulls", "pull sigma", 200, -5, 5 ); fitter.addParameter( "mean", & pdf.mean ); fitter.addParameter( "sigma", & pdf.sigma ); for ( int i = 0; i < 50000; i++ ) { double par[ 2 ] = { mean, sigma }; double err[ 2 ] = { 1, 1 }; double logLike; Sample< Gaussian::types > sample; experiment.generate( sample ); logLike = fitter.fit( par, err, sample ); pull1.Fill( ( par[ 0 ] - mean ) / err[ 0 ] ); pull2.Fill( ( par[ 1 ] - sigma ) / err[ 1 ] ); } pull1.Write(); pull2.Write(); return 0; }