Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-22 02:30:53

0001 // -*- C++ -*-
0002 //
0003 // Package:     MuonAlignment
0004 // Class  :     MuonAlignmentInputSurveyDB
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Jim Pivarski
0010 //         Created:  Thu Mar  6 17:30:46 CST 2008
0011 // $Id: MuonAlignmentInputSurveyDB.cc,v 1.1 2008/03/15 20:26:46 pivarski Exp $
0012 //
0013 
0014 // system include files
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 
0017 // user include files
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 // constants, enums and typedefs
0028 //
0029 
0030 //
0031 // static data member definitions
0032 //
0033 
0034 //
0035 // constructors and destructor
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 // MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB& rhs)
0053 // {
0054 //    // do actual copying here;
0055 //
0056 
0057 MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {}
0058 
0059 //
0060 // assignment operators
0061 //
0062 // const MuonAlignmentInputSurveyDB& MuonAlignmentInputSurveyDB::operator=(const MuonAlignmentInputSurveyDB& rhs)
0063 // {
0064 //   //An exception safe implementation is
0065 //   MuonAlignmentInputSurveyDB temp(rhs);
0066 //   swap(rhs);
0067 //
0068 //   return *this;
0069 // }
0070 
0071 //
0072 // member functions
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 // This function was copied (with minimal modifications) from
0098 // Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc
0099 // (version CMSSW_2_0_0_pre1), guaranteed to work the same way
0100 // unless AlignmentProducer.cc's version changes!
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 // const member functions
0135 //
0136 
0137 //
0138 // static member functions
0139 //