Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JGeometry3D/JLegendre.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TRandom3.h"
6 
7 #include "JMath/JLegendre.hh"
9 
11 #include "JGeometry3D/JEigen3D.hh"
12 
13 #include "JTools/JQuantile.hh"
14 
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Example program to test Legendre polynome.
23  * \author mdejong
24  */
25 int main(int argc, char**argv)
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:1500
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary methods for mathematics.
#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 JPolynome f1(1.0, 2.0, 3.0)
Function.
const int n
Definition: JPolint.hh:676
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
static const double PI
Mathematical constants.
int debug
debug level
Definition: JSirene.cc:66
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
Utility class to parse command line options.
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:67
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25