CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/Geometry/CommonTopologies/src/TwoBowedSurfacesDeformation.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "Geometry/CommonTopologies/interface/TwoBowedSurfacesDeformation.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 TwoBowedSurfacesDeformation::TwoBowedSurfacesDeformation(const std::vector<double> &pars)
00017 {
00018   if (pars.size() != parameterSize()) {
00019     edm::LogError("BadSetup") << "@SUB=TwoBowedSurfacesDeformation"
00020                               << "Input vector of wrong size " << pars.size()
00021                               << " instead of " << parameterSize() << ", add zeros to fill up!";
00022   }
00023   for (unsigned int i=0; i!=std::min((unsigned int)(pars.size()), parameterSize()); ++i )  theParameters[i]=pars[i];
00024   for (unsigned int i=pars.size(); i!=parameterSize(); ++i )  theParameters[i]=0;
00025   
00026 }
00027 
00028 //------------------------------------------------------------------------------
00029 TwoBowedSurfacesDeformation* TwoBowedSurfacesDeformation::clone() const
00030 {
00031   return new TwoBowedSurfacesDeformation(*this);
00032 }
00033 
00034 //------------------------------------------------------------------------------
00035 int TwoBowedSurfacesDeformation::type() const
00036 {
00037   return SurfaceDeformationFactory::kTwoBowedSurfaces;
00038 }
00039 
00040 //------------------------------------------------------------------------------
00041 SurfaceDeformation::Local2DVector 
00042 TwoBowedSurfacesDeformation::positionCorrection(const Local2DPoint &localPos,
00043                                                 const LocalTrackAngles &localAngles,
00044                                                 double length, double width) const
00045 {
00046   const double ySplit = theParameters[k_ySplit()];
00047 
00048 // treatment of different widthes at high/low y could be done by theRelWidthLowY or so
00049 //   if (widthLowY > 0. && widthHighY != widthLowY) {
00050 //     std::cout << "SurfaceDeformation::positionCorrection2Bowed: Cannot yet deal "
00051 //            << " with different widthes, take " << widthHighY << " not " << widthLowY
00052 //            << std::endl;
00053 //   }
00054 //   const double width = widthHighY;
00055   
00056   // Some signs depend on whether we are in surface part below or above ySplit:
00057   const double sign = (localPos.y() < ySplit ? +1. : -1.); 
00058   const double yMiddle = ySplit * 0.5 - sign * length * .25;
00059   // 'calibrate' y length and transform y to be w.r.t. surface middle
00060   const double myY = localPos.y() - yMiddle;
00061   const double myLength = length * 0.5 + sign * ySplit;
00062   
00063   double uRel = 2. * localPos.x() / width;  // relative u (-1 .. +1)
00064   double vRel = 2. * myY / myLength;        // relative v (-1 .. +1)
00065   // 'range check':
00066   const double cutOff = 1.5;
00067   if (uRel < -cutOff) { uRel = -cutOff; } else if (uRel > cutOff) { uRel = cutOff; }
00068   if (vRel < -cutOff) { vRel = -cutOff; } else if (vRel > cutOff) { vRel = cutOff; }
00069   
00070   auto pars = theParameters;
00071   // 1st, get dw effect depending 
00072   // - on the surface sagittas (Legendre polynomials),
00073   //   see BowedSurfaceAlignmentDerivatives::operator()(..)
00074   // - relative dw
00075   // - surface specific dalpha (note that this shifts surface specific dw)
00076   // - surface specific dbeta
00077   const double dw 
00078     = (uRel * uRel - 1./3.) * (pars[0] + sign * pars[9])  // sagittaX
00079     +  uRel * vRel          * (pars[1] + sign * pars[10]) // sagittaXY
00080     + (vRel * vRel - 1./3.) * (pars[2] + sign * pars[11]) // sagittaY
00081     + sign * pars[5]                 // different dw
00082     + myY          * sign * pars[6]  // different dalpha
00083     - localPos.x() * sign * pars[7]; // different dbeta
00084   // 2nd, translate the dw effect to shifts in x and y
00085   // Positive dxdz/dydz and positive dw mean negative shift in x/y: 
00086   Local2DVector::ScalarType x = -dw * localAngles.dxdz();
00087   Local2DVector::ScalarType y = -dw * localAngles.dydz();
00088   // 3rd, treat in-plane differences depending on surface from xy-shifts... 
00089   x += (sign * pars[3]); // different du
00090   y += (sign * pars[4]); // different dv
00091   //     ...and gamma-rotation
00092   x -= myY          * (sign * pars[8]); // different dgamma for u
00093   y += localPos.x() * (sign * pars[8]); // different dgamma for v
00094 
00095   return Local2DVector(x, y);
00096 }
00097 
00098 //------------------------------------------------------------------------------
00099 bool TwoBowedSurfacesDeformation::add(const SurfaceDeformation &other)
00100 {
00101   if (this->type() == other.type()) {
00102     const std::vector<double> otherParameters(other.parameters());
00103     if (otherParameters.size() ==parameterSize() ) {
00104       if (theParameters[k_ySplit()] == otherParameters[k_ySplit()]) {
00105         for (unsigned int i = 0; i != parameterSize()-1; ++i) {// -1 for ySplit
00106           // mean bows, delta shifts, delta angles and delta bows can simply be added up
00107           theParameters[i] += otherParameters[i];
00108         }
00109         return true;
00110       } else { // ySplit values are different!
00111         LogDebug("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
00112                               << "Different ySplit: this " << theParameters[k_ySplit()]
00113                               << ", to add " << otherParameters[k_ySplit()];
00114       }
00115     } // same size
00116   } // same type
00117 
00118   return false;
00119 }
00120   
00121 //------------------------------------------------------------------------------
00122 std::vector<double> TwoBowedSurfacesDeformation::parameters() const
00123 {
00124   return std::vector<double>(theParameters,theParameters+parameterSize());
00125 }