60 unsigned int nTry = 1000;
61 unsigned int nLayer = 10;
62 bool useThickScatterer =
true;
63 std::cout <<
" Gbltst-thickScat $Id: 4dad593b54fd71605954af13372263355af83f16 $ " << nTry <<
", " << nLayer
64 <<
", useThickScat: " << useThickScatterer << std::endl;
68 clock_t startTime = clock();
70 double sinLambda = 0.3;
71 double cosLambda = sqrt(1.0 - sinLambda * sinLambda);
73 double cosPhi = sqrt(1.0 - sinPhi * sinPhi);
76 Matrix<double, 2, 3> uvDir;
77 uvDir(0, 0) = -sinPhi;
80 uvDir(1, 0) = -sinLambda * cosPhi;
81 uvDir(1, 1) = -sinLambda * sinPhi;
82 uvDir(1, 2) = cosLambda;
85 measErr << 0.001, 0.001;
87 measPrec << 1.0 / (measErr(0) * measErr(0)), 1.0 / (measErr(1) * measErr(1));
90 scatErr << 0.001, 0.001;
92 Vector2d scat(0., 0.);
93 scatPrec << 1.0 / (scatErr(0) * scatErr(0)), 1.0 / (scatErr(1) * scatErr(1));
94 Matrix4d scatPrecThick;
95 Vector4d scatThick(0., 0., 0., 0.);
99 clErr << 0.001, -0.1, 0.2, -0.15, 0.25;
103 unsigned int numScat;
106 addPar << 0.0025, -0.005;
107 std::vector<int> globalLabels;
108 globalLabels.push_back(4711);
109 globalLabels.push_back(4712);
115 double bfac = 0.2998;
116 double step = 1.5 / cosLambda;
123 for (
unsigned int iTry = 1; iTry <= nTry; ++iTry) {
125 for (
unsigned int i = 0; i < 5; ++i) {
126 clPar[i] = clErr[i] *
unrm();
135 Matrix5d jacPointToPoint, jacToNextPlane;
136 jacPointToPoint.setIdentity();
140 std::vector<GblPoint> listOfPoints;
141 listOfPoints.reserve(2 * nLayer);
143 for (
unsigned int iLayer = 0; iLayer < nLayer; ++iLayer) {
146 double sinStereo = (iLayer % 2 == 0) ? 0. : 0.1;
147 double cosStereo = sqrt(1.0 - sinStereo * sinStereo);
148 Matrix<double, 3, 2> mDirT;
150 mDirT(1, 0) = cosStereo;
151 mDirT(2, 0) = sinStereo;
152 mDirT(1, 1) = -sinStereo;
153 mDirT(2, 1) = cosStereo;
155 Matrix2d proM2l = uvDir * mDirT;
157 Matrix2d proL2m = proM2l.inverse();
159 GblPoint pointMeas(jacPointToPoint);
161 Vector2d meas = proL2m * clPar.tail(2);
163 for (
unsigned int i = 0; i < 2; ++i) {
164 meas[i] += measErr[i] *
unrm();
173 if (useThickScatterer) {
177 <<
" Singular cov. matrix for thick scatterer at layer "
178 << iLayer << std::endl;
179 std::cout << scatCov << std::endl;
182 scatPrecThick = scatCov.inverse();
194 for (
unsigned int i = 0; i < 2; ++i) {
195 clPar[i + 1] += scatErr[i] *
unrm();
196 scatCov(i, i) += scatErr[i] * scatErr[i];
199 listOfPoints.push_back(pointMeas);
201 if (iLayer == nLayer - 1)
205 jacPointToPoint = jacToNextPlane;
207 clPar = jacToNextPlane * clPar;
208 scatCov = jacToNextPlane.bottomRightCorner<4, 4>() * scatCov
209 * jacToNextPlane.bottomRightCorner<4, 4>().transpose();
212 if (useThickScatterer) {
214 jacPointToPoint = jacToNextPlane * jacPointToPoint;
219 listOfPoints.push_back(pointScat);
223 for (
unsigned int i = 0; i < 2; ++i) {
224 clPar[i + 1] += scatErr[i] *
unrm();
225 scatCov(i, i) += scatErr[i] * scatErr[i];
228 clPar = jacToNextPlane * clPar;
229 scatCov = jacToNextPlane.bottomRightCorner<4, 4>() * scatCov
230 * jacToNextPlane.bottomRightCorner<4, 4>().transpose();
247 traj.
fit(Chi2, Ndf, lostWeight);
278 LostSum += lostWeight;
282 clock_t endTime = clock();
283 double diff = endTime - startTime;
284 double cps = CLOCKS_PER_SEC;
285 std::cout <<
" Time elapsed " << diff / cps <<
" s" << std::endl;
286 std::cout <<
" Chi2/Ndf = " << Chi2Sum / NdfSum << std::endl;
287 std::cout <<
" Tracks fitted " << numFit << std::endl;
289 std::cout <<
" Weight lost " << LostSum << std::endl;
GblTrajectory definition.
Definitions for GBL utilities.
void addThickScatterer(const Eigen::Vector4d &aResiduals, const Eigen::Matrix4d &aPrecision)
Add a thick scatterer to a point.
void addMeasurement(const Eigen::MatrixBase< Projection > &aProjection, const Eigen::MatrixBase< Residuals > &aResiduals, const Eigen::MatrixBase< Precision > &aPrecision, double minPrecision=0.)
Add a measurement to a point.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::Matrix2d &aPrecision)
Add a thin scatterer to a point.
unsigned int fit(double &Chi2, int &Ndf, double &lostWeight, const std::string &optionList="", unsigned int aLabel=0)
Perform fit of (valid) trajectory.
Namespace for the general broken lines package.
double unrm()
unit normal distribution, Box-Muller method, polar form
Eigen::Matrix< double, 5, 1 > Vector5d
Matrix5d gblSimpleJacobian(double ds, double cosl, double bfac)
Simple jacobian.
Eigen::Matrix< double, 5, 5 > Matrix5d