File indexing completed on 2024-04-06 11:57:24
0001 #include <iostream>
0002
0003 #include "Alignment/SurveyAnalysis/interface/DTSurveyChamber.h"
0004 #include "Alignment/SurveyAnalysis/interface/Chi2.h"
0005
0006 DTSurveyChamber::DTSurveyChamber(int m_wheel, int m_station, int m_sector, long m_rawId) {
0007
0008 wheel = m_wheel;
0009 station = m_station;
0010 sector = m_sector;
0011 pointNumber = 0;
0012 rawId = m_rawId;
0013 }
0014
0015 void DTSurveyChamber::compute() {
0016 TMatrixD leftMatrix = makeMatrix();
0017 TMatrixD rightMatrix = makeVector();
0018 TMatrixD errors = makeErrors();
0019
0020 Chi2 myChi2(leftMatrix, rightMatrix, errors);
0021
0022 Solution.ResizeTo(6, 1);
0023 Solution = myChi2.getSolution();
0024 Covariance.ResizeTo(6, 6);
0025 Covariance = myChi2.getCovariance();
0026 }
0027
0028 void DTSurveyChamber::addPoint(int code, const TMatrixD &r, const TMatrixD &disp, const TMatrixD &err) {
0029 ++pointNumber;
0030
0031 points.push_back(r);
0032 pointsDiff.push_back(disp);
0033 pointsError.push_back(err);
0034 pointsTheoretical.push_back(r - disp);
0035 }
0036
0037 TMatrixD &DTSurveyChamber::makeVector() {
0038 TMatrixD *result = new TMatrixD(3 * getNumberPoints(), 1);
0039 result->Zero();
0040 int real = 0;
0041 for (std::vector<TMatrixD>::iterator p = pointsDiff.begin(); p != pointsDiff.end(); ++p) {
0042 (*result)(real * 3, 0) = (*p)(0, 0);
0043 (*result)(real * 3 + 1, 0) = (*p)(1, 0);
0044 (*result)(real * 3 + 2, 0) = (*p)(2, 0);
0045 ++real;
0046 }
0047 return *result;
0048 }
0049
0050 TMatrixD &DTSurveyChamber::makeErrors() {
0051 TMatrixD *result = new TMatrixD(3 * getNumberPoints(), 3 * getNumberPoints());
0052 result->Zero();
0053 int real = 0;
0054 for (std::vector<TMatrixD>::iterator p = pointsError.begin(); p != pointsError.end(); ++p) {
0055 double rmsn = 1.0 / ((*p)(0, 0) * (*p)(0, 0));
0056 (*result)(real * 3, real * 3) = rmsn;
0057 (*result)(real * 3 + 1, real * 3 + 1) = rmsn;
0058 (*result)(real * 3 + 2, real * 3 + 2) = rmsn;
0059 real++;
0060 }
0061 return *result;
0062 }
0063
0064 TMatrixD &DTSurveyChamber::makeMatrix() {
0065 TMatrixD *result = new TMatrixD(3 * getNumberPoints(), 6);
0066 result->Zero();
0067 int real = 0;
0068 for (std::vector<TMatrixD>::iterator p = pointsTheoretical.begin(); p != pointsTheoretical.end(); p++) {
0069 (*result)(real * 3, 0) = 1.0;
0070 (*result)(real * 3, 3) = (*p)(1, 0);
0071 (*result)(real * 3, 4) = (*p)(2, 0);
0072 (*result)(real * 3 + 1, 1) = 1.0;
0073 (*result)(real * 3 + 1, 3) = -(*p)(0, 0);
0074 (*result)(real * 3 + 1, 5) = (*p)(2, 0);
0075 (*result)(real * 3 + 2, 2) = 1.0;
0076 (*result)(real * 3 + 2, 4) = -(*p)(0, 0);
0077 (*result)(real * 3 + 2, 5) = -(*p)(1, 0);
0078 real++;
0079 }
0080 return *result;
0081 }
0082
0083 std::ostream &operator<<(std::ostream &flujo, const DTSurveyChamber &obj) {
0084 flujo << obj.getId() << " " << obj.getDeltaX() << " " << obj.getDeltaXError() << " " << obj.getDeltaY() << " "
0085 << obj.getDeltaYError() << " " << obj.getDeltaZ() << " " << obj.getDeltaZError() << " " << obj.getAlpha() << " "
0086 << obj.getAlphaError() << " " << obj.getBeta() << " " << obj.getBetaError() << " " << obj.getGamma() << " "
0087 << obj.getGammaError() << std::endl;
0088 return flujo;
0089 }