Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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"
#include "Jeep/JPrint.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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 28 of file JPoint3D.cc.

29{
30 using namespace std;
31 using namespace JPP;
32
33 string outputFile;
34 int numberOfEvents;
35 int numberOfAxes;
36 double sigma;
37 double precision;
38 int debug;
39
40 try {
41
42 JParser<> zap("Test program for position fit.");
43
44 zap['o'] = make_field(outputFile) = "";
45 zap['n'] = make_field(numberOfEvents) = 1000;
46 zap['N'] = make_field(numberOfAxes) = 3;
47 zap['s'] = make_field(sigma) = 1.0e-4;
48 zap['e'] = make_field(precision) = 1.0e-3;
49 zap['d'] = make_field(debug) = 3;
50
51 zap(argc, argv);
52 }
53 catch(const exception &error) {
54 FATAL(error.what() << endl);
55 }
56
57
58 TH1D hx("hx", NULL, 101, -1.0, +1.0);
59 TH1D hy("hy", NULL, 101, -1.0, +1.0);
60 TH1D hz("hz", NULL, 101, -1.0, +1.0);
61
62 JQuantile Qx("x");
63 JQuantile Qy("y");
64 JQuantile Qz("z");
65
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
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
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(fabs(Qx.getMean()) <= precision);
120 ASSERT(fabs(Qy.getMean()) <= precision);
121 ASSERT(fabs(Qz.getMean()) <= precision);
122
123 ASSERT(Qx.getSTDev() <= precision);
124 ASSERT(Qy.getSTDev() <= precision);
125 ASSERT(Qz.getSTDev() <= precision);
126
127 return 0;
128}
string outputFile
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Template definition of linear fit.
Definition JEstimator.hh:25
Axis object.
Definition JAxis3D.hh:41
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
Data structure for normalised vector in three dimensions.
Definition JVersor3D.hh:28
Utility class to parse command line options.
Definition JParser.hh:1698
const double sigma[]
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int j
Definition JPolint.hh:801
Detector file.
Definition JHead.hh:227
Auxiliary data structure for running average, standard deviation and quantiles.
Definition JQuantile.hh:46