Commit 3fa9c87b by Claus Kleinwort

examples reworked

`git-svn-id: http://svnsrv.desy.de/public/GeneralBrokenLines/trunk@141 281f6f2b-e318-4fd1-8bce-1a4ba7aab212`
parent e5972dd1
 ... ... @@ -28,52 +28,12 @@ */ #include #include "example1.h" #include "exampleUtil.h" #include "GblTrajectory.h" using namespace gbl; using namespace Eigen; Matrix5d gblSimpleJacobian(double ds, double cosl, double bfac) { /// Simple jacobian: quadratic in arc length difference /** * \param [in] ds (3D) arc-length * \param [in] cosl cos(lambda) * \param [in] bfac Bz*c * \return jacobian */ Matrix5d jac; jac.setIdentity(); jac(1, 0) = -bfac * ds * cosl; jac(3, 0) = -0.5 * bfac * ds * ds * cosl; jac(3, 1) = ds; jac(4, 2) = ds; return jac; } double unrm() { /// unit normal distribution, Box-Muller method, polar form static double unrm2 = 0.0; static bool cached = false; if (!cached) { double x, y, r; do { x = 2.0 * rand() / RAND_MAX - 1; y = 2.0 * rand() / RAND_MAX - 1; r = x * x + y * y; } while (r == 0.0 || r > 1.0); // (x,y) in unit circle double d = sqrt(-2.0 * log(r) / r); double unrm1 = x * d; unrm2 = y * d; cached = true; return unrm1; } else { cached = false; return unrm2; } } void example1() { /// Simple technical example (curvilinear as local system). /** ... ...
 ... ... @@ -28,52 +28,12 @@ */ #include #include "example1.h" #include "exampleUtil.h" #include "GblTrajectory.h" using namespace gbl; using namespace Eigen; Matrix5d gblSimpleJacobian2(double ds, double cosl, double bfac) { /// Simple jacobian: quadratic in arc length difference /** * \param [in] ds (3D) arc-length * \param [in] cosl cos(lambda) * \param [in] bfac Bz*c * \return jacobian */ Matrix5d jac; jac.setIdentity(); jac(1, 0) = -bfac * ds * cosl; jac(3, 0) = -0.5 * bfac * ds * ds * cosl; jac(3, 1) = ds; jac(4, 2) = ds; return jac; } double unrm2() { /// unit normal distribution, Box-Muller method, polar form static double unrm2 = 0.0; static bool cached = false; if (!cached) { double x, y, r; do { x = 2.0 * rand() / RAND_MAX - 1; y = 2.0 * rand() / RAND_MAX - 1; r = x * x + y * y; } while (r == 0.0 || r > 1.0); // (x,y) in unit circle double d = sqrt(-2.0 * log(r) / r); double unrm1 = x * d; unrm2 = y * d; cached = true; return unrm1; } else { cached = false; return unrm2; } } void example2() { /// Simple technical example (measurement as local system). /** ... ... @@ -151,7 +111,7 @@ void example2() { for (unsigned int iTry = 1; iTry <= nTry; ++iTry) { // curvilinear track parameters for (unsigned int i = 0; i < 5; ++i) { clPar[i] = clErr[i] * unrm2(); clPar[i] = clErr[i] * unrm(); } // std::cout << " Try " << iTry << ":" << clPar << std::endl; Matrix2d addDer; ... ... @@ -197,7 +157,7 @@ void example2() { // measurement - prediction in measurement system with error Vector2d meas = proL2m * clPar.tail(2); for (unsigned int i = 0; i < 2; ++i) { meas[i] += measErr[i] * unrm2(); meas[i] += measErr[i] * unrm(); } pointMeas.addMeasurement(meas, measPrec); ... ... @@ -205,7 +165,7 @@ void example2() { listOfPoints.push_back(pointMeas); // propagate to scatterer jacPointToPoint = gblSimpleJacobian2(step, cosLambda, bfac); jacPointToPoint = gblSimpleJacobian(step, cosLambda, bfac); clPar = jacPointToPoint * clPar; s += step; if (iLayer < nLayer - 1) { ... ... @@ -223,7 +183,7 @@ void example2() { listOfPoints.push_back(pointScat); // scatter a little for (unsigned int i = 0; i < 2; ++i) { clPar[i + 1] += scatErr[i] * unrm2(); clPar[i + 1] += scatErr[i] * unrm(); } // propagate to next measurement layer clPar = jacPointToPoint * clPar; ... ...
 ... ... @@ -28,52 +28,12 @@ */ #include #include "example1.h" #include "exampleUtil.h" #include "GblTrajectory.h" using namespace gbl; using namespace Eigen; Matrix5d gblSimpleJacobian3(double ds, double cosl, double bfac) { /// Simple jacobian: quadratic in arc length difference /** * \param [in] ds (3D) arc-length * \param [in] cosl cos(lambda) * \param [in] bfac Bz*c * \return jacobian */ Matrix5d jac; jac.setIdentity(); jac(1, 0) = -bfac * ds * cosl; jac(3, 0) = -0.5 * bfac * ds * ds * cosl; jac(3, 1) = ds; jac(4, 2) = ds; return jac; } double unrm3() { /// unit normal distribution, Box-Muller method, polar form static double unrm2 = 0.0; static bool cached = false; if (!cached) { double x, y, r; do { x = 2.0 * rand() / RAND_MAX - 1; y = 2.0 * rand() / RAND_MAX - 1; r = x * x + y * y; } while (r == 0.0 || r > 1.0); // (x,y) in unit circle double d = sqrt(-2.0 * log(r) / r); double unrm1 = x * d; unrm2 = y * d; cached = true; return unrm1; } else { cached = false; return unrm2; } } void example3() { /// Simple technical example (measure scattering). /** ... ... @@ -156,7 +116,7 @@ void example3() { for (unsigned int iTry = 1; iTry <= nTry; ++iTry) { // curvilinear track parameters for (unsigned int i = 0; i < 5; ++i) { clPar[i] = clErr[i] * unrm3(); clPar[i] = clErr[i] * unrm(); } clCov.setZero(); for (unsigned int i = 0; i < 5; ++i) { ... ... @@ -192,7 +152,7 @@ void example3() { // measurement - prediction in measurement system with error Vector2d meas = proL2m * clPar.tail(2); for (unsigned int i = 0; i < 2; ++i) { meas[i] += measErr[i] * unrm3(); meas[i] += measErr[i] * unrm(); } pointMeas.addMeasurement(proL2m, meas, measPrec); /* point with (correlated) measurements (in local system) ... ... @@ -220,7 +180,7 @@ void example3() { clSeed = clCov.inverse(); } // propagate to scatterer jacPointToPoint = gblSimpleJacobian3(step, cosLambda, bfac); jacPointToPoint = gblSimpleJacobian(step, cosLambda, bfac); clPar = jacPointToPoint * clPar; clCov = jacPointToPoint * clCov * jacPointToPoint.adjoint(); s += step; ... ... @@ -241,7 +201,7 @@ void example3() { } // scatter a little for (unsigned int i = 0; i < 2; ++i) { clPar[i + 1] += scatErr[i] * unrm3(); clPar[i + 1] += scatErr[i] * unrm(); clCov(i + 1, i + 1) += scatErr[i] * scatErr[i]; } // propagate to next measurement layer ... ...