/********************************************************************** * * * 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 "Ext/Root/RootHistoPdfTester.h" #include "StatTools/Pdf/RandomGeneratorFlat.h" #include "StatTools/Pdf/RandomGeneratorExponential.h" #include "StatTools/Pdf/RandomGeneratorGaussian.h" #include "StatTools/Pdf/RandomGeneratorDoubleGaussian.h" #include "StatTools/Pdf/RandomGeneratorPoissonian.h" #include "StatTools/Pdf/RandomGeneratorConstant.h" #include "StatTools/Pdf/RandomGeneratorTag.h" #include "StatTools/Pdf/RandomGeneratorTriangular.h" #include "StatTools/Pdf/Argus.h" #include "StatTools/Pdf/RandomGeneratorSample.h" #include "StatTools/Pdf/RandomGeneratorHitOrMiss.h" #include "StatTools/Pdf/Ext/Stdlib/Drand48Random.h" #include "StatTools/Pdf/Ext/Clhep/ClhepRandom.h" #include #include using namespace Pdf; RANDOM_GENERATOR_SAMPLE( Argus, 1024, 0.5, 1 ) struct Custom : Arguments { double operator()( double x ) const { return ( x < -1 || x > 1 ? 0 : sqrt( 1 - x*x ) ) / M_PI_2; } }; RANDOM_GENERATOR_HITORMISS( Custom, -1, 1, 1 / M_PI_2 ) int main() { Flat flat( -1, 1 ); Exponential expo( 5 ); Gaussian gauss( 0.1, 0.5 ); Gaussian g1( -1, 0.1 ), g2( 1, 0.1 ); DoubleGaussian gauss2( g1, g2, 0.4 ); Poissonian poisson( 5 ); Constant constant( 5 ); double t[] = { 0.5, 0.3, 0.2 }; Tag<3> tag( t ); Argus argus( 0.5, 1, -0.5 ); RandomGenerator rand_flat( flat ); RandomGenerator rand_expo( expo ); RandomGenerator rand_gauss( gauss ); RandomGenerator rand_gauss2( gauss2 ); RandomGenerator rand_poisson( poisson ); RandomGenerator > rand_constant( constant ); RandomGenerator rand_triangle; RandomGenerator > rand_tag( tag ); RandomGenerator randclhep_gauss( gauss ); RootHistoPdfTester tester( "testpdf.root" ); tester.test( rand_flat, "flat", "flat pdf", 100, -2, 2 ); tester.test( rand_expo, "expo", "exponential pdf", 100, 0, 20 ); tester.test( rand_gauss, "gauss", "gaussian pdf", 100, -2, 2 ); tester.test( rand_gauss2, "gauss2", "double gaussian pdf", 100, -3, 3 ); tester.test( rand_poisson, "poisson", "poissonian pdf", 30, -0.5, 29.5 ); tester.test( rand_constant, "constant", "constant pdf", 30, -0.5, 29.5 ); tester.test( rand_triangle, "triangle", "triangular pdf", 100, -0.5, 1.5 ); tester.test( rand_tag, "tag", "tag pdf", 5, -0.25, 2.25 ); tester.test( randclhep_gauss, "gaussclhep", "gaussian pdf, clhep", 100, -2, 2 ); #ifndef __STRICT_ANSI__ Custom custom; RandomGenerator rand48_flat( flat ); RandomGenerator rand48_argus( argus ); RandomGenerator rand48_custom( custom ); tester.test( rand48_flat, "flat48", "constant pdf, drand48", 100, -2, 2 ); tester.test( rand48_argus, "argus", "argus pdf", 200, 0, 1, 10000 ); tester.test( rand48_custom, "custom", "custom pdf", 200, -1.5, 1.5, 10000 ); #else std::cout << "Warning: you have compiled with an ANSI compiler." << "drand48-based generator test will be skipped." << std::endl; #endif std::cout << "pdf test completed" << std::endl; return 0; }