38 template <
typename T1,
typename T2 >
40 enum {
result = std::numeric_limits<T1>::digits <= std::numeric_limits<T2>::digits };
43 template <
typename T1,
typename T2,
bool>
44 struct LessPreciseType {
47 template <
typename T1,
typename T2>
48 struct LessPreciseType<T1, T2, false> {
53 template <
typename Scalar1,
typename Scalar2>
55 closeEnough ( Scalar1 s1, Scalar2 s2, std::string
const & coord,
double ticks ) {
57 int pr = std::cout.precision(18);
61 Scalar
epsilon = (eps1 >= eps2) ? eps1 : eps2;
64 Scalar diff = ss1 - ss2;
65 if (diff < 0) diff = -diff;
66 if (ss1 == 0 || ss2 == 0) {
67 if ( diff > ticks*epsilon ) {
69 std::cout <<
"\nAbsolute discrepancy in " << coord <<
"(): " 70 << ss1 <<
" != " << ss2 <<
"\n" 71 <<
" (Allowed discrepancy is " << ticks*epsilon
72 <<
")\nDifference is " << diff/epsilon <<
" ticks\n";
74 std::cout.precision (pr);
80 if ( (sd1 + sd2 == sd1) != (sd1 + sd2 == sd2) ) {
82 std::cout <<
"\nInfinity discrepancy in " << coord <<
"(): " 83 << sd1 <<
" != " << sd2 <<
"\n";
84 std::cout.precision (pr);
87 Scalar denom = ss1 > 0 ? ss1 : -ss1;
88 if ((diff/denom > ticks*epsilon) && (diff > ticks*epsilon)) {
90 std::cout <<
"\nDiscrepancy in " << coord <<
"(): " 91 << ss1 <<
" != " << ss2 <<
"\n" 92 <<
" (Allowed discrepancy is " << ticks*epsilon*ss1
93 <<
")\nDifference is " << (diff/denom)/epsilon <<
" ticks\n";
95 std::cout.precision (pr);
99 template <
class V1,
class V2>
100 int compare3D (
const V1 & v1,
const V2 & v2,
double ticks) {
102 typedef typename V1::CoordinateType CoordType1;
103 typedef typename V2::CoordinateType CoordType2;
107 ret |=
closeEnough ( v1.rho(), v2.rho(),
"rho" ,ticks);
110 Scalar phi2 = v2.phi();
117 ret |=
closeEnough ( v1.phi(), phi2,
"phi" ,ticks);
119 ret |=
closeEnough ( v1.theta(), v2.theta(),
"theta" ,ticks);
120 ret |=
closeEnough ( v1.mag2(), v2.mag2(),
"mag2" ,ticks);
121 ret |=
closeEnough ( v1.perp2(), v2.perp2(),
"perp2" ,ticks);
122 if ( v1.rho() > 0 && v2.rho() > 0 ) {
123 ret |=
closeEnough ( v1.eta(), v2.eta(),
"eta" ,ticks);
127 std::cout <<
"\nDiscrepancy detected (see above) is between:\n " 130 <<
"with v = (" << v1.x() <<
", " << v1.y() <<
", " << v1.z()
147 std::cout <<
"\n>>>>> Testing 3D from " << v <<
" ticks = " << ticks << std::endl;
167 std::cout <<
":::: rho != 0\n" 168 <<
":::: theta = << " << theta
169 <<
"/n:::: tan(theta/2) = " <<
std::tan(theta/2)
170 <<
"\n:::: eta = " << eta <<
"\n";
172 }
else if (v.
z() == 0) {
175 std::cout <<
":::: v.z() == 0\n" 176 <<
"\n:::: eta = " << eta <<
"\n";
178 }
else if (v.
z() > 0) {
179 eta = v.
z() + etaMax<long double>();
181 std::cout <<
":::: v.z() > 0\n" 182 <<
":::: etaMax = " << etaMax<long double>()
183 <<
"\n:::: eta = " << eta <<
"\n";
186 eta = v.
z() - etaMax<long double>();
188 std::cout <<
":::: v.z() < 0\n" 189 <<
":::: etaMax = " << etaMax<long double>()
190 <<
"\n:::: eta = " << eta <<
"\n";
195 std::cout <<
" Testing DisplacementVector3D : ";
200 ret |=
compare3D( vxyz_d, vrtp_d, ticks);
201 ret |=
compare3D( vrtp_d, vxyz_d, ticks);
202 ret |=
compare3D( vxyz_d, vrep_d, ticks);
203 ret |=
compare3D( vrtp_d, vrep_d, ticks);
207 ret |=
compare3D( vxyz_d, vrzp_d, ticks);
208 ret |=
compare3D( vrtp_d, vrzp_d, ticks);
209 ret |=
compare3D( vrep_d, vrzp_d, ticks);
215 ret |=
compare3D( vxyz_d, vxyz_f, ticks);
216 ret |=
compare3D( vxyz_d, vrep_f, ticks);
217 ret |=
compare3D( vrtp_d, vrep_f, ticks);
219 ret |=
compare3D( vxyz_f, vxyz_f, ticks);
220 ret |=
compare3D( vxyz_f, vrep_f, ticks);
221 ret |=
compare3D( vrtp_f, vrep_f, ticks);
224 if (ret == 0) std::cout <<
"\t OK\n";
226 std::cout <<
"\t FAIL\n";
227 std::cerr <<
"\n>>>>> Testing DisplacementVector3D from " << v <<
" ticks = " << ticks
230 std::cout <<
" Testing PositionVector3D : ";
239 ret |=
compare3D( pxyz_d, prtp_d, ticks);
240 ret |=
compare3D( vxyz_d, prep_d, ticks);
241 ret |=
compare3D( vrtp_d, prep_d, ticks);
242 ret |=
compare3D( vxyz_d, przp_d, ticks);
248 ret |=
compare3D( vxyz_d, pxyz_f, ticks);
249 ret |=
compare3D( vxyz_d, prep_f, ticks);
250 ret |=
compare3D( vrtp_d, prep_f, ticks);
252 ret |=
compare3D( vxyz_f, pxyz_f, ticks);
253 ret |=
compare3D( vxyz_f, prep_f, ticks);
254 ret |=
compare3D( vrtp_f, prep_f, ticks);
257 if (ret == 0) std::cout <<
"\t\t OK\n";
259 std::cout <<
"\t FAIL\n";
260 std::cerr <<
"\n>>>>> Testing PositionVector3D from " << v <<
" ticks = " << ticks
321 if (ret) std::cerr <<
"test FAILED !!! " << std::endl;
322 else std::cout <<
"test OK " << std::endl;
Class describing a generic position vector (point) in 3 dimensions.
int test3D(const DisplacementVector3D< C > &v, double ticks)
static const std::string name()
int compare3D(const V1 &v1, const V2 &v2, double ticks)
Class describing a generic displacement vector in 3 dimensions.
double Pi()
Mathematical constants.
int closeEnough(Scalar1 s1, Scalar2 s2, std::string const &coord, double ticks)
RooCmdArg Precision(Double_t prec)
double atan2(double, double)
you should not use this method at all Int_t Int_t z
Rotation3D::Scalar Scalar