Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:23

0001 ///  \author    : Gero Flucke
0002 ///  date       : October 2010
0003 
0004 #include "Geometry/CommonTopologies/interface/BowedSurfaceDeformation.h"
0005 #include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
0006 
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 // already included via header:
0010 // #include <vector>
0011 
0012 //------------------------------------------------------------------------------
0013 BowedSurfaceDeformation::BowedSurfaceDeformation(const std::vector<double> &pars)
0014     : theSagittaX(!pars.empty() ? pars[0] : 0.),
0015       theSagittaY(pars.size() > 2 ? pars[2] : 0.),
0016       theSagittaXY(pars.size() > 1 ? pars[1] : 0.) {
0017   if (pars.size() != minParameterSize()) {
0018     edm::LogError("BadSetup") << "@SUB=BowedSurfaceDeformation"
0019                               << "Input vector of wrong size " << pars.size() << " instead of " << minParameterSize()
0020                               << ", filled up with zeros!";
0021   }
0022 }
0023 
0024 //------------------------------------------------------------------------------
0025 BowedSurfaceDeformation *BowedSurfaceDeformation::clone() const {
0026   return new BowedSurfaceDeformation(theSagittaX, theSagittaXY, theSagittaY);
0027 }
0028 
0029 //------------------------------------------------------------------------------
0030 int BowedSurfaceDeformation::type() const { return SurfaceDeformationFactory::kBowedSurface; }
0031 
0032 //------------------------------------------------------------------------------
0033 SurfaceDeformation::Local2DVector BowedSurfaceDeformation::positionCorrection(const Local2DPoint &localPos,
0034                                                                               const LocalTrackAngles &localAngles,
0035                                                                               double length,
0036                                                                               double width) const {
0037   // different widthes at high/low y could somehow be treated by theRelWidthLowY
0038   //   if (widthLowY > 0. && widthHighY != widthLowY) {
0039   //     // TEC would always create a warning...
0040   //     edm::LogWarning("UnusableData") << "@SUB=BowedSurfaceDeformation::positionCorrection"
0041   //                    << "Cannot yet deal with different widthes, take "
0042   //                    << widthHighY << " not " << widthLowY;
0043   //   }
0044   //   const double width = widthHighY;
0045 
0046   double uRel = (width ? 2. * localPos.x() / width : 0.);    // relative u (-1 .. +1)
0047   double vRel = (length ? 2. * localPos.y() / length : 0.);  // relative v (-1 .. +1)
0048   // 'range check':
0049   const double cutOff = 1.5;
0050   if (uRel < -cutOff) {
0051     uRel = -cutOff;
0052   } else if (uRel > cutOff) {
0053     uRel = cutOff;
0054   }
0055   if (vRel < -cutOff) {
0056     vRel = -cutOff;
0057   } else if (vRel > cutOff) {
0058     vRel = cutOff;
0059   }
0060 
0061   // apply coefficients to Legendre polynomials
0062   // to get local height relative to 'average'
0063   const double dw =
0064       (uRel * uRel - 1. / 3.) * theSagittaX + uRel * vRel * theSagittaXY + (vRel * vRel - 1. / 3.) * theSagittaY;
0065 
0066   // positive dxdz/dydz and positive dw mean negative shift in x/y:
0067   return Local2DVector(-dw * localAngles);
0068 }
0069 
0070 //------------------------------------------------------------------------------
0071 bool BowedSurfaceDeformation::add(const SurfaceDeformation &other) {
0072   if (other.type() == this->type()) {
0073     const std::vector<double> otherParams(other.parameters());
0074     if (otherParams.size() == parameterSize()) {  // double check!
0075       theSagittaX += otherParams[0];              // bows can simply be added up
0076       theSagittaXY += otherParams[1];
0077       theSagittaY += otherParams[2];
0078 
0079       return true;
0080     }
0081   }
0082 
0083   return false;
0084 }
0085 
0086 //------------------------------------------------------------------------------
0087 std::vector<double> BowedSurfaceDeformation::parameters() const {
0088   std::vector<double> result(parameterSize());
0089   result[0] = theSagittaX;
0090   result[1] = theSagittaXY;
0091   result[2] = theSagittaY;
0092 
0093   return result;
0094 }