Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JGeometry3D/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 "JGeometry3D/JQuaternion3D.hh"
#include "JGeometry3D/JEigen3D.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 JGeometry3D/JLegendre.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JGeometry3D/JLegendre.cc.

26 {
27  using namespace std;
28  using namespace JPP;
29 
30  const double xmin = -10.0;
31  const double xmax = +10.0;
32 
33  typedef JLegendre<JQuaternion3D> JLegendre_t;
34 
35  unsigned int numberOfEvents;
36  unsigned int numberOfBins;
37  JLegendre_t f1(xmin, xmax);
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Example program to test Legendre polynome.");
43 
44  zap['n'] = make_field(numberOfEvents) = 0;
45  zap['N'] = make_field(numberOfBins) = 10;
46  zap['L'] = make_field(f1);
47  zap['d'] = make_field(debug) = 3;
48 
49  zap(argc, argv);
50  }
51  catch(const exception &error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  for (JLegendre_t::iterator i = f1.begin(); i != f1.end(); ++i) {
57 
58  i->normalise();
59 
60  STATUS("function: " << *i << endl);
61  }
62 
63 
65 
66  for (unsigned int i = 0; i != numberOfBins; ++i) {
67 
68  const double x = xmin + i * (xmax - xmin) / (numberOfBins - 1);
69 
70  data[x] = f1(x);
71  }
72 
73 
74  for (map<double, JQuaternion3D>::const_iterator i = data.begin(); i != data.end(); ++i) {
75  DEBUG("data: "
76  << FIXED(7,3) << i->first << " "
77  << i->second << "; "
78  << 360.0 * acos(i->second.getA()) / PI << endl);
79  }
80 
81 
82  const size_t N = 2;
83 
84  JLegendre<JQuaternion3D, N> g1(data.begin(), data.end());
85 
86  for (size_t n = 0; n != N + 1; ++n) {
87 
88  STATUS("Legendre: " << setw(2) << n << ' ' << g1[n]);
89 
90  if (n < f1.size()) {
91  STATUS(' ' << FIXED(7,3) << getAngle(f1[n], g1[n]));
92  }
93 
94  STATUS(endl);
95  }
96 
97 
98  if (numberOfEvents > 0) {
99 
100  JQuantile Q;
101 
102  for (unsigned int i = 0; i != numberOfEvents; ++i) {
103 
104  const double x = gRandom->Uniform(xmin, xmax);
105  const JQuaternion3D y = f1(x);
106  const JQuaternion3D z = g1(x);
107 
108  Q.put(getAngle(y,z));
109  }
110 
111  Q.print(cout);
112  }
113 
114  return 0;
115 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1514
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
Q(UTCMax_s-UTCMin_s)-livetime_s
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
const JPolynome f1(1.0, 2.0, 3.0)
Function.
const int n
Definition: JPolint.hh:697
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
static const double PI
Mathematical constants.
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:36
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:69
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25