31{
34
35 string inputFile;
37 int numberOfEvents;
38 int numberOfPMTs;
39 double precision;
41
42 try {
43
44 JParser<> zap(
"Test program for vertex fit.");
45
52
53 zap(argc, argv);
54 }
55 catch(const exception& error) {
56 FATAL(error.what() << endl);
57 }
58
59
60 TH1D hx("hx", NULL, 101, -1.0, +1.0);
61 TH1D hy("hy", NULL, 101, -1.0, +1.0);
62 TH1D ht("ht", NULL, 101, -1.0, +1.0);
63
67
68
70
72
73 if (inputFile != "") {
74
75 ifstream in(inputFile.c_str());
76
77 for (
double x, y, z; in >>
x >>
y >> z; ) {
79 }
80
81 in.close();
82
83 } else {
84
86
87 for (int i = 0; i != numberOfPMTs; ++i) {
89 }
90 }
91
92
94
95 const double xmin = -1.0;
96 const double xmax = +1.0;
97
98 const double tmin = -1.0;
99 const double tmax = +1.0;
100
101 for (int i = 0; i != numberOfEvents; ++i) {
102
103
104
105 const double x = 0.0 + gRandom->Uniform(xmin, xmax);
106 const double y = 0.0 + gRandom->Uniform(xmin, xmax);
107 const double z = 0.0;
108 const double t = 0.0 + gRandom->Uniform(tmin, tmax);
109
111
113 <<
FIXED(12,5) << line.getX() <<
' '
114 <<
FIXED(12,5) << line.getY() <<
' '
115 <<
FIXED(12,5) << line.getZ() <<
' '
116 <<
FIXED(12,5) << line.getT() << endl);
117
118
119
121
122 for (JDetector_t::const_iterator pos =
detector.begin(); pos !=
detector.end(); ++pos) {
123 data.push_back(
JHit_t(*pos, line.getT(*pos)));
124 }
125
126 for (vector<JHit_t>::const_iterator hit =
data.begin(); hit !=
data.end(); ++hit) {
128 <<
FIXED(12,5) << hit->getX() <<
' '
129 <<
FIXED(12,5) << hit->getY() <<
' '
130 <<
FIXED(12,5) << hit->getZ() <<
' '
131 <<
FIXED(12,5) << hit->getT() << endl);
132 }
133
134
135
137
138 result.setZ(line.getZ(), getSpeedOfLight());
139
145
146 hx.Fill(line.getX() -
result.getX());
147 hy.Fill(line.getY() -
result.getY());
148 ht.Fill(line.getT() -
result.getT());
149
150 Qx.put(line.getX() -
result.getX());
151 Qy.put(line.getY() -
result.getY());
152 Qt.put(line.getT() -
result.getT());
153 }
154
155 if (
debug >= debug_t) {
156 Qx.print(cout);
157 Qy.print(cout);
158 Qt.print(cout);
159 }
160
162
164
165 out << hx << hy << ht;
166
167 out.Write();
168 out.Close();
169 }
170
171 ASSERT(numberOfEvents > 0);
172
173 ASSERT(fabs(Qx.getMean()) <= precision);
174 ASSERT(fabs(Qy.getMean()) <= precision);
175 ASSERT(fabs(Qt.getMean()) <= precision);
176
177 ASSERT(Qx.getSTDev() <= precision);
178 ASSERT(Qy.getSTDev() <= precision);
179 ASSERT(Qt.getSTDev() <= precision);
180
181 return 0;
182}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Template definition of linear fit.
Data structure for fit of straight line paralel to z-axis.
Data structure for circle in two dimensions.
Data structure for vector in two dimensions.
Data structure for vector in three dimensions.
Utility class to parse command line options.
JVector3D getRandomPosition(const JSphere3D &sphere)
Get random position.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Auxiliary class to set-up Hit.