CMS 3D CMS Logo

MuonAlignmentInputSurveyDB.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonAlignment
4 // Class : MuonAlignmentInputSurveyDB
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Jim Pivarski
10 // Created: Thu Mar 6 17:30:46 CST 2008
11 // $Id: MuonAlignmentInputSurveyDB.cc,v 1.1 2008/03/15 20:26:46 pivarski Exp $
12 //
13 
14 // system include files
16 
17 // user include files
24 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 //
34 // constructors and destructor
35 //
36 MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB() : m_dtLabel(""), m_cscLabel("") {}
37 
39  : m_dtLabel(dtLabel), m_cscLabel(cscLabel) {}
40 
41 // MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 
48 //
49 // assignment operators
50 //
51 // const MuonAlignmentInputSurveyDB& MuonAlignmentInputSurveyDB::operator=(const MuonAlignmentInputSurveyDB& rhs)
52 // {
53 // //An exception safe implementation is
54 // MuonAlignmentInputSurveyDB temp(rhs);
55 // swap(rhs);
56 //
57 // return *this;
58 // }
59 
60 //
61 // member functions
62 //
63 
65  std::shared_ptr<DTGeometry> dtGeometry = idealDTGeometry(iSetup);
66  std::shared_ptr<CSCGeometry> cscGeometry = idealCSCGeometry(iSetup);
67 
69  edm::ESHandle<SurveyErrors> dtSurveyError;
70  edm::ESHandle<Alignments> cscSurvey;
71  edm::ESHandle<SurveyErrors> cscSurveyError;
72  iSetup.get<DTSurveyRcd>().get(m_dtLabel, dtSurvey);
73  iSetup.get<DTSurveyErrorExtendedRcd>().get(m_dtLabel, dtSurveyError);
74  iSetup.get<CSCSurveyRcd>().get(m_cscLabel, cscSurvey);
75  iSetup.get<CSCSurveyErrorExtendedRcd>().get(m_cscLabel, cscSurveyError);
76 
77  AlignableMuon* output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
78 
79  unsigned int theSurveyIndex = 0;
80  const Alignments* theSurveyValues = &*dtSurvey;
81  const SurveyErrors* theSurveyErrors = &*dtSurveyError;
82  const auto& barrels = output->DTBarrel();
83  for (const auto& iter : barrels) {
84  addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
85  }
86 
87  theSurveyIndex = 0;
88  theSurveyValues = &*cscSurvey;
89  theSurveyErrors = &*cscSurveyError;
90  const auto& endcaps = output->CSCEndcaps();
91  for (const auto& iter : endcaps) {
92  addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
93  }
94 
95  return output;
96 }
97 
98 // This function was copied (with minimal modifications) from
99 // Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc
100 // (version CMSSW_2_0_0_pre1), guaranteed to work the same way
101 // unless AlignmentProducer.cc's version changes!
103  unsigned int* theSurveyIndex,
104  const Alignments* theSurveyValues,
105  const SurveyErrors* theSurveyErrors) const {
106  const auto& comp = ali->components();
107 
108  unsigned int nComp = comp.size();
109 
110  for (unsigned int i = 0; i < nComp; ++i)
111  addSurveyInfo_(comp[i], theSurveyIndex, theSurveyValues, theSurveyErrors);
112 
113  const SurveyError& error = theSurveyErrors->m_surveyErrors[*theSurveyIndex];
114 
115  if (ali->geomDetId().rawId() != error.rawId() || ali->alignableObjectId() != error.structureType()) {
116  throw cms::Exception("DatabaseError") << "Error reading survey info from DB. Mismatched id!";
117  }
118 
119  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[*theSurveyIndex].translation();
120  const CLHEP::HepRotation& rot = theSurveyValues->m_align[*theSurveyIndex].rotation();
121 
122  AlignableSurface surf(
123  align::PositionType(pos.x(), pos.y(), pos.z()),
124  align::RotationType(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
125 
126  surf.setWidth(ali->surface().width());
127  surf.setLength(ali->surface().length());
128 
129  ali->setSurvey(new SurveyDet(surf, error.matrix()));
130 
131  (*theSurveyIndex)++;
132 }
133 
134 //
135 // const member functions
136 //
137 
138 //
139 // static member functions
140 //
align::Scalar width() const
AlignableMuon * newAlignableMuon(const edm::EventSetup &iSetup) const override
ErrorMatrix matrix() const
Definition: SurveyError.h:63
align::Alignables DTBarrel()
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::shared_ptr< DTGeometry > idealDTGeometry(const edm::EventSetup &iSetup) const
void setWidth(align::Scalar width)
virtual const Alignables & components() const =0
Return vector of all direct components.
uint8_t structureType() const
Definition: SurveyError.h:59
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
void addSurveyInfo_(Alignable *ali, unsigned int *theSurveyIndex, const Alignments *theSurveyValues, const SurveyErrors *theSurveyErrors) const
void setLength(align::Scalar length)
std::shared_ptr< CSCGeometry > idealCSCGeometry(const edm::EventSetup &iSetup) const
align::Alignables CSCEndcaps()
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
align::ID rawId() const
Definition: SurveyError.h:61
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
align::Scalar length() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
T get() const
Definition: EventSetup.h:73
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:22
Constructor of the full muon geometry.
Definition: AlignableMuon.h:33
const DetId & geomDetId() const
Definition: Alignable.h:177