CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     MuonAlignment
00004 // Class  :     MuonAlignmentInputDB
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Jim Pivarski
00010 //         Created:  Thu Mar  6 17:30:46 CST 2008
00011 // $Id: MuonAlignmentInputDB.cc,v 1.4 2009/10/07 20:46:39 pivarski Exp $
00012 //
00013 
00014 // system include files
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 
00017 // user include files
00018 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h"
00019 #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
00020 #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h"
00021 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h"
00022 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorRcd.h"
00023 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00024 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00025 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00026 
00027 //
00028 // constants, enums and typedefs
00029 //
00030 
00031 //
00032 // static data member definitions
00033 //
00034 
00035 //
00036 // constructors and destructor
00037 //
00038 MuonAlignmentInputDB::MuonAlignmentInputDB()
00039    : m_dtLabel(""), m_cscLabel("") {}
00040 
00041 MuonAlignmentInputDB::MuonAlignmentInputDB(std::string dtLabel, std::string cscLabel, bool getAPEs)
00042    : m_dtLabel(dtLabel), m_cscLabel(cscLabel), m_getAPEs(getAPEs) {}
00043 
00044 // MuonAlignmentInputDB::MuonAlignmentInputDB(const MuonAlignmentInputDB& rhs)
00045 // {
00046 //    // do actual copying here;
00047 // }
00048 
00049 MuonAlignmentInputDB::~MuonAlignmentInputDB() {}
00050 
00051 //
00052 // assignment operators
00053 //
00054 // const MuonAlignmentInputDB& MuonAlignmentInputDB::operator=(const MuonAlignmentInputDB& rhs)
00055 // {
00056 //   //An exception safe implementation is
00057 //   MuonAlignmentInputDB temp(rhs);
00058 //   swap(rhs);
00059 //
00060 //   return *this;
00061 // }
00062 
00063 //
00064 // member functions
00065 //
00066 
00067 AlignableMuon *MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSetup) const {
00068    boost::shared_ptr<DTGeometry> dtGeometry = idealDTGeometry(iSetup);
00069    boost::shared_ptr<CSCGeometry> cscGeometry = idealCSCGeometry(iSetup);
00070 
00071    edm::ESHandle<Alignments> dtAlignments;
00072    edm::ESHandle<AlignmentErrors> dtAlignmentErrors;
00073    edm::ESHandle<Alignments> cscAlignments;
00074    edm::ESHandle<AlignmentErrors> cscAlignmentErrors;
00075    edm::ESHandle<Alignments> globalPositionRcd;
00076 
00077    iSetup.get<DTAlignmentRcd>().get(m_dtLabel, dtAlignments);
00078    iSetup.get<CSCAlignmentRcd>().get(m_cscLabel, cscAlignments);
00079    iSetup.get<GlobalPositionRcd>().get(globalPositionRcd);
00080 
00081    if (m_getAPEs) {
00082       iSetup.get<DTAlignmentErrorRcd>().get(m_dtLabel, dtAlignmentErrors);
00083       iSetup.get<CSCAlignmentErrorRcd>().get(m_cscLabel, cscAlignmentErrors);
00084 
00085       GeometryAligner aligner;
00086       aligner.applyAlignments<DTGeometry>(&(*dtGeometry), &(*dtAlignments), &(*dtAlignmentErrors),
00087                                           align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00088       aligner.applyAlignments<CSCGeometry>(&(*cscGeometry), &(*cscAlignments), &(*cscAlignmentErrors),
00089                                            align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00090    }
00091    else {
00092       AlignmentErrors dtAlignmentErrors2, cscAlignmentErrors2;
00093 
00094       for (std::vector<AlignTransform>::const_iterator i = dtAlignments->m_align.begin();  i != dtAlignments->m_align.end();  ++i) {
00095          CLHEP::HepSymMatrix empty_matrix(3, 0);
00096          AlignTransformError empty_error(empty_matrix, i->rawId());
00097          dtAlignmentErrors2.m_alignError.push_back(empty_error);
00098       }
00099       for (std::vector<AlignTransform>::const_iterator i = cscAlignments->m_align.begin();  i != cscAlignments->m_align.end();  ++i) {
00100          CLHEP::HepSymMatrix empty_matrix(3, 0);
00101          AlignTransformError empty_error(empty_matrix, i->rawId());
00102          cscAlignmentErrors2.m_alignError.push_back(empty_error);
00103       }
00104 
00105       GeometryAligner aligner;
00106       aligner.applyAlignments<DTGeometry>(&(*dtGeometry), &(*dtAlignments), &(dtAlignmentErrors2),
00107                                           align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00108       aligner.applyAlignments<CSCGeometry>(&(*cscGeometry), &(*cscAlignments), &(cscAlignmentErrors2),
00109                                            align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00110    }
00111 
00112    return new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
00113 }
00114 
00115 //
00116 // const member functions
00117 //
00118 
00119 //
00120 // static member functions
00121 //