CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Geometry/CommonTopologies/src/BowedSurfaceDeformation.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "Geometry/CommonTopologies/interface/BowedSurfaceDeformation.h"
00008 #include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 // already included via header:
00013 // #include <vector>
00014 
00015 //------------------------------------------------------------------------------
00016 BowedSurfaceDeformation::BowedSurfaceDeformation(const std::vector<double> &pars)
00017   : theSagittaX (pars.size() > 0 ? pars[0] : 0.),
00018     theSagittaY (pars.size() > 2 ? pars[2] : 0.),
00019     theSagittaXY(pars.size() > 1 ? pars[1] : 0.)
00020 {
00021   if (pars.size() != minParameterSize()) {
00022     edm::LogError("BadSetup") << "@SUB=BowedSurfaceDeformation"
00023                               << "Input vector of wrong size " << pars.size()
00024                               << " instead of " << minParameterSize() << ", filled up with zeros!";
00025   }
00026 }
00027 
00028 //------------------------------------------------------------------------------
00029 BowedSurfaceDeformation* BowedSurfaceDeformation::clone() const
00030 {
00031   return new BowedSurfaceDeformation(theSagittaX, theSagittaXY, theSagittaY);
00032 }
00033 
00034 //------------------------------------------------------------------------------
00035 int BowedSurfaceDeformation::type() const
00036 {
00037   return SurfaceDeformationFactory::kBowedSurface;
00038 }
00039 
00040 //------------------------------------------------------------------------------
00041 SurfaceDeformation::Local2DVector 
00042 BowedSurfaceDeformation::positionCorrection(const Local2DPoint &localPos,
00043                                             const LocalTrackAngles &localAngles,
00044                                             double length, double width) const
00045 {
00046 
00047 // different widthes at high/low y could somehow be treated by theRelWidthLowY
00048 //   if (widthLowY > 0. && widthHighY != widthLowY) {
00049 //     // TEC would always create a warning...
00050 //     edm::LogWarning("UnusableData") << "@SUB=BowedSurfaceDeformation::positionCorrection"
00051 //                                  << "Cannot yet deal with different widthes, take "
00052 //                                  << widthHighY << " not " << widthLowY;
00053 //   }
00054 //   const double width = widthHighY;
00055   
00056   double uRel = (width  ? 2. * localPos.x() / width  : 0.);  // relative u (-1 .. +1)
00057   double vRel = (length ? 2. * localPos.y() / length : 0.);  // relative v (-1 .. +1)
00058   // 'range check':
00059   const double cutOff = 1.5;
00060   if (uRel < -cutOff) { uRel = -cutOff; } else if (uRel > cutOff) { uRel = cutOff; }
00061   if (vRel < -cutOff) { vRel = -cutOff; } else if (vRel > cutOff) { vRel = cutOff; }
00062   
00063   // apply coefficients to Legendre polynomials
00064   // to get local height relative to 'average'
00065   const double dw 
00066     = (uRel * uRel - 1./3.) * theSagittaX
00067     +  uRel * vRel          * theSagittaXY
00068     + (vRel * vRel - 1./3.) * theSagittaY;
00069 
00070   // positive dxdz/dydz and positive dw mean negative shift in x/y: 
00071   return Local2DVector(-dw * localAngles);
00072 }
00073 
00074 //------------------------------------------------------------------------------
00075 bool BowedSurfaceDeformation::add(const SurfaceDeformation &other)
00076 {
00077   if (other.type() == this->type()) {
00078     const std::vector<double> otherParams(other.parameters());
00079     if (otherParams.size() == 3) { // double check!
00080       theSagittaX  += otherParams[0]; // bows can simply be added up
00081       theSagittaXY += otherParams[1];
00082       theSagittaY  += otherParams[2];
00083 
00084       return true;
00085     }
00086   }
00087 
00088   return false;
00089 }
00090   
00091 //------------------------------------------------------------------------------
00092 std::vector<double> BowedSurfaceDeformation::parameters() const
00093 {
00094   std::vector<double> result(3);
00095   result[0] = theSagittaX;
00096   result[1] = theSagittaXY;
00097   result[2] = theSagittaY;
00098 
00099   return result;
00100 }