#include <Alignment/MuonAlignment/interface/MuonAlignment.h>
Definition at line 21 of file MuonAlignment.h.
MuonAlignment::MuonAlignment | ( | const edm::EventSetup & | iSetup | ) |
Definition at line 45 of file MuonAlignment.cc.
References align::AlignableMuon, edm::EventSetup::get(), init(), theAlignableMuon, and theAlignableNavigator.
00046 { 00047 init(); 00048 00049 edm::ESHandle<DTGeometry> dtGeometry; 00050 edm::ESHandle<CSCGeometry> cscGeometry; 00051 iSetup.get<MuonGeometryRecord>().get( dtGeometry ); 00052 iSetup.get<MuonGeometryRecord>().get( cscGeometry ); 00053 00054 theAlignableMuon = new AlignableMuon( &(*dtGeometry) , &(*cscGeometry) ); 00055 theAlignableNavigator = new AlignableNavigator( theAlignableMuon ); 00056 }
MuonAlignment::MuonAlignment | ( | const edm::EventSetup & | iSetup, | |
const MuonAlignmentInputMethod & | input | |||
) |
Definition at line 58 of file MuonAlignment.cc.
References init(), MuonAlignmentInputMethod::newAlignableMuon(), theAlignableMuon, and theAlignableNavigator.
00059 { 00060 init(); 00061 00062 theAlignableMuon = input.newAlignableMuon( iSetup ); 00063 theAlignableNavigator = new AlignableNavigator( theAlignableMuon ); 00064 }
MuonAlignment::~MuonAlignment | ( | ) | [inline] |
Definition at line 29 of file MuonAlignment.h.
References theAlignableMuon, and theAlignableNavigator.
00029 { delete theAlignableMuon; delete theAlignableNavigator; }
void MuonAlignment::copyAlignmentToSurvey | ( | double | shiftErr, | |
double | angleErr | |||
) |
Definition at line 139 of file MuonAlignment.cc.
References edmNew::copy(), AlignableMuon::cscAlignmentErrors(), AlignableMuon::CSCEndcaps(), AlignableMuon::dtAlignmentErrors(), AlignableMuon::DTBarrel(), fillGapsInSurvey(), i, j, AlignmentErrors::m_alignError, recursiveMap(), Alignable::setSurvey(), Alignable::surface(), and theAlignableMuon.
Referenced by MuonGeometryDBConverter::analyze().
00139 { 00140 std::map<align::ID, Alignable*> alignableMap; 00141 recursiveMap(theAlignableMuon->DTBarrel(), alignableMap); 00142 recursiveMap(theAlignableMuon->CSCEndcaps(), alignableMap); 00143 00144 // Set the survey error to the alignable error, expanding the matrix as needed 00145 AlignmentErrors* dtAlignmentErrors = theAlignableMuon->dtAlignmentErrors(); 00146 AlignmentErrors* cscAlignmentErrors = theAlignableMuon->cscAlignmentErrors(); 00147 std::vector<AlignTransformError> alignmentErrors; 00148 std::copy(dtAlignmentErrors->m_alignError.begin(), dtAlignmentErrors->m_alignError.end(), std::back_inserter(alignmentErrors)); 00149 std::copy(cscAlignmentErrors->m_alignError.begin(), cscAlignmentErrors->m_alignError.end(), std::back_inserter(alignmentErrors)); 00150 00151 for (std::vector<AlignTransformError>::const_iterator alignmentError = alignmentErrors.begin(); 00152 alignmentError != alignmentErrors.end(); 00153 ++alignmentError) { 00154 align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity(); 00155 CLHEP::HepSymMatrix matrix3x3 = alignmentError->matrix(); 00156 00157 for (int i = 0; i < 3; i++) { 00158 for (int j = 0; j < 3; j++) { 00159 matrix6x6(i, j) = matrix3x3(i+1, j+1); 00160 } 00161 } 00162 matrix6x6(3,3) = angleErr; 00163 matrix6x6(4,4) = angleErr; 00164 matrix6x6(5,5) = angleErr; 00165 00166 Alignable *alignable = alignableMap[alignmentError->rawId()]; 00167 alignable->setSurvey(new SurveyDet(alignable->surface(), matrix6x6)); 00168 } 00169 00170 fillGapsInSurvey(shiftErr, angleErr); 00171 }
void MuonAlignment::copySurveyToAlignment | ( | ) |
Definition at line 233 of file MuonAlignment.cc.
References recursiveCopySurveyToAlignment(), and theAlignableMuon.
Referenced by MuonGeometryDBConverter::analyze().
00233 { 00234 recursiveCopySurveyToAlignment(theAlignableMuon); 00235 }
void MuonAlignment::fillGapsInSurvey | ( | double | shiftErr, | |
double | angleErr | |||
) |
Definition at line 176 of file MuonAlignment.cc.
References AlignableMuon::CSCEndcaps(), AlignableMuon::DTBarrel(), iter, python::multivaluedict::map(), NULL, recursiveStructureMap(), and theAlignableMuon.
Referenced by MuonGeometryDBConverter::analyze(), and copyAlignmentToSurvey().
00176 { 00177 // get all the ones we missed 00178 std::map<std::pair<align::StructureType, align::ID>, Alignable*> alignableStructureMap; 00179 recursiveStructureMap(theAlignableMuon->DTBarrel(), alignableStructureMap); 00180 recursiveStructureMap(theAlignableMuon->CSCEndcaps(), alignableStructureMap); 00181 00182 for (std::map<std::pair<align::StructureType, align::ID>, Alignable*>::const_iterator iter = alignableStructureMap.begin(); 00183 iter != alignableStructureMap.end(); 00184 ++iter) { 00185 if (iter->second->survey() == NULL) { 00186 align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity(); 00187 matrix6x6(0,0) = shiftErr; 00188 matrix6x6(1,1) = shiftErr; 00189 matrix6x6(2,2) = shiftErr; 00190 matrix6x6(3,3) = angleErr; 00191 matrix6x6(4,4) = angleErr; 00192 matrix6x6(5,5) = angleErr; 00193 iter->second->setSurvey(new SurveyDet(iter->second->surface(), matrix6x6)); 00194 } 00195 } 00196 }
AlignableMuon* MuonAlignment::getAlignableMuon | ( | ) | [inline] |
Definition at line 31 of file MuonAlignment.h.
References theAlignableMuon.
Referenced by MuonGeometryDBConverter::analyze().
00031 { return theAlignableMuon; }
AlignableNavigator* MuonAlignment::getAlignableNavigator | ( | ) | [inline] |
Definition at line 33 of file MuonAlignment.h.
References theAlignableNavigator.
00033 { return theAlignableNavigator; }
void MuonAlignment::init | ( | ) | [private] |
Definition at line 31 of file MuonAlignment.cc.
References NULL, theAlignableMuon, theAlignableNavigator, theCSCAlignRecordName, theCSCErrorRecordName, theCSCSurveyErrorRecordName, theCSCSurveyRecordName, theDTAlignRecordName, theDTErrorRecordName, theDTSurveyErrorRecordName, and theDTSurveyRecordName.
Referenced by MuonAlignment().
00032 { 00033 theDTAlignRecordName = "DTAlignmentRcd"; 00034 theDTErrorRecordName = "DTAlignmentErrorRcd"; 00035 theCSCAlignRecordName = "CSCAlignmentRcd"; 00036 theCSCErrorRecordName = "CSCAlignmentErrorRcd"; 00037 theDTSurveyRecordName = "DTSurveyRcd"; 00038 theDTSurveyErrorRecordName = "DTSurveyErrorRcd"; 00039 theCSCSurveyRecordName = "CSCSurveyRcd"; 00040 theCSCSurveyErrorRecordName = "CSCSurveyErrorRcd"; 00041 theAlignableMuon = NULL; 00042 theAlignableNavigator = NULL; 00043 }
void MuonAlignment::moveAlignableGlobalCoord | ( | DetId & | detid, | |
std::vector< float > & | displacements, | |||
std::vector< float > & | rotations | |||
) |
Definition at line 89 of file MuonAlignment.cc.
References AlignableNavigator::alignableFromDetId(), Alignable::move(), Alignable::rotateAroundGlobalX(), Alignable::rotateAroundGlobalY(), Alignable::rotateAroundGlobalZ(), and theAlignableNavigator.
00089 { 00090 00091 // Displace and rotate DT an Alignable associated to a GeomDet or GeomDetUnit 00092 Alignable* theAlignable = theAlignableNavigator->alignableFromDetId( detid ); 00093 00094 // Convert std::vector to GlobalVector 00095 GlobalVector gvector( displacements.at(0), displacements.at(1), displacements.at(2)); 00096 00097 // global displacement of the chamber 00098 theAlignable->move( gvector ); 00099 00100 // local rotation of the chamber 00101 theAlignable->rotateAroundGlobalX( rotations.at(0) ); // Global X axis rotation 00102 theAlignable->rotateAroundGlobalY( rotations.at(1) ); // Global Y axis rotation 00103 theAlignable->rotateAroundGlobalZ( rotations.at(2) ); // Global Z axis rotation 00104 00105 }
void MuonAlignment::moveAlignableLocalCoord | ( | DetId & | detid, | |
std::vector< float > & | displacements, | |||
std::vector< float > & | rotations | |||
) |
Definition at line 68 of file MuonAlignment.cc.
References AlignableNavigator::alignableFromDetId(), Alignable::move(), Alignable::rotateAroundLocalX(), Alignable::rotateAroundLocalY(), Alignable::rotateAroundLocalZ(), Alignable::surface(), and theAlignableNavigator.
00068 { 00069 00070 // Displace and rotate DT an Alignable associated to a GeomDet or GeomDetUnit 00071 Alignable* theAlignable = theAlignableNavigator->alignableFromDetId( detid ); 00072 00073 // Convert local to global diplacements 00074 LocalVector lvector( displacements.at(0), displacements.at(1), displacements.at(2)); 00075 GlobalVector gvector = ( theAlignable->surface()).toGlobal( lvector ); 00076 00077 // global displacement of the chamber 00078 theAlignable->move( gvector ); 00079 00080 // local rotation of the chamber 00081 theAlignable->rotateAroundLocalX( rotations.at(0) ); // Local X axis rotation 00082 theAlignable->rotateAroundLocalY( rotations.at(1) ); // Local Y axis rotation 00083 theAlignable->rotateAroundLocalZ( rotations.at(2) ); // Local Z axis rotation 00084 00085 }
Definition at line 200 of file MuonAlignment.cc.
References Alignable::components(), SurveyDet::errors(), Alignable::globalPosition(), Alignable::globalRotation(), i, j, Alignable::move(), NULL, SurveyDet::position(), rot, Alignable::rotateInGlobalFrame(), SurveyDet::rotation(), Alignable::setAlignmentPositionError(), Alignable::survey(), TkRotation< T >::transposed(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by copySurveyToAlignment().
00200 { 00201 if (alignable->survey() != NULL) { 00202 const SurveyDet *survey = alignable->survey(); 00203 00204 align::PositionType pos = survey->position(); 00205 align::RotationType rot = survey->rotation(); 00206 00207 align::PositionType oldpos = alignable->globalPosition(); 00208 align::RotationType oldrot = alignable->globalRotation(); 00209 alignable->move(GlobalVector(-oldpos.x(), -oldpos.y(), -oldpos.z())); 00210 alignable->rotateInGlobalFrame(oldrot.transposed()); 00211 alignable->rotateInGlobalFrame(rot); 00212 alignable->move(GlobalVector(pos.x(), pos.y(), pos.z())); 00213 00214 align::ErrorMatrix matrix6x6 = survey->errors(); // start from 0,0 00215 CLHEP::HepSymMatrix matrix3x3(3); // start from 1,1 00216 for (int i = 0; i < 3; i++) { 00217 for (int j = 0; j < 3; j++) { 00218 matrix3x3(i+1, j+1) = matrix6x6(i, j); 00219 } 00220 } 00221 00222 // this sets APEs at this level and all lower levels 00223 alignable->setAlignmentPositionError(AlignmentPositionError(GlobalError(matrix3x3))); 00224 } 00225 00226 // do lower levels afterward to thwart the cumulative setting of APEs 00227 std::vector<Alignable*> components = alignable->components(); 00228 for (std::vector<Alignable*>::const_iterator comp = components.begin(); comp != components.end(); ++comp) { 00229 recursiveCopySurveyToAlignment(*comp); 00230 } 00231 }
void MuonAlignment::recursiveList | ( | std::vector< Alignable * > | alignables, | |
std::vector< Alignable * > & | theList | |||
) |
Definition at line 109 of file MuonAlignment.cc.
Referenced by saveCSCSurveyToDB(), and saveDTSurveyToDB().
00109 { 00110 for (std::vector<Alignable*>::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) { 00111 recursiveList((*alignable)->components(), theList); 00112 theList.push_back(*alignable); 00113 } 00114 }
void MuonAlignment::recursiveMap | ( | std::vector< Alignable * > | alignables, | |
std::map< align::ID, Alignable * > & | theMap | |||
) |
Definition at line 118 of file MuonAlignment.cc.
Referenced by copyAlignmentToSurvey().
00118 { 00119 for (std::vector<Alignable*>::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) { 00120 unsigned int rawId = (*alignable)->geomDetId().rawId(); 00121 if (rawId != 0) { 00122 theMap[rawId] = *alignable; 00123 } 00124 recursiveMap((*alignable)->components(), theMap); 00125 } 00126 }
void MuonAlignment::recursiveStructureMap | ( | std::vector< Alignable * > | alignables, | |
std::map< std::pair< align::StructureType, align::ID >, Alignable * > & | theMap | |||
) |
Definition at line 130 of file MuonAlignment.cc.
Referenced by fillGapsInSurvey().
00130 { 00131 for (std::vector<Alignable*>::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) { 00132 theMap[std::pair<align::StructureType, align::ID>((*alignable)->alignableObjectId(), (*alignable)->id())] = *alignable; 00133 recursiveStructureMap((*alignable)->components(), theMap); 00134 } 00135 }
Definition at line 277 of file MuonAlignment.cc.
References AlignableMuon::CSCEndcaps(), error, edm::Service< T >::isAvailable(), Alignments::m_align, SurveyErrors::m_surveyErrors, recursiveList(), rot, theAlignableMuon, theCSCSurveyErrorRecordName, theCSCSurveyRecordName, value, PV3DBase< T, PVType, FrameType >::x(), TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), PV3DBase< T, PVType, FrameType >::y(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), PV3DBase< T, PVType, FrameType >::z(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().
Referenced by saveSurveyToDB().
00277 { 00278 // Call service 00279 edm::Service<cond::service::PoolDBOutputService> poolDbService; 00280 if( !poolDbService.isAvailable() ) // Die if not available 00281 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; 00282 00283 // Get alignments and errors 00284 Alignments *cscAlignments = new Alignments(); 00285 SurveyErrors *cscSurveyErrors = new SurveyErrors(); 00286 00287 std::vector<Alignable*> alignableList; 00288 recursiveList(theAlignableMuon->CSCEndcaps(), alignableList); 00289 00290 for (std::vector<Alignable*>::const_iterator alignable = alignableList.begin(); alignable != alignableList.end(); ++alignable) { 00291 const align::PositionType &pos = (*alignable)->survey()->position(); 00292 const align::RotationType &rot = (*alignable)->survey()->rotation(); 00293 00294 AlignTransform value(CLHEP::Hep3Vector(pos.x(), pos.y(), pos.z()), 00295 CLHEP::HepRotation(CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), 00296 rot.yx(), rot.yy(), rot.yz(), 00297 rot.zx(), rot.zy(), rot.zz())), 00298 (*alignable)->id()); 00299 SurveyError error((*alignable)->alignableObjectId(), (*alignable)->id(), (*alignable)->survey()->errors()); 00300 00301 cscAlignments->m_align.push_back(value); 00302 cscSurveyErrors->m_surveyErrors.push_back(error); 00303 } 00304 00305 // Store CSC alignments and errors 00306 poolDbService->writeOne<Alignments>( &(*cscAlignments), poolDbService->currentTime(), theCSCSurveyRecordName); 00307 poolDbService->writeOne<SurveyErrors>( &(*cscSurveyErrors), poolDbService->currentTime(), theCSCSurveyErrorRecordName); 00308 }
Definition at line 330 of file MuonAlignment.cc.
References AlignableMuon::cscAlignmentErrors(), AlignableMuon::cscAlignments(), edm::Service< T >::isAvailable(), theAlignableMuon, theCSCAlignRecordName, and theCSCErrorRecordName.
Referenced by saveToDB().
00330 { 00331 // Call service 00332 edm::Service<cond::service::PoolDBOutputService> poolDbService; 00333 if( !poolDbService.isAvailable() ) // Die if not available 00334 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; 00335 00336 // Get alignments and errors 00337 Alignments* csc_Alignments = theAlignableMuon->cscAlignments(); 00338 AlignmentErrors* csc_AlignmentErrors = theAlignableMuon->cscAlignmentErrors(); 00339 00340 // Store CSC alignments and errors 00341 poolDbService->writeOne<Alignments>( &(*csc_Alignments), poolDbService->currentTime(), theCSCAlignRecordName); 00342 poolDbService->writeOne<AlignmentErrors>( &(*csc_AlignmentErrors), poolDbService->currentTime(), theCSCErrorRecordName); 00343 }
Definition at line 244 of file MuonAlignment.cc.
References AlignableMuon::DTBarrel(), error, edm::Service< T >::isAvailable(), Alignments::m_align, SurveyErrors::m_surveyErrors, recursiveList(), rot, theAlignableMuon, theDTSurveyErrorRecordName, theDTSurveyRecordName, value, PV3DBase< T, PVType, FrameType >::x(), TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), PV3DBase< T, PVType, FrameType >::y(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), PV3DBase< T, PVType, FrameType >::z(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().
Referenced by saveSurveyToDB().
00244 { 00245 // Call service 00246 edm::Service<cond::service::PoolDBOutputService> poolDbService; 00247 if( !poolDbService.isAvailable() ) // Die if not available 00248 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; 00249 00250 // Get alignments and errors 00251 Alignments *dtAlignments = new Alignments(); 00252 SurveyErrors *dtSurveyErrors = new SurveyErrors(); 00253 00254 std::vector<Alignable*> alignableList; 00255 recursiveList(theAlignableMuon->DTBarrel(), alignableList); 00256 00257 for (std::vector<Alignable*>::const_iterator alignable = alignableList.begin(); alignable != alignableList.end(); ++alignable) { 00258 const align::PositionType &pos = (*alignable)->survey()->position(); 00259 const align::RotationType &rot = (*alignable)->survey()->rotation(); 00260 00261 AlignTransform value(CLHEP::Hep3Vector(pos.x(), pos.y(), pos.z()), 00262 CLHEP::HepRotation(CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), 00263 rot.yx(), rot.yy(), rot.yz(), 00264 rot.zx(), rot.zy(), rot.zz())), 00265 (*alignable)->id()); 00266 SurveyError error((*alignable)->alignableObjectId(), (*alignable)->id(), (*alignable)->survey()->errors()); 00267 00268 dtAlignments->m_align.push_back(value); 00269 dtSurveyErrors->m_surveyErrors.push_back(error); 00270 } 00271 00272 // Store DT alignments and errors 00273 poolDbService->writeOne<Alignments>( &(*dtAlignments), poolDbService->currentTime(), theDTSurveyRecordName); 00274 poolDbService->writeOne<SurveyErrors>( &(*dtSurveyErrors), poolDbService->currentTime(), theDTSurveyErrorRecordName); 00275 }
Definition at line 315 of file MuonAlignment.cc.
References AlignableMuon::dtAlignmentErrors(), AlignableMuon::dtAlignments(), edm::Service< T >::isAvailable(), theAlignableMuon, theDTAlignRecordName, and theDTErrorRecordName.
Referenced by saveToDB().
00315 { 00316 // Call service 00317 edm::Service<cond::service::PoolDBOutputService> poolDbService; 00318 if( !poolDbService.isAvailable() ) // Die if not available 00319 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; 00320 00321 // Get alignments and errors 00322 Alignments* dt_Alignments = theAlignableMuon->dtAlignments() ; 00323 AlignmentErrors* dt_AlignmentErrors = theAlignableMuon->dtAlignmentErrors(); 00324 00325 // Store DT alignments and errors 00326 poolDbService->writeOne<Alignments>( &(*dt_Alignments), poolDbService->currentTime(), theDTAlignRecordName); 00327 poolDbService->writeOne<AlignmentErrors>( &(*dt_AlignmentErrors), poolDbService->currentTime(), theDTErrorRecordName); 00328 }
Definition at line 310 of file MuonAlignment.cc.
References saveCSCSurveyToDB(), and saveDTSurveyToDB().
Referenced by MuonGeometryDBConverter::analyze().
00310 { 00311 saveDTSurveyToDB(); 00312 saveCSCSurveyToDB(); 00313 }
Definition at line 345 of file MuonAlignment.cc.
References saveCSCtoDB(), and saveDTtoDB().
Referenced by MuonGeometryDBConverter::analyze(), and DTSurveyConvert::endJob().
00345 { 00346 saveDTtoDB(); 00347 saveCSCtoDB(); 00348 }
void MuonAlignment::writeXML | ( | const edm::ParameterSet | iConfig, | |
const edm::EventSetup & | iSetup | |||
) |
Definition at line 240 of file MuonAlignment.cc.
References theAlignableMuon.
Referenced by MuonGeometryDBConverter::analyze().
00240 { 00241 MuonAlignmentOutputXML(iConfig).write(theAlignableMuon, iSetup); 00242 }
std::vector<float> MuonAlignment::displacements [private] |
Definition at line 67 of file MuonAlignment.h.
std::vector<float> MuonAlignment::rotations [private] |
Definition at line 69 of file MuonAlignment.h.
AlignableMuon* MuonAlignment::theAlignableMuon [private] |
Definition at line 71 of file MuonAlignment.h.
Referenced by copyAlignmentToSurvey(), copySurveyToAlignment(), fillGapsInSurvey(), getAlignableMuon(), init(), MuonAlignment(), saveCSCSurveyToDB(), saveCSCtoDB(), saveDTSurveyToDB(), saveDTtoDB(), writeXML(), and ~MuonAlignment().
Definition at line 73 of file MuonAlignment.h.
Referenced by getAlignableNavigator(), init(), moveAlignableGlobalCoord(), moveAlignableLocalCoord(), MuonAlignment(), and ~MuonAlignment().
std::string MuonAlignment::theCSCAlignRecordName [private] |
std::string MuonAlignment::theCSCErrorRecordName [private] |
std::string MuonAlignment::theCSCSurveyErrorRecordName [private] |
std::string MuonAlignment::theCSCSurveyRecordName [private] |
std::string MuonAlignment::theDTAlignRecordName [private] |
std::string MuonAlignment::theDTErrorRecordName [private] |
std::string MuonAlignment::theDTSurveyErrorRecordName [private] |
std::string MuonAlignment::theDTSurveyRecordName [private] |