CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Alignment/SurveyAnalysis/src/DTSurveyChamber.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include "Alignment/SurveyAnalysis/interface/DTSurveyChamber.h"
00004 #include "Alignment/SurveyAnalysis/interface/Chi2.h" 
00005 
00006 
00007 DTSurveyChamber::DTSurveyChamber(int m_wheel, int m_station, int m_sector, long m_rawId) {
00008   
00009   //Coordinates of the chamber
00010   wheel = m_wheel;
00011   station = m_station;
00012   sector = m_sector;
00013   pointNumber = 0;
00014   rawId = m_rawId;  
00015    
00016 }
00017 
00018 
00019 void DTSurveyChamber::compute() {
00020   
00021   TMatrixD leftMatrix = makeMatrix();
00022   TMatrixD rightMatrix = makeVector();
00023   TMatrixD errors = makeErrors();
00024   
00025   Chi2 myChi2(leftMatrix, rightMatrix, errors);
00026   
00027   Solution.ResizeTo(6,1);
00028   Solution = myChi2.getSolution();
00029   Covariance.ResizeTo(6,6);
00030   Covariance = myChi2.getCovariance();
00031 
00032 }
00033 
00034 
00035 void DTSurveyChamber::addPoint(int code, const TMatrixD& r, const TMatrixD& disp, const TMatrixD& err) {
00036   
00037   
00038   ++pointNumber;
00039 
00040   points.push_back(r);
00041   pointsDiff.push_back(disp);
00042   pointsError.push_back(err);
00043   pointsTheoretical.push_back(r-disp);
00044 
00045 }
00046   
00047 
00048 
00049 TMatrixD & DTSurveyChamber::makeVector() {
00050 
00051   TMatrixD *result = new TMatrixD(3*getNumberPoints(),1);
00052   result->Zero();
00053   int real = 0;
00054   for(std::vector<TMatrixD >::iterator p = pointsDiff.begin(); p != pointsDiff.end(); ++p) {  
00055     (*result)(real*3,0) = (*p)(0,0);
00056     (*result)(real*3+1,0) = (*p)(1,0);
00057     (*result)(real*3+2,0) = (*p)(2,0);
00058     ++real;
00059   }
00060   return *result;
00061 }
00062 
00063 
00064 
00065 TMatrixD & DTSurveyChamber::makeErrors() {
00066   
00067   TMatrixD *result = new TMatrixD(3*getNumberPoints(),3*getNumberPoints());
00068   result->Zero();
00069   int real = 0;
00070   for(std::vector<TMatrixD >::iterator p = pointsError.begin(); p != pointsError.end(); ++p) {
00071     double rmsn = 1.0/((*p)(0,0)*(*p)(0,0));
00072     (*result)(real*3,real*3) = rmsn;
00073     (*result)(real*3+1,real*3+1) = rmsn;
00074     (*result)(real*3+2,real*3+2) = rmsn;
00075     real++;
00076   }
00077   return *result;
00078 }
00079 
00080 
00081 TMatrixD & DTSurveyChamber::makeMatrix() {
00082 
00083   TMatrixD *result = new TMatrixD(3*getNumberPoints(), 6);
00084   result->Zero();
00085   int real = 0;
00086   for(std::vector<TMatrixD >::iterator p = pointsTheoretical.begin(); p != pointsTheoretical.end(); p++) {
00087     (*result)(real*3,0)= 1.0;
00088     (*result)(real*3,3) = (*p)(1,0);
00089     (*result)(real*3,4) = (*p)(2,0);
00090     (*result)(real*3+1,1) = 1.0;
00091     (*result)(real*3+1,3) = -(*p)(0,0);
00092     (*result)(real*3+1,5) = (*p)(2,0);
00093     (*result)(real*3+2,2) = 1.0;
00094     (*result)(real*3+2,4) = -(*p)(0,0);
00095     (*result)(real*3+2,5) = -(*p)(1,0);
00096     real++;
00097   }
00098   return *result;
00099 }
00100 
00101 
00102 std::ostream &operator<<(std::ostream &flujo, const DTSurveyChamber& obj) {
00103 
00104   flujo << obj.getId() << " "
00105         << obj.getDeltaX() << " " << obj.getDeltaXError() << " "
00106         << obj.getDeltaY() << " " << obj.getDeltaYError() << " "
00107         << obj.getDeltaZ() << " " << obj.getDeltaZError() << " "
00108         << obj.getAlpha() << " " << obj.getAlphaError() << " "
00109         << obj.getBeta() << " " << obj.getBetaError() << " "
00110         << obj.getGamma() << " " << obj.getGammaError() << std::endl;
00111   return flujo;
00112 
00113 }