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 theSagittaXY(pars.size() > 1 ? pars[1] : 0.), 00019 theSagittaY (pars.size() > 2 ? pars[2] : 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 const Local2DVector::ScalarType x = -dw * localAngles.dxdz(); 00072 const Local2DVector::ScalarType y = -dw * localAngles.dydz(); 00073 00074 return Local2DVector(x, y); 00075 } 00076 00077 //------------------------------------------------------------------------------ 00078 bool BowedSurfaceDeformation::add(const SurfaceDeformation &other) 00079 { 00080 if (other.type() == this->type()) { 00081 const std::vector<double> otherParams(other.parameters()); 00082 if (otherParams.size() == 3) { // double check! 00083 theSagittaX += otherParams[0]; // bows can simply be added up 00084 theSagittaXY += otherParams[1]; 00085 theSagittaY += otherParams[2]; 00086 00087 return true; 00088 } 00089 } 00090 00091 return false; 00092 } 00093 00094 //------------------------------------------------------------------------------ 00095 std::vector<double> BowedSurfaceDeformation::parameters() const 00096 { 00097 std::vector<double> result(3); 00098 result[0] = theSagittaX; 00099 result[1] = theSagittaXY; 00100 result[2] = theSagittaY; 00101 00102 return result; 00103 }