Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFit/JLegendre.cc File Reference

Example program to test Legendre polynome. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JMath/JLegendre.hh"
#include "JMath/JMathSupportkit.hh"
#include "JFit/JLegendreEstimator.hh"
#include "JTools/JCollection.hh"
#include "JTools/JElement.hh"
#include "JTools/JQuantile.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test Legendre polynome.

Author
mdejong

Definition in file JFit/JLegendre.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JFit/JLegendre.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  const size_t N = 3;
32 
33  typedef JLegendre<double, N> JLegendre_t;
34 
35  const double xmin = -10.0;
36  const double xmax = +10.0;
37 
38  unsigned int numberOfEvents;
39  unsigned int numberOfBins;
40  JLegendre_t f1(xmin, xmax);
41  double precision;
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Example program to test Legendre polynome.");
47 
48  zap['n'] = make_field(numberOfEvents) = 1000;
49  zap['N'] = make_field(numberOfBins) = 10;
50  zap['L'] = make_field(f1);
51  zap['e'] = make_field(precision) = 1.0e-10;
52  zap['d'] = make_field(debug) = 3;
53 
54  zap(argc, argv);
55  }
56  catch(const exception &error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61  typedef JCollection< JElement2D<double, double> > collection_type;
62 
63  collection_type data;
64 
65  for (unsigned int i = 0; i != numberOfBins; ++i) {
66 
67  const double x = xmin + i * (xmax - xmin) / (numberOfBins - 1);
68 
69  data[x] = f1(x);
70  }
71 
72  for (collection_type::const_iterator i = data.begin(); i != data.end(); ++i) {
73  DEBUG("data: " << FIXED(7,3) << i->getX() << ' ' << FIXED(7,3) << i->getY() << endl);
74  }
75 
76 
77  JEstimator<JLegendre_t> g1(data.begin(), data.end());
78 
79  for (size_t n = 0; n != g1.size(); ++n) {
80  STATUS("Legendre: " << setw(2) << n << ' ' << FIXED(7,3) << g1[n] << endl);
81  }
82 
83 
84  JQuantile Q;
85 
86  if (numberOfEvents > 0) {
87 
88  for (unsigned int i = 0; i != numberOfEvents; ++i) {
89 
90  const double x = gRandom->Uniform(xmin, xmax);
91  const double y = f1(x);
92  const double z = g1(x);
93 
94  Q.put(y - z);
95  }
96 
97  DEBUG(Q << endl);
98  }
99 
100  ASSERT(numberOfEvents > 0);
101 
102  ASSERT(f1.size() == g1.size());
103 
104  for (size_t n = 0; n != g1.size(); ++n) {
105  ASSERT(fabs(f1[n] - g1[n]) <= precision, "Legendre: " << setw(2) << n << ' ' << FIXED(7,3) << g1[n]);
106  }
107 
108  ASSERT(fabs(Q.getMean()) <= precision);
109 
110  ASSERT(Q.getSTDev() <= precision);
111 
112  return 0;
113 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Q(UTCMax_s-UTCMin_s)-livetime_s
#define STATUS(A)
Definition: JMessage.hh:63
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
const int n
Definition: JPolint.hh:660
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:64
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25