File indexing completed on 2024-04-06 11:56:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016
0017
0018 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h"
0019 #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h"
0020 #include "CondFormats/AlignmentRecord/interface/DTSurveyErrorExtendedRcd.h"
0021 #include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h"
0022 #include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h"
0023 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
0024 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const DTGeometry* dtGeometry,
0038 const CSCGeometry* cscGeometry,
0039 const GEMGeometry* gemGeometry,
0040 const Alignments* dtSurvey,
0041 const Alignments* cscSurvey,
0042 const SurveyErrors* dtSurveyError,
0043 const SurveyErrors* cscSurveyError)
0044 : dtGeometry_(dtGeometry),
0045 cscGeometry_(cscGeometry),
0046 gemGeometry_(gemGeometry),
0047 dtSurvey_(dtSurvey),
0048 cscSurvey_(cscSurvey),
0049 dtSurveyError_(dtSurveyError),
0050 cscSurveyError_(cscSurveyError) {}
0051
0052
0053
0054
0055
0056
0057 MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {}
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 AlignableMuon* MuonAlignmentInputSurveyDB::newAlignableMuon() const {
0076 AlignableMuon* output = new AlignableMuon(dtGeometry_, cscGeometry_, gemGeometry_);
0077
0078 unsigned int theSurveyIndex = 0;
0079 const Alignments* theSurveyValues = dtSurvey_;
0080 const SurveyErrors* theSurveyErrors = dtSurveyError_;
0081 const auto& barrels = output->DTBarrel();
0082 for (const auto& iter : barrels) {
0083 addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
0084 }
0085
0086 theSurveyIndex = 0;
0087 theSurveyValues = cscSurvey_;
0088 theSurveyErrors = cscSurveyError_;
0089 const auto& endcaps = output->CSCEndcaps();
0090 for (const auto& iter : endcaps) {
0091 addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
0092 }
0093
0094 return output;
0095 }
0096
0097
0098
0099
0100
0101 void MuonAlignmentInputSurveyDB::addSurveyInfo_(Alignable* ali,
0102 unsigned int* theSurveyIndex,
0103 const Alignments* theSurveyValues,
0104 const SurveyErrors* theSurveyErrors) const {
0105 const auto& comp = ali->components();
0106
0107 unsigned int nComp = comp.size();
0108
0109 for (unsigned int i = 0; i < nComp; ++i)
0110 addSurveyInfo_(comp[i], theSurveyIndex, theSurveyValues, theSurveyErrors);
0111
0112 const SurveyError& error = theSurveyErrors->m_surveyErrors[*theSurveyIndex];
0113
0114 if (ali->geomDetId().rawId() != error.rawId() || ali->alignableObjectId() != error.structureType()) {
0115 throw cms::Exception("DatabaseError") << "Error reading survey info from DB. Mismatched id!";
0116 }
0117
0118 const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[*theSurveyIndex].translation();
0119 const CLHEP::HepRotation& rot = theSurveyValues->m_align[*theSurveyIndex].rotation();
0120
0121 AlignableSurface surf(
0122 align::PositionType(pos.x(), pos.y(), pos.z()),
0123 align::RotationType(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
0124
0125 surf.setWidth(ali->surface().width());
0126 surf.setLength(ali->surface().length());
0127
0128 ali->setSurvey(new SurveyDet(surf, error.matrix()));
0129
0130 (*theSurveyIndex)++;
0131 }
0132
0133
0134
0135
0136
0137
0138
0139