Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:28

0001 /* 
0002  *  $Date: 2011/09/05 16:59:07 $
0003  *  $Revision: 1.9 $
0004  */
0005 
0006 #include "Alignment/CommonAlignment/interface/AlignableSurface.h"
0007 #include "Alignment/TrackerAlignment/interface/AlignableStackDet.h"
0008 #include "CondFormats/Alignment/interface/AlignTransformErrorExtended.h"
0009 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0010 #include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h"
0011 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0012 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0013 #include "DataFormats/GeometrySurface/interface/Bounds.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/Utilities/interface/Exception.h"
0016 #include "Geometry/CommonDetUnit/interface/StackGeomDet.h"
0017 #include <cmath>
0018 
0019 AlignableStackDet::AlignableStackDet(const StackGeomDet* stackedDet)
0020     : AlignableDet(stackedDet, true),  // true: adding DetUnits
0021       theLowerDetSurface(stackedDet->lowerDet()->surface()) {
0022   // check order lower/upper
0023   const Alignables units(this->components());
0024   if (units.size() != 2 || stackedDet->lowerDet()->geographicalId() != units[0]->geomDetId() ||
0025       stackedDet->upperDet()->geographicalId() != units[1]->geomDetId()) {
0026     throw cms::Exception("LogicError") << "[AlignableStackDet] "
0027                                        << "Either != 2 components or "
0028                                        << "upper/lower in wrong order for consistifyAlignments.";
0029   }
0030 }
0031 
0032 //__________________________________________________________________________________________________
0033 Alignments* AlignableStackDet::alignments() const {
0034   const_cast<AlignableStackDet*>(this)->consistifyAlignments();
0035   return this->AlignableDet::alignments();
0036 }
0037 
0038 //__________________________________________________________________________________________________
0039 void AlignableStackDet::consistifyAlignments() {
0040   // Now we have all to calculate new position and rotation via PlaneBuilderForGluedDet.
0041   const PositionType oldPos(theSurface.position());  // From old surface for keeping...
0042   const RotationType oldRot(theSurface.rotation());  // ...track of changes.
0043 
0044   // The plane is *not* built in the middle, but on the Lower surface
0045   // see usage in  Geometry/TrackerGeometryBuilder/src/TrackerGeomBuilderFromGeometricDet.cc
0046   theSurface = AlignableSurface(theLowerDetSurface);
0047 
0048   // But do not forget to keep track of movements/rotations:
0049   const GlobalVector movement(theSurface.position().basicVector() - oldPos.basicVector());
0050   // Seems to be correct down to delta angles 4.*1e-8:
0051   const RotationType rotation(oldRot.multiplyInverse(theSurface.rotation()));
0052   this->addDisplacement(movement);
0053   this->addRotation(rotation);
0054 }