Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016
00017
00018 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h"
00019 #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h"
00020 #include "CondFormats/AlignmentRecord/interface/DTSurveyErrorRcd.h"
00021 #include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h"
00022 #include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorRcd.h"
00023 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB()
00037 : m_dtLabel(""), m_cscLabel("") {}
00038
00039 MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(std::string dtLabel, std::string cscLabel)
00040 : m_dtLabel(dtLabel), m_cscLabel(cscLabel) {}
00041
00042
00043
00044
00045
00046
00047 MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {}
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 AlignableMuon *MuonAlignmentInputSurveyDB::newAlignableMuon(const edm::EventSetup& iSetup) const {
00066 boost::shared_ptr<DTGeometry> dtGeometry = idealDTGeometry(iSetup);
00067 boost::shared_ptr<CSCGeometry> cscGeometry = idealCSCGeometry(iSetup);
00068
00069 edm::ESHandle<Alignments> dtSurvey;
00070 edm::ESHandle<SurveyErrors> dtSurveyError;
00071 edm::ESHandle<Alignments> cscSurvey;
00072 edm::ESHandle<SurveyErrors> cscSurveyError;
00073 iSetup.get<DTSurveyRcd>().get(m_dtLabel, dtSurvey);
00074 iSetup.get<DTSurveyErrorRcd>().get(m_dtLabel, dtSurveyError);
00075 iSetup.get<CSCSurveyRcd>().get(m_cscLabel, cscSurvey);
00076 iSetup.get<CSCSurveyErrorRcd>().get(m_cscLabel, cscSurveyError);
00077
00078 AlignableMuon *output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
00079
00080 unsigned int theSurveyIndex = 0;
00081 const Alignments *theSurveyValues = &*dtSurvey;
00082 const SurveyErrors *theSurveyErrors = &*dtSurveyError;
00083 std::vector<Alignable*> barrels = output->DTBarrel();
00084 for (std::vector<Alignable*>::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) {
00085 addSurveyInfo_(*iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
00086 }
00087
00088 theSurveyIndex = 0;
00089 theSurveyValues = &*cscSurvey;
00090 theSurveyErrors = &*cscSurveyError;
00091 std::vector<Alignable*> endcaps = output->CSCEndcaps();
00092 for (std::vector<Alignable*>::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) {
00093 addSurveyInfo_(*iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
00094 }
00095
00096 return output;
00097 }
00098
00099
00100
00101
00102
00103 void MuonAlignmentInputSurveyDB::addSurveyInfo_(Alignable* ali,
00104 unsigned int *theSurveyIndex,
00105 const Alignments* theSurveyValues,
00106 const SurveyErrors* theSurveyErrors) const {
00107 const std::vector<Alignable*>& comp = ali->components();
00108
00109 unsigned int nComp = comp.size();
00110
00111 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i], theSurveyIndex, theSurveyValues, theSurveyErrors);
00112
00113 const SurveyError& error = theSurveyErrors->m_surveyErrors[*theSurveyIndex];
00114
00115 if ( ali->geomDetId().rawId() != error.rawId() ||
00116 ali->alignableObjectId() != error.structureType() )
00117 {
00118 throw cms::Exception("DatabaseError")
00119 << "Error reading survey info from DB. Mismatched id!";
00120 }
00121
00122 const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[*theSurveyIndex].translation();
00123 const CLHEP::HepRotation& rot = theSurveyValues->m_align[*theSurveyIndex].rotation();
00124
00125 AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ),
00126 align::RotationType( rot.xx(), rot.xy(), rot.xz(),
00127 rot.yx(), rot.yy(), rot.yz(),
00128 rot.zx(), rot.zy(), rot.zz() ) );
00129
00130 surf.setWidth( ali->surface().width() );
00131 surf.setLength( ali->surface().length() );
00132
00133 ali->setSurvey( new SurveyDet( surf, error.matrix() ) );
00134
00135 (*theSurveyIndex)++;
00136 }
00137
00138
00139
00140
00141
00142
00143
00144