41 template <
typename T1,
typename T2 >
43 enum {
result = std::numeric_limits<T1>::digits <= std::numeric_limits<T2>::digits };
46 template <
typename T1,
typename T2,
bool>
47 struct LessPreciseType {
50 template <
typename T1,
typename T2>
51 struct LessPreciseType<T1, T2, false> {
56 template <
typename Scalar1,
typename Scalar2>
58 closeEnough ( Scalar1 s1, Scalar2 s2, std::string
const & coord,
double ticks ) {
63 Scalar
epsilon = (eps1 >= eps2) ? eps1 : eps2;
64 int pr = std::cout.precision(18);
67 Scalar diff = ss1 - ss2;
68 if (diff < 0) diff = -diff;
69 if (ss1 == 0 || ss2 == 0) {
70 if ( diff > ticks*epsilon ) {
72 std::cout <<
"\nAbsolute discrepancy in " << coord <<
"(): " 73 << ss1 <<
" != " << ss2 <<
"\n" 74 <<
" (Allowed discrepancy is " << ticks*epsilon
75 <<
")\nDifference is " << diff/epsilon <<
" ticks\n";
77 std::cout.precision (pr);
83 if ( (sd1 + sd2 == sd1) != (sd1 + sd2 == sd2) ) {
85 std::cout <<
"\nInfinity discrepancy in " << coord <<
"(): " 86 << sd1 <<
" != " << sd2 <<
"\n";
87 std::cout.precision (pr);
90 Scalar denom = ss1 > 0 ? ss1 : -ss1;
91 if ((diff/denom > ticks*epsilon) && (diff > ticks*epsilon)) {
93 std::cout <<
"\nDiscrepancy in " << coord <<
"(): " 94 << ss1 <<
" != " << ss2 <<
"\n" 95 <<
" (Allowed discrepancy is " << ticks*epsilon*ss1
96 <<
")\nDifference is " << (diff/denom)/epsilon <<
" ticks\n";
98 std::cout.precision (pr);
103 template <
class V1,
class V2>
104 int compare4D (
const V1 & v1,
const V2 & v2,
double ticks) {
106 typedef typename V1::CoordinateType CoordType1;
107 typedef typename V2::CoordinateType CoordType2;
113 ret |=
closeEnough ( v1.rho(), v2.rho(),
"rho" ,ticks);
114 ret |=
closeEnough ( v1.phi(), v2.phi(),
"phi" ,ticks);
116 ret |=
closeEnough ( v1.theta(), v2.theta(),
"theta" ,ticks);
117 ret |=
closeEnough ( v1.perp2(), v2.perp2(),
"perp2" ,ticks);
118 ret |=
closeEnough ( v1.M2(), v2.M2(),
"m2" ,ticks);
120 ret |=
closeEnough ( v1.Mt(), v2.Mt(),
"mt" ,ticks);
121 ret |=
closeEnough ( v1.Et(), v2.Et(),
"et" ,ticks);
122 if ( v1.rho() > 0 && v2.rho() > 0 ) {
123 ret |=
closeEnough ( v1.eta(), v2.eta(),
"eta" ,ticks);
127 std::cout <<
"Discrepancy detected (see above) is between:\n " 130 <<
"with v = (" << v1.x() <<
", " << v1.y() <<
", " 131 << v1.z() <<
", " << v1.t() <<
")\n";
147 std::cout <<
"\n>>>>> Testing LorentzVector from " <<
XYZTVector(v) <<
" ticks = " << ticks <<
"\t: ";
164 std::cout <<
":::: rho != 0\n" 165 <<
":::: theta = " << theta
166 <<
"/n:::: tan(theta/2) = " <<
std::tan(theta/2)
167 <<
"\n:::: eta = " << eta <<
"\n";
169 }
else if (v.
z() == 0) {
172 std::cout <<
":::: v.z() == 0\n" 173 <<
"\n:::: eta = " << eta <<
"\n";
175 }
else if (v.
z() > 0) {
176 eta = v.
z() + etaMax<long double>();
178 std::cout <<
":::: v.z() > 0\n" 179 <<
":::: etaMax = " << etaMax<long double>()
180 <<
"\n:::: eta = " << eta <<
"\n";
183 eta = v.
z() - etaMax<long double>();
185 std::cout <<
":::: v.z() < 0\n" 186 <<
":::: etaMax = " << etaMax<long double>()
187 <<
"\n:::: eta = " << eta <<
"\n";
193 ret |=
compare4D( vxyzt_d, vrep_d, ticks);
196 ret |=
compare4D( vxyzt_d, vrepm_d, ticks);
199 ret |=
compare4D( vrep_d, vxyzm_d, ticks);
202 ret |=
compare4D( vxyzt_d, vxyzt_f, ticks);
205 ret |=
compare4D( vxyzt_f, vrep_f, ticks);
208 ret |=
compare4D( vxyzt_f, vrepm_f, ticks);
211 ret |=
compare4D( vrep_f, vxyzm_f, ticks);
213 if (ret == 0) std::cout <<
"\t OK\n";
215 std::cout <<
"\t FAIL\n";
216 std::cerr <<
"\n>>>>> Testing LorentzVector from " <<
XYZTVector(v) <<
" ticks = " << ticks
241 if (!testAll)
return ret;
255 if (ret) std::cerr <<
"test FAILED !!! " << std::endl;
256 else std::cout <<
"test OK " << std::endl;
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
int compare4D(const V1 &v1, const V2 &v2, double ticks)
LorentzVector< PxPyPzE4D< double > > XYZTVector
LorentzVector based on x,y,x,t (or px,py,pz,E) coordinates in double precision with metric (-...
static const std::string name()
int coordinates4D(bool testAll=false)
int test4D(const LorentzVector< C > &v, double ticks)
int closeEnough(Scalar1 s1, Scalar2 s2, std::string const &coord, double ticks)
RooCmdArg Precision(Double_t prec)
double atan2(double, double)
Scalar M() const
return magnitude (mass) using the (-,-,-,+) metric.