#include #include #include #include "TRandom3.h" #include "JMath/JLegendre.hh" #include "JMath/JMathSupportkit.hh" #include "JTools/JQuantile.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test Legendre polynome. * \author mdejong */ int main(int argc, char**argv) { using namespace std; using namespace JPP; const double xmin = -10.0; const double xmax = +10.0; typedef JLegendre JLegendre_t; unsigned int numberOfEvents; unsigned int numberOfBins; JLegendre_t f1(xmin, xmax); int debug; try { JParser<> zap("Example program to test Legendre polynome."); zap['n'] = make_field(numberOfEvents) = 0; zap['N'] = make_field(numberOfBins) = 10; zap['L'] = make_field(f1); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } map data; for (unsigned int i = 0; i != numberOfBins; ++i) { const double x = xmin + i * (xmax - xmin) / (numberOfBins - 1); data[x] = f1(x); } for (map::const_iterator i = data.begin(); i != data.end(); ++i) { DEBUG("data: " << FIXED(7,3) << i->first << ' ' << FIXED(7,3) << i->second << endl); } const size_t N = 3; JLegendre g1(data.begin(), data.end()); for (size_t n = 0; n != N + 1; ++n) { STATUS("Legendre: " << setw(2) << n << ' ' << FIXED(7,3) << g1[n] << endl); } if (numberOfEvents > 0) { JQuantile Q; for (unsigned int i = 0; i != numberOfEvents; ++i) { const double x = gRandom->Uniform(xmin, xmax); const double y = f1(x); const double z = g1(x); Q.put(y - z); } Q.print(cout); } return 0; }