Go to the documentation of this file.00001
00008 #include "FWCore/Utilities/interface/Exception.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010
00011 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00012
00013 #include "Alignment/CommonAlignment/interface/Alignable.h"
00014 #include "Alignment/CommonAlignment/interface/AlignableDetOrUnitPtr.h"
00015 #include "Alignment/CommonAlignmentParametrization/interface/KarimakiAlignmentDerivatives.h"
00016 #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h"
00017 #include "CondFormats/Alignment/interface/Definitions.h"
00018 #include "Geometry/CommonTopologies/interface/BowedSurfaceDeformation.h"
00019
00020
00021
00022 #include "Alignment/CommonAlignmentParametrization/interface/BowedSurfaceAlignmentParameters.h"
00023
00024 #include <iostream>
00025
00026 BowedSurfaceAlignmentParameters::BowedSurfaceAlignmentParameters(Alignable *ali) :
00027 AlignmentParameters(ali, AlgebraicVector(N_PARAM), AlgebraicSymMatrix(N_PARAM, 0))
00028 {
00029 }
00030
00031
00032 BowedSurfaceAlignmentParameters
00033 ::BowedSurfaceAlignmentParameters(Alignable *alignable,
00034 const AlgebraicVector ¶meters,
00035 const AlgebraicSymMatrix &covMatrix) :
00036 AlignmentParameters(alignable, parameters, covMatrix)
00037 {
00038 if (parameters.num_row() != N_PARAM) {
00039 throw cms::Exception("BadParameters") << "in BowedSurfaceAlignmentParameters(): "
00040 << parameters.num_row() << " instead of " << N_PARAM
00041 << " parameters.";
00042 }
00043 }
00044
00045
00046 BowedSurfaceAlignmentParameters
00047 ::BowedSurfaceAlignmentParameters(Alignable *alignable,
00048 const AlgebraicVector ¶meters,
00049 const AlgebraicSymMatrix &covMatrix,
00050 const std::vector<bool> &selection) :
00051 AlignmentParameters(alignable, parameters, covMatrix, selection)
00052 {
00053 if (parameters.num_row() != N_PARAM) {
00054 throw cms::Exception("BadParameters") << "in BowedSurfaceAlignmentParameters(): "
00055 << parameters.num_row() << " instead of " << N_PARAM
00056 << " parameters.";
00057 }
00058 }
00059
00060
00061 BowedSurfaceAlignmentParameters*
00062 BowedSurfaceAlignmentParameters::clone(const AlgebraicVector ¶meters,
00063 const AlgebraicSymMatrix &covMatrix) const
00064 {
00065 BowedSurfaceAlignmentParameters* rbap =
00066 new BowedSurfaceAlignmentParameters(this->alignable(), parameters, covMatrix, selector());
00067
00068 if (this->userVariables()) rbap->setUserVariables(this->userVariables()->clone());
00069 rbap->setValid(this->isValid());
00070
00071 return rbap;
00072 }
00073
00074
00075 BowedSurfaceAlignmentParameters*
00076 BowedSurfaceAlignmentParameters::cloneFromSelected(const AlgebraicVector ¶meters,
00077 const AlgebraicSymMatrix &covMatrix) const
00078 {
00079 return this->clone(this->expandVector(parameters, this->selector()),
00080 this->expandSymMatrix(covMatrix, this->selector()));
00081
00082 }
00083
00084
00085 AlgebraicMatrix
00086 BowedSurfaceAlignmentParameters::derivatives(const TrajectoryStateOnSurface &tsos,
00087 const AlignableDetOrUnitPtr &alidet) const
00088 {
00089 const Alignable *ali = this->alignable();
00090
00091 if (ali == alidet) {
00092 const AlignableSurface &surf = ali->surface();
00093 return BowedDerivs()(tsos, surf.width(), surf.length());
00094 } else {
00095
00096
00097
00098
00099
00100
00101 throw cms::Exception("MisMatch")
00102 << "BowedSurfaceAlignmentParameters::derivatives: The hit alignable must match the "
00103 << "aligned one (i.e. bowed surface parameters cannot be used for composed alignables)\n";
00104 return AlgebraicMatrix(N_PARAM, 2);
00105 }
00106
00107 }
00108
00109
00110 align::LocalVector BowedSurfaceAlignmentParameters::translation() const
00111 {
00112
00113 const AlgebraicVector ¶ms = theData->parameters();
00114 return align::LocalVector(params[dx], params[dy], params[dz]);
00115 }
00116
00117
00118
00119 align::EulerAngles BowedSurfaceAlignmentParameters::rotation() const
00120 {
00121 const AlgebraicVector ¶ms = theData->parameters();
00122 const Alignable *alignable = this->alignable();
00123 const AlignableSurface &surface = alignable->surface();
00124
00125 align::EulerAngles eulerAngles(3);
00126
00127
00128 eulerAngles[0] = params[dslopeY] * 2. / surface.length();
00129 eulerAngles[1] = -params[dslopeX] * 2. / surface.width();
00130 const double aScale = BowedDerivs::gammaScale(surface.width(), surface.length());
00131 eulerAngles[2] = params[drotZ] / aScale;
00132
00133 return eulerAngles;
00134 }
00135
00136
00137 void BowedSurfaceAlignmentParameters::apply()
00138 {
00139 Alignable *alignable = this->alignable();
00140 if (!alignable) {
00141 throw cms::Exception("BadParameters")
00142 << "BowedSurfaceAlignmentParameters::apply: parameters without alignable";
00143 }
00144
00145
00146 alignable->move(alignable->surface().toGlobal(this->translation()));
00147
00148
00149 const align::EulerAngles angles(this->rotation());
00150
00151
00152
00153 align::RotationType rot(alignable->surface().toGlobal(align::toMatrix(angles)));
00154 align::rectify(rot);
00155 alignable->rotateInGlobalFrame(rot);
00156
00157 const AlgebraicVector ¶ms = theData->parameters();
00158 const BowedSurfaceDeformation deform(params[dsagittaX], params[dsagittaXY], params[dsagittaY]);
00159
00160
00161
00162
00163 alignable->addSurfaceDeformation(&deform, false);
00164 }
00165
00166
00167 int BowedSurfaceAlignmentParameters::type() const
00168 {
00169 return AlignmentParametersFactory::kBowedSurface;
00170 }
00171
00172
00173 void BowedSurfaceAlignmentParameters::print() const
00174 {
00175 std::cout << "Contents of BowedSurfaceAlignmentParameters:"
00176 << "\nParameters: " << theData->parameters()
00177 << "\nCovariance: " << theData->covariance() << std::endl;
00178 }