Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPoint3D.cc File Reference

Test program for JFIT::JEstimator<JPoint3D> fit. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TRandom3.h"
#include "JGeometry3D/JAxis3D.hh"
#include "JFit/JPoint3D.hh"
#include "JFit/JPoint3DEstimator.hh"
#include "JROOT/JRootToolkit.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

Test program for JFIT::JEstimator<JPoint3D> fit.

Author
mdejong

Definition in file JPoint3D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file JPoint3D.cc.

28 {
29  using namespace std;
30 
31  string outputFile;
32  int numberOfEvents;
33  int numberOfAxes;
34  double sigma;
35  double precision;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Test program for position fit.");
41 
42  zap['o'] = make_field(outputFile) = "";
43  zap['n'] = make_field(numberOfEvents) = 1000;
44  zap['N'] = make_field(numberOfAxes) = 3;
45  zap['s'] = make_field(sigma) = 1.0e-4;
46  zap['e'] = make_field(precision) = 1.0e-3;
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  using namespace JPP;
57 
58 
59  TH1D hx("hx", NULL, 101, -1.0, +1.0);
60  TH1D hy("hy", NULL, 101, -1.0, +1.0);
61  TH1D hz("hz", NULL, 101, -1.0, +1.0);
62 
63  JQuantile Qx("x");
64  JQuantile Qy("y");
65  JQuantile Qz("z");
66 
67  for (int i = 0; i != numberOfEvents; ++i) {
68 
69  const JVector3D vertex(0.0, 0.0, 0.0);
70 
71  // generate axes
72 
73  vector<JAxis3D> detector;
74 
75  for (int j = 0; j != numberOfAxes; ++j) {
76 
77  const double x = gRandom->Gaus(0.0, sigma);
78  const double y = gRandom->Gaus(0.0, sigma);
79  const double z = gRandom->Gaus(0.0, sigma);
80 
81  const double dx = gRandom->Uniform(-1, +1);
82  const double dy = gRandom->Uniform(-1, +1);
83  const double dz = gRandom->Uniform(-1, +1);
84 
85  detector.push_back(JAxis3D(vertex + JVector3D(x,y,z), JVersor3D(dx,dy,dz)));
86  }
87 
88  // fit
89 
90  JEstimator<JPoint3D> result(detector.begin(), detector.end());
91 
92  hx.Fill(vertex.getX() - result.getX());
93  hy.Fill(vertex.getY() - result.getY());
94  hz.Fill(vertex.getZ() - result.getZ());
95 
96  Qx.put(vertex.getX() - result.getX());
97  Qy.put(vertex.getY() - result.getY());
98  Qz.put(vertex.getZ() - result.getZ());
99  }
100 
101  if (debug >= debug_t) {
102  Qx.print(cout);
103  Qy.print(cout);
104  Qz.print(cout);
105  }
106 
107  if (outputFile != "") {
108 
109  TFile out(outputFile.c_str(), "recreate");
110 
111  out << hx << hy << hz;
112 
113  out.Write();
114  out.Close();
115  }
116 
117  ASSERT(numberOfEvents > 0);
118 
119  ASSERT(Qx.getMean() <= precision);
120  ASSERT(Qy.getMean() <= precision);
121  ASSERT(Qz.getMean() <= precision);
122 
123  ASSERT(Qx.getSTDev() <= precision);
124  ASSERT(Qy.getSTDev() <= precision);
125  ASSERT(Qz.getSTDev() <= precision);
126 
127  return 0;
128 }
Utility class to parse command line options.
Definition: JParser.hh:1410
debug
Definition: JMessage.hh:27
string outputFile
#define ASSERT(A)
Assert macro.
Definition: JMessage.hh:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65