//--------------------------------------------------------------------- #include #include int tests() { cout << "tests.C is now loaded." << endl; cout << "To run a test of a class, type Test()" << endl; cout << "Example: TestFourVectorReal()" << endl; return 0; } void TestThreeVectorReal () { TThreeVectorReal v3v; v3v.Zero(); cout << "Zero(): "; v3v.Print(); v3v[1] = 1; v3v[2] = 2; v3v[3] = 3; cout << "Set to 1,2,3: "; v3v.Print(); TThreeVectorReal v3w(4,5,6); cout << "Initialized to 4,5,6: "; v3w.Print(); Float_t aarray[]={7,8,9,10}; TThreeVectorReal v3x(aarray); cout << "Initialized to (Float_t *) 7,8,9: "; v3x.Print(); Double_t darray[]={10,11,12,13}; TThreeVectorReal v3y(darray); cout << "Initialized to (Double_t *) 10,11,12: "; v3y.Print(); TThreeVectorReal v3z(v3v); cout << "Initialized to (TThreeVectorReal) 1,2,3: "; v3z.Print(); v3z.SpaceInv(); cout << "SpaceInv(): "; v3z.Print(); v3z.Normalize(1); cout << "Normalize(1): "; v3z.Print(); v3z.SetPolar(10,2.5,-1.2); cout << "SetPolar(10,2.5,-1.2) : GetPolar("; cout << v3z.Length() << "," << v3z.Theta() << "," << v3z.Phi() << ")" << endl; cout << "z == z ? " << ((v3z == v3z) ? "yes!" : "no!") << endl; cout << "z != w ? " << ((v3z != v3w) ? "yes!" : "no!") << endl; v3z.Rotate(-1.2,2.5,0); Double_t v3zhat[]={0,0,10}; cout << "Rotate(phi,theta,0) gets back z axis? "; cout << ((v3z == v3zhat) ? "yes!" : "no!" ) << endl; cout << "(w cross x) != 0 ? "; cout << ((v3z.Cross(v3w,v3x).Length() >= v3w.Resolution()) ? "yes!" : "no!" ) << endl; cout << "w dot (w cross x) == 0 ? "; cout << ((v3w.Dot(v3z.Cross(v3w,v3x)) < v3w.Resolution()) ? "yes!" : "no!" ) << endl; v3y.Cross(v3w,v3w-v3x); v3z.Cross(v3x,v3w); cout << "w cross (w - x) == x cross w ? "; cout << ((v3y.Cross(v3w,v3w-v3x) == v3z.Cross(v3x,v3w)) ? "yes!" : "no!" ) << endl; } void TestThreeVectorComplex () { TThreeVectorComplex v3v; v3v.Zero(); cout << "Zero(): "; v3v.Print(); v3v[1] = 1; v3v[2] = 2; v3v[3] = 3; cout << "Set to 1,2,3: "; v3v.Print(); TThreeVectorComplex v3w(4,5,6); cout << "Initialized to 4,5,6: "; v3w.Print(); Float_t farray[]={7,8,9,10}; TThreeVectorComplex v3x(farray); cout << "Initialized to (Float_t *) 7,8,9: "; v3x.Print(); Double_t darray[]={10,11,12,13}; TThreeVectorComplex v3y(darray); cout << "Initialized to (Double_t *) 10,11,12: "; v3y.Print(); TThreeVectorComplex v3z(v3v); cout << "Initialized to (TThreeVectorComplex) 1,2,3: "; v3z.Print(); v3z.SpaceInv(); cout << "SpaceInv(): "; v3z.Print(); v3z.Normalize(1); cout << "Normalize(1): "; v3z.Print(); cout << "z == z ? " << ((v3z == v3z) ? "yes!" : "no!") << endl; cout << "z != w ? " << ((v3z != v3w) ? "yes!" : "no!") << endl; TThreeVectorReal v3r(242.99,-485,0.6666); v3z = v3r.Normalize(10); v3z.Rotate(v3r.Phi(),v3r.Theta(),0); Double_t v3zhat[]={0,0,10}; cout << "Rotate(phi,theta,0) gets back z axis? "; cout << ((v3z == v3zhat) ? "yes!" : "no!" ) << endl; cout << "(w cross x) != 0 ? "; cout << ((v3z.Cross(v3w,v3x).Length() >= v3w.Resolution()) ? "yes!" : "no!" ) << endl; cout << "w dot (w cross x) == 0 ? "; cout << ((abs(v3w.Dot(v3z.Cross(v3w,v3x))) < v3w.Resolution()) ? "yes!" : "no!" ) << endl; v3y.Cross(v3w,v3w-v3x); v3z.Cross(v3x,v3w); cout << "w cross (w - x) == x cross w ? "; cout << ((v3y.Cross(v3w,v3w-v3x) == v3z.Cross(v3x,v3w)) ? "yes!" : "no!" ) << endl; } void TestFourVectorReal () { TFourVectorReal v4v; v4v.Zero(); cout << "Zero(): "; v4v.Print(); v4v[0] = 10; v4v[1] = 1; v4v[2] = 2; v4v[3] = 3; cout << "Set to 10,1,2,3: "; v4v.Print(); TFourVectorReal v4w(-4,4,5,6); cout << "Initialized to -4,4,5,6: "; v4w.Print(); Float_t aarray[]={7,8,9,10}; TFourVectorReal v4x(aarray); cout << "Initialized to (Float_t *) 7,8,9,10: "; v4x.Print(); Double_t darray[]={10,11,12,13}; TFourVectorReal v4y(darray); cout << "Initialized to (Double_t *) 10,11,12,13: "; v4y.Print(); TFourVectorReal v4z(v4v); cout << "Initialized to (TFourVectorReal) 10,1,2,3: "; v4z.Print(); v4z.SpaceInv(); cout << "SpaceInv(): "; v4z.Print(); v4z /= v4z.Invariant(); cout << "v4z /= v4z.Invariant(): "; v4z.Print(); TFourVectorReal v4u(v4z); v4z.Boost(0,0,.99); cout << "v4z.Boost(0,0,.99): "; v4z.Print(); cout << "Lorentz invariant? "; cout << ((abs(v4z.Invariant()-v4u.Invariant()) < v4z.Resolution()) ? "yes!" : "no!") << endl; v4z.Boost(0,0,-.99); cout << "Boost back, recover original vector? "; cout << ((v4z == v4u) ? "yes!" : "no!") << endl; } void TestFourVectorComplex () { TFourVectorComplex v4v; v4v.Zero(); cout << "Zero(): "; v4v.Print(); v4v[0] = 10; v4v[1] = 1; v4v[2] = 2; v4v[3] = 3; cout << "Set to 10,1,2,3: "; v4v.Print(); TFourVectorComplex v4w(-4,4,5,6); cout << "Initialized to -4,4,5,6: "; v4w.Print(); Float_t aarray[]={7,8,9,10}; TFourVectorComplex v4x(aarray); cout << "Initialized to (Float_t *) 7,8,9,10: "; v4x.Print(); Double_t darray[]={10,11,12,13}; TFourVectorComplex v4y(darray); cout << "Initialized to (Double_t *) 10,11,12,13: "; v4y.Print(); TFourVectorComplex v4z(v4v); cout << "Initialized to (TFourVectorComplex) 10,1,2,3: "; v4z.Print(); v4z.SpaceInv(); cout << "SpaceInv(): "; v4z.Print(); v4z /= v4z.Invariant(); cout << "v4z /= v4z.Invariant(): "; v4z.Print(); TFourVectorComplex v4u(v4z); v4z.Boost(0,0,.99); cout << "v4z.Boost(0,0,.99): "; v4z.Print(); cout << "Lorentz invariant? "; cout << ((abs(v4z.Invariant()-v4u.Invariant()) < v4z.Resolution()) ? "yes!" : "no!") << endl; v4z.Boost(0,0,-.99); cout << "Boost back, recover original vector? "; cout << ((v4z == v4u) ? "yes!" : "no!") << endl; } void TestRotation () { TThreeVectorReal w1(0,0,1.2); TThreeVectorReal w2(0,0.887,0); TThreeVectorReal w3(0,0,-1.557); TThreeRotation r1(w1), r2(w2), r3(w3); TThreeRotation r123=r3*r2*r1; Double_t phi=0,theta=0,psi=0; r123.GetEuler(phi,theta,psi); cout << "First rotate 1.2 radians about z axis" <