CMS 3D CMS Logo

GeometryAligner Class Reference

Class to update a given geometry with a set of alignments. More...

#include <Geometry/TrackingGeometryAligner/interface/GeometryAligner.h>

Inheritance diagram for GeometryAligner:

DetPositioner

List of all members.

Public Member Functions

template<class C>
void applyAlignments (C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)


Detailed Description

Class to update a given geometry with a set of alignments.

Definition at line 28 of file GeometryAligner.h.


Member Function Documentation

template<class C>
void GeometryAligner::applyAlignments ( C *  geometry,
const Alignments alignments,
const AlignmentErrors alignmentErrors,
const AlignTransform globalCoordinates 
) [inline]

Definition at line 41 of file GeometryAligner.h.

References edmNew::copy(), error, Alignments::m_align, AlignmentErrors::m_alignError, AlignTransform::rotation(), DetPositioner::setAlignmentPositionError(), DetPositioner::setGeomDetPosition(), and AlignTransform::translation().

Referenced by TrackerGeometryIntoNtuples::beginJob(), MuonGeometryIntoNtuples::beginJob(), AlignmentMonitorAsAnalyzer::beginJob(), AlignmentProducer::beginOfJob(), TrackerGeometryCompare::createROOTGeometry(), MuonAlignmentInputDB::newAlignableMuon(), TrackerDigiGeometryESModule::produce(), CSCGeometryESModule::produce(), DTGeometryESModule::produce(), MisalignedMuonESProducer::produce(), MisalignedTrackerESProducer::produce(), and AlignmentProducer::startingNewLoop().

00045 {
00046 
00047   edm::LogInfo("Starting") << "Starting to apply alignments";
00048 
00049   // Preliminary checks (or we can't loop!)
00050   if ( alignments->m_align.size() != geometry->theMap.size() )
00051         throw cms::Exception("GeometryMismatch") 
00052           << "Size mismatch between geometry (size=" << geometry->theMap.size() 
00053           << ") and alignments (size=" << alignments->m_align.size() << ")";
00054   if ( alignments->m_align.size() != alignmentErrors->m_alignError.size() )
00055         throw cms::Exception("GeometryMismatch") 
00056           << "Size mismatch between geometry (size=" << geometry->theMap.size() 
00057           << ") and alignment errors (size=" << alignmentErrors->m_alignError.size() << ")";
00058 
00059   const AlignTransform::Translation &globalShift = globalCoordinates.translation();
00060   const AlignTransform::Rotation globalRotation = globalCoordinates.rotation(); // by value!
00061 
00062   // Parallel loop on alignments, alignment errors and geomdets
00063   std::vector<AlignTransform>::const_iterator iAlign = alignments->m_align.begin();
00064   std::vector<AlignTransformError>::const_iterator 
00065         iAlignError = alignmentErrors->m_alignError.begin();
00066   //copy  geometry->theMap to a real map to order it....
00067   std::map<unsigned int, GeomDet*> theMap;
00068   std::copy(geometry->theMap.begin(), geometry->theMap.end(), std::inserter(theMap,theMap.begin()));
00069   for ( std::map<unsigned int, GeomDet*>::const_iterator iPair = theMap.begin(); 
00070                 iPair != theMap.end(); ++iPair, ++iAlign, ++iAlignError )
00071         {
00072           // Check DetIds
00073           if ( (*iPair).first != (*iAlign).rawId() )
00074             throw cms::Exception("GeometryMismatch") 
00075               << "DetId mismatch between geometry (rawId=" << (*iPair).first
00076               << ") and alignments (rawId=" << (*iAlign).rawId();
00077           
00078           if ( (*iPair).first != (*iAlignError).rawId() )
00079             throw cms::Exception("GeometryMismatch") 
00080               << "DetId mismatch between geometry (rawId=" << (*iPair).first
00081               << ") and alignment errors (rawId=" << (*iAlignError).rawId();
00082 
00083           // Apply global correction
00084           CLHEP::Hep3Vector positionHep = globalRotation * CLHEP::Hep3Vector( (*iAlign).translation() ) + globalShift;
00085           CLHEP::HepRotation rotationHep = globalRotation * CLHEP::HepRotation( (*iAlign).rotation() );
00086 
00087           // Define new quantities
00088           Surface::PositionType position( positionHep.x(), positionHep.y(), positionHep.z() );
00089           Surface::RotationType rotation( rotationHep.xx(), rotationHep.xy(), rotationHep.xz(), 
00090                                           rotationHep.yx(), rotationHep.yy(), rotationHep.yz(), 
00091                                           rotationHep.zx(), rotationHep.zy(), rotationHep.zz() );
00092 
00093           // Alignment Position Error
00094           GlobalError error( (*iAlignError).matrix() );
00095           AlignmentPositionError ape( error );
00096 
00097           // Apply new quantities
00098           GeomDet* iGeomDet = (*iPair).second;
00099           DetPositioner::setGeomDetPosition( *iGeomDet, position, rotation );
00100           DetPositioner::setAlignmentPositionError( *iGeomDet, ape );
00101         }
00102 
00103   edm::LogInfo("Done") << "Finished to apply alignments";
00104 }


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:21:23 2009 for CMSSW by  doxygen 1.5.4