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
25 
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  const CSCGeometry* cscGeometry,
39  const GEMGeometry* gemGeometry,
40  const Alignments* dtSurvey,
41  const Alignments* cscSurvey,
42  const SurveyErrors* dtSurveyError,
43  const SurveyErrors* cscSurveyError)
44  : dtGeometry_(dtGeometry),
45  cscGeometry_(cscGeometry),
46  gemGeometry_(gemGeometry),
47  dtSurvey_(dtSurvey),
48  cscSurvey_(cscSurvey),
49  dtSurveyError_(dtSurveyError),
50  cscSurveyError_(cscSurveyError) {}
51 
52 // MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB& rhs)
53 // {
54 // // do actual copying here;
55 //
56 
58 
59 //
60 // assignment operators
61 //
62 // const MuonAlignmentInputSurveyDB& MuonAlignmentInputSurveyDB::operator=(const MuonAlignmentInputSurveyDB& rhs)
63 // {
64 // //An exception safe implementation is
65 // MuonAlignmentInputSurveyDB temp(rhs);
66 // swap(rhs);
67 //
68 // return *this;
69 // }
70 
71 //
72 // member functions
73 //
74 
77 
78  unsigned int theSurveyIndex = 0;
79  const Alignments* theSurveyValues = dtSurvey_;
80  const SurveyErrors* theSurveyErrors = dtSurveyError_;
81  const auto& barrels = output->DTBarrel();
82  for (const auto& iter : barrels) {
83  addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
84  }
85 
86  theSurveyIndex = 0;
87  theSurveyValues = cscSurvey_;
88  theSurveyErrors = cscSurveyError_;
89  const auto& endcaps = output->CSCEndcaps();
90  for (const auto& iter : endcaps) {
91  addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
92  }
93 
94  return output;
95 }
96 
97 // This function was copied (with minimal modifications) from
98 // Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc
99 // (version CMSSW_2_0_0_pre1), guaranteed to work the same way
100 // unless AlignmentProducer.cc's version changes!
102  unsigned int* theSurveyIndex,
103  const Alignments* theSurveyValues,
104  const SurveyErrors* theSurveyErrors) const {
105  const auto& comp = ali->components();
106 
107  unsigned int nComp = comp.size();
108 
109  for (unsigned int i = 0; i < nComp; ++i)
110  addSurveyInfo_(comp[i], theSurveyIndex, theSurveyValues, theSurveyErrors);
111 
112  const SurveyError& error = theSurveyErrors->m_surveyErrors[*theSurveyIndex];
113 
114  if (ali->geomDetId().rawId() != error.rawId() || ali->alignableObjectId() != error.structureType()) {
115  throw cms::Exception("DatabaseError") << "Error reading survey info from DB. Mismatched id!";
116  }
117 
118  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[*theSurveyIndex].translation();
119  const CLHEP::HepRotation& rot = theSurveyValues->m_align[*theSurveyIndex].rotation();
120 
121  AlignableSurface surf(
122  align::PositionType(pos.x(), pos.y(), pos.z()),
123  align::RotationType(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
124 
125  surf.setWidth(ali->surface().width());
126  surf.setLength(ali->surface().length());
127 
128  ali->setSurvey(new SurveyDet(surf, error.matrix()));
129 
130  (*theSurveyIndex)++;
131 }
132 
133 //
134 // const member functions
135 //
136 
137 //
138 // static member functions
139 //
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
align::Scalar width() const
void setWidth(align::Scalar width)
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)
AlignableMuon * newAlignableMuon() const override
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual const Alignables & components() const =0
Return vector of all direct components.
MuonAlignmentInputSurveyDB(const DTGeometry *dtGeometry, const CSCGeometry *cscGeometry, const GEMGeometry *gemGeometry, const Alignments *dtSurvey, const Alignments *cscSurvey, const SurveyErrors *dtSurveyError, const SurveyErrors *cscSurveyError)
const DetId & geomDetId() const
Definition: Alignable.h:177
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
align::Scalar length() const
Definition: output.py:1
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:22
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38