Example program to test 1D interpolation of a polynome.
More...
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include "TRandom3.h"
#include "JLang/JException.hh"
#include "JMath/JPolynome.hh"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JGrid.hh"
#include "JTools/JQuantile.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to test 1D interpolation of a polynome.
- Author
- mdejong
Definition in file JPolynome1P.cc.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 25 of file JPolynome1P.cc.
30 unsigned int numberOfEvents;
38 JParser<> zap(
"Example program to test 1D interpolation of a polynome.");
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
53 FATAL(
"Invalid polynomial.");
60 typedef JResultPolynome<N, double> JResult_t;
61 typedef JPolintFunction1D<N, JElement2D<double, double>, JCollection, JResult_t> JFunction1D_t;
67 const double xmin = -1.0;
68 const double xmax = +1.0;
70 polint.configure(JGrid<double>(
numberOfBins, xmin, xmax), f1);
74 polint.setExceptionHandler(
new JFunction1D_t::JDefaultResult(
JMATH::zero));
79 for (
int i = 1; i != (int) f1.size(); ++i) {
80 fp.push_back(fp.rbegin()->getDerivative());
85 for (
int i = 0; i != (int) f1.size(); ++i) {
86 DEBUG(
' ' << fp[i](x0));
92 JResult_t
result = polint(x0);
94 for (
int i = 0; i !=
N+1; ++i) {
100 if (numberOfEvents != 0) {
104 for (
int j = 0;
j !=
sizeof(
Q)/
sizeof(Q[0]); ++
j) {
110 Q[
j].setTitle(os.str());
113 const int M = min(fp.size(),
sizeof(
Q)/
sizeof(Q[0]));
115 for (
unsigned int i = 0; i != numberOfEvents; ++i) {
117 const double x = gRandom->Uniform(xmin, xmax);
119 JResult_t
result = polint(x);
121 for (
int j = 0; j !=
M; ++
j) {
122 Q[
j].put(fp[j](x) - result.y[j]);
126 for (
int j = 0; j !=
M; ++
j) {
127 Q[
j].print(cout, j == 0);
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
static const JZero zero
Function object to assign zero value.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
then usage $script[input file[working directory[option]]] nWhere option can be N
int numberOfBins
number of bins for average CDF integral of optical module