CMS 3D CMS Logo

Alignable.cc

Go to the documentation of this file.
00001 
00008 #include "Alignment/CommonAlignment/interface/AlignmentParameters.h"
00009 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00010 
00011 #include "Alignment/CommonAlignment/interface/Alignable.h"
00012 
00013 //__________________________________________________________________________________________________
00014 Alignable::Alignable(align::ID id, const AlignableSurface& surf):
00015   theDetId(id), // FIXME: inconsistent with other ctr., but needed for AlignableNavigator 
00016   theId(id),    // (finally get rid of one of the IDs!)
00017   theSurface(surf),
00018   theAlignmentParameters(0),
00019   theMother(0),
00020   theSurvey(0)
00021 {
00022 }
00023 
00024 //__________________________________________________________________________________________________
00025 Alignable::Alignable(align::ID id, const RotationType& rot):
00026   theDetId(), // FIXME: inconsistent with other ctr., cf. above
00027   theId(id),
00028   theSurface(PositionType(), rot),
00029   theAlignmentParameters(0),
00030   theMother(0),
00031   theSurvey(0)
00032 {
00033 }
00034 
00035 //__________________________________________________________________________________________________
00036 Alignable::~Alignable()
00037 {
00038   delete theAlignmentParameters;
00039   delete theSurvey;
00040 }
00041 
00042 //__________________________________________________________________________________________________
00043 bool Alignable::firstCompsWithParams(Alignables &paramComps) const
00044 {
00045   bool isConsistent = true;
00046   bool hasAliComp = false; // whether there are any (grand-) daughters with parameters
00047   bool first = true;
00048   const Alignables comps(this->components());
00049   for (Alignables::const_iterator iComp = comps.begin(), iCompEnd = comps.end();
00050        iComp != iCompEnd; ++iComp) {
00051     if ((*iComp)->alignmentParameters()) { // component has parameters itself
00052       paramComps.push_back(*iComp);
00053       if (!first && !hasAliComp) isConsistent = false;
00054       hasAliComp = true;
00055     } else {
00056       const unsigned int nCompBefore = paramComps.size();
00057       if (!(*iComp)->firstCompsWithParams(paramComps)) {
00058         isConsistent = false; // problem down in hierarchy
00059       }
00060       if (paramComps.size() != nCompBefore) {
00061         if (!first && !hasAliComp) isConsistent = false;
00062         hasAliComp = true;
00063       } else if (hasAliComp) { // no components with params, but previous component did have comps.
00064         isConsistent = false;
00065       }
00066     }
00067     first = false;
00068   }
00069 
00070   return isConsistent;
00071 }
00072 
00073 //__________________________________________________________________________________________________
00074 void Alignable::setAlignmentParameters( AlignmentParameters* dap )
00075 {
00076 
00077   delete theAlignmentParameters;
00078   theAlignmentParameters = dap;
00079 
00080 }
00081 
00082 
00083 //__________________________________________________________________________________________________
00084 void Alignable::rotateInLocalFrame( const RotationType& rotation)
00085 {
00086 
00087   // This is done by simply transforming the rotation from
00088   // the local system O to the global one  O^-1 * Rot * O
00089   // and then applying the global rotation  O * Rot
00090 
00091   rotateInGlobalFrame( surface().toGlobal(rotation) );
00092 
00093 }
00094 
00095 
00096 //__________________________________________________________________________________________________
00097 void Alignable::rotateAroundGlobalAxis( const GlobalVector& axis, Scalar radians )
00098 {
00099 
00100   rotateInGlobalFrame( RotationType(axis.basicVector(),radians) );
00101 
00102 }
00103 
00104 
00105 //__________________________________________________________________________________________________
00106 void Alignable::rotateAroundLocalAxis( const LocalVector& axis, Scalar radians )
00107 {
00108 
00109   rotateInLocalFrame(RotationType(axis.basicVector(), radians));
00110 
00111 }
00112 
00113 
00114 //__________________________________________________________________________________________________
00115 void Alignable::rotateAroundGlobalX( Scalar radians )
00116 {
00117 
00118   RotationType rot( 1.,  0.,            0.,
00119                     0.,  std::cos(radians),  std::sin(radians),
00120                     0., -std::sin(radians),  std::cos(radians) );
00121 
00122   rotateInGlobalFrame(rot);
00123 
00124 }
00125 
00126 
00127 //__________________________________________________________________________________________________
00128 void Alignable::rotateAroundLocalX( Scalar radians )
00129 {
00130  
00131   RotationType rot( 1.,  0.,            0.,
00132                     0.,  std::cos(radians),  std::sin(radians),
00133                     0., -std::sin(radians),  std::cos(radians) );
00134 
00135   rotateInLocalFrame(rot);
00136 
00137 }
00138 
00139 
00140 //__________________________________________________________________________________________________
00141 void Alignable::rotateAroundGlobalY( Scalar radians )
00142 {
00143 
00144   RotationType rot( std::cos(radians),  0., -std::sin(radians), 
00145                     0.,            1.,  0.,
00146                     std::sin(radians),  0.,  std::cos(radians) );
00147 
00148   rotateInGlobalFrame(rot);
00149   
00150 }
00151 
00152 
00153 //__________________________________________________________________________________________________
00154 void Alignable::rotateAroundLocalY( Scalar radians )
00155 {
00156 
00157   RotationType rot( std::cos(radians),  0., -std::sin(radians), 
00158                     0.,            1.,  0.,
00159                     std::sin(radians),  0.,  std::cos(radians) );
00160   
00161   rotateInLocalFrame(rot);
00162 
00163 }
00164 
00165 
00166 //__________________________________________________________________________________________________
00167 void Alignable::rotateAroundGlobalZ( Scalar radians )
00168 {
00169 
00170   RotationType rot(  std::cos(radians),  std::sin(radians),  0.,
00171                     -std::sin(radians),  std::cos(radians),  0.,
00172                      0.,            0.,            1. );
00173 
00174   rotateInGlobalFrame(rot);
00175   
00176 }
00177 
00178 
00179 //__________________________________________________________________________________________________
00180 void Alignable::rotateAroundLocalZ( Scalar radians)
00181 {
00182 
00183   RotationType rot(  std::cos(radians),  std::sin(radians), 0. ,
00184                     -std::sin(radians),  std::cos(radians), 0. ,
00185                      0.,            0.,           1. );
00186   
00187   rotateInLocalFrame(rot);
00188 
00189 }
00190 
00191 
00192 //__________________________________________________________________________________________________
00193 void Alignable::addDisplacement( const GlobalVector& displacement )
00194 {
00195 
00196   theDisplacement += displacement;
00197 
00198 }
00199 
00200 //__________________________________________________________________________________________________
00201 void Alignable::addRotation( const RotationType& rotation ) 
00202 {
00203 
00204   theRotation *= rotation;
00205 
00206 }
00207 
00208 
00209 //__________________________________________________________________________________________________
00210 void Alignable::setSurvey( const SurveyDet* survey )
00211 {
00212 
00213   delete theSurvey;
00214   theSurvey = survey;
00215 
00216 }

Generated on Tue Jun 9 17:23:45 2009 for CMSSW by  doxygen 1.5.4