23{
25
26 int numberOfEvents;
27 double precision;
28 ULong_t seed;
30
31 try {
32
33 JParser<> zap(
"Example program to test intersection of straight line with cylinder.");
34
39
40 zap(argc, argv);
41 }
42 catch(const exception &error) {
43 FATAL(error.what() << endl);
44 }
45
46 gRandom->SetSeed(seed);
47
48
50
52
53
54 int number_of_errors = 0;
55 int number_of_events = 0;
56
57 for (int i = 0; i != numberOfEvents; ++i) {
58
60
61 const double x = gRandom->Uniform(-1.0, +1.0);
62 const double y = gRandom->Uniform(-1.0, +1.0);
63 const double z = gRandom->Uniform(-1.0, +1.0);
64
65 double dx;
66 double dy;
67 double dz;
68
69 gRandom->Sphere(dx, dy, dz, 1.0);
70
72
74
76 make_pair(intersection.first - 1*precision, false),
77 make_pair(2*precision, true),
78 make_pair(intersection.second - intersection.first - 2*precision, true),
79 make_pair(2*precision, false)
80 };
81
82 ++number_of_events;
83
84 bool ok = true;
85
86 const int N = sizeof(path)/sizeof(path[0]);
87
89
90 for (int i = 0; i != N; ++i) {
91
92 axis.move(path[i].first);
93
94 if ((getDistance(cylinder, axis.getPosition()) < 1e-3*precision) != path[i].second) {
95 ok = false;
96 }
97
98 pos[i] = axis.getPosition();
99 }
100
101 if (!ok) {
102
103 for (int i = 0; i != N; ++i) {
104 cout << endl << "point[" << noshowpos << setw(1) << i << "] = "
105 << showpos <<
FIXED(9,5) << pos[i].
getX() <<
' '
106 << showpos <<
FIXED(9,5) << pos[i].
getY() <<
' '
107 << showpos <<
FIXED(9,5) << pos[i].
getZ() <<
' '
108 <<
SCIENTIFIC(12,3) << cylinder.getDistance(pos[i]) <<
' '
109 << (cylinder.getDistance(pos[i]) < 1e-3*precision ? "in" : "out") << endl;
110 }
111 }
112
113 if (!ok) {
114 ++number_of_errors;
115 }
116 }
118
119 NOTICE(
"Number of errors: " << number_of_errors <<
" out of " << number_of_events <<
" events." << endl);
120
121 ASSERT(number_of_events > 0);
122 ASSERT(number_of_errors == 0);
123
124 return 0;
125}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Data structure for circle in two dimensions.
Data structure for vector in two dimensions.
Data structure for vector in three dimensions.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
Data structure for normalised vector in three dimensions.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Auxiliary data structure for floating point format specification.