CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Alignment/SurveyAnalysis/interface/SurveyPxbImageLocalFit.h

Go to the documentation of this file.
00001 #ifndef GUARD_surveypxbimagelocalfit_h
00002 #define GUARD_surveypxbimagelocalfit_h
00003 
00004 #include <sstream>
00005 #include <vector>
00006 #include <utility>
00007 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00008 #include "Alignment/SurveyAnalysis/interface/SurveyPxbImage.h"
00009 #include "Math/SMatrix.h"
00010 #include "Math/SVector.h"
00011 #include <iostream>
00012 
00014 class SurveyPxbImageLocalFit : public SurveyPxbImage
00015 {
00016 public:
00017         typedef std::vector<value_t> localpars_t;
00018         typedef std::vector<coord_t> fidpoint_t;
00019         typedef unsigned int count_t;
00020         static const count_t nGlD = 3; // no of global derivs
00021         static const count_t nLcD = 4; // no of local derivs
00022         static const count_t nMsrmts = 8; // no of measurements per image
00023         static const count_t nLcPars = 4; // no of local parameters
00024         static const count_t nFidpoints = 4; // no of fiducial points
00025         // Typedefs for pede
00026         typedef int pede_label_t;
00027         typedef float pede_deriv_t;
00028 
00029         // Constructors
00030         SurveyPxbImageLocalFit(): 
00031                 SurveyPxbImage(), a_(nLcPars,0), fidpoints_(nFidpoints), fitValidFlag_(false), derivsValidFlag_(false)
00032         {
00033                 initFidPoints();
00034         };
00035 
00037         SurveyPxbImageLocalFit(std::istringstream &iss): 
00038             SurveyPxbImage(iss), a_(nLcPars,0), fidpoints_(nFidpoints), fitValidFlag_(false), derivsValidFlag_(false)
00039         {
00040                 initFidPoints();
00041         };
00042 
00044         void doFit(const fidpoint_t &fidpointvec);
00045         void doFit(const fidpoint_t &fidpointvec, const pede_label_t &label1, const pede_label_t &label2);
00046         void doFit(value_t x1, value_t y1, value_t g1, value_t x2, value_t y2, value_t g2);
00047 
00049         bool isFitValid() { return fitValidFlag_; };
00050 
00052         localpars_t getLocalParameters();
00053 
00055         value_t getChi2();
00056 
00057         pede_label_t getLocalDerivsSize()                      {return nLcD; };
00058         pede_label_t getGlobalDerivsSize()                     {return nGlD; };
00059         const pede_deriv_t* getLocalDerivsPtr(count_t i)       {return localDerivsMatrix_.Array()+i*nLcD; };
00060         const pede_deriv_t* getGlobalDerivsPtr(count_t i)      {return globalDerivsMatrix_.Array()+i*nGlD;};
00061         const pede_label_t* getGlobalDerivsLabelPtr(count_t i) {return i<4 ? &labelVec1_[0] : &labelVec2_[0];};
00062         pede_deriv_t getResiduum(count_t i) { return (pede_deriv_t) r(i); };
00063         pede_deriv_t getSigma(count_t i) { return i%2 ? sigma_x_ : sigma_y_ ; };
00064 
00065         void setLocalDerivsToZero(count_t i);
00066         void setGlobalDerivsToZero(count_t i);
00067 
00068 private:
00070         localpars_t a_;
00071         
00073         ROOT::Math::SVector<value_t, nMsrmts> r;
00074 
00076         //std::vector<localDerivs_t> globalDerivsVec_;
00077         ROOT::Math::SMatrix<pede_deriv_t,nMsrmts,nGlD> globalDerivsMatrix_;
00078 
00080         //std::vector<globalDerivs_t> localDerivsVec_;
00081         ROOT::Math::SMatrix<pede_deriv_t,nMsrmts,nLcD> localDerivsMatrix_;
00082 
00084         std::vector<pede_label_t> labelVec1_, labelVec2_;
00085 
00087         std::vector<coord_t> fidpoints_;
00088 
00090         value_t chi2_;
00091 
00093         bool fitValidFlag_;
00094 
00096         bool derivsValidFlag_;
00097 
00099         void initFidPoints()
00100         {
00101                 fidpoints_[0] = coord_t(-0.91,-3.30);
00102                 fidpoints_[1] = coord_t(+0.91,-3.30);
00103                 fidpoints_[2] = coord_t(-0.91,+3.30);
00104                 fidpoints_[3] = coord_t(+0.91,+3.30);
00105         }
00106 
00108         value_t dist(coord_t p1, coord_t p2)
00109         {
00110             value_t dx = p1.x()-p2.x();
00111             value_t dy = p1.y()-p2.y();
00112             return sqrt(dx*dx+dy*dy);
00113         }
00114         
00115 };
00116 
00117 #endif
00118