CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //
37  : m_dtLabel(""), m_cscLabel("") {}
38 
40  : m_dtLabel(dtLabel), m_cscLabel(cscLabel) {}
41 
42 // MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB& rhs)
43 // {
44 // // do actual copying here;
45 // }
46 
48 
49 //
50 // assignment operators
51 //
52 // const MuonAlignmentInputSurveyDB& MuonAlignmentInputSurveyDB::operator=(const MuonAlignmentInputSurveyDB& rhs)
53 // {
54 // //An exception safe implementation is
55 // MuonAlignmentInputSurveyDB temp(rhs);
56 // swap(rhs);
57 //
58 // return *this;
59 // }
60 
61 //
62 // member functions
63 //
64 
66  boost::shared_ptr<DTGeometry> dtGeometry = idealDTGeometry(iSetup);
67  boost::shared_ptr<CSCGeometry> cscGeometry = idealCSCGeometry(iSetup);
68 
70  edm::ESHandle<SurveyErrors> dtSurveyError;
71  edm::ESHandle<Alignments> cscSurvey;
72  edm::ESHandle<SurveyErrors> cscSurveyError;
73  iSetup.get<DTSurveyRcd>().get(m_dtLabel, dtSurvey);
74  iSetup.get<DTSurveyErrorExtendedRcd>().get(m_dtLabel, dtSurveyError);
75  iSetup.get<CSCSurveyRcd>().get(m_cscLabel, cscSurvey);
76  iSetup.get<CSCSurveyErrorExtendedRcd>().get(m_cscLabel, cscSurveyError);
77 
78  AlignableMuon *output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
79 
80  unsigned int theSurveyIndex = 0;
81  const Alignments *theSurveyValues = &*dtSurvey;
82  const SurveyErrors *theSurveyErrors = &*dtSurveyError;
83  std::vector<Alignable*> barrels = output->DTBarrel();
84  for (std::vector<Alignable*>::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) {
85  addSurveyInfo_(*iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
86  }
87 
88  theSurveyIndex = 0;
89  theSurveyValues = &*cscSurvey;
90  theSurveyErrors = &*cscSurveyError;
91  std::vector<Alignable*> endcaps = output->CSCEndcaps();
92  for (std::vector<Alignable*>::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) {
93  addSurveyInfo_(*iter, &theSurveyIndex, theSurveyValues, theSurveyErrors);
94  }
95 
96  return output;
97 }
98 
99 // This function was copied (with minimal modifications) from
100 // Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc
101 // (version CMSSW_2_0_0_pre1), guaranteed to work the same way
102 // unless AlignmentProducer.cc's version changes!
104  unsigned int *theSurveyIndex,
105  const Alignments* theSurveyValues,
106  const SurveyErrors* theSurveyErrors) const {
107  const std::vector<Alignable*>& comp = ali->components();
108 
109  unsigned int nComp = comp.size();
110 
111  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i], theSurveyIndex, theSurveyValues, theSurveyErrors);
112 
113  const SurveyError& error = theSurveyErrors->m_surveyErrors[*theSurveyIndex];
114 
115  if ( ali->geomDetId().rawId() != error.rawId() ||
116  ali->alignableObjectId() != error.structureType() )
117  {
118  throw cms::Exception("DatabaseError")
119  << "Error reading survey info from DB. Mismatched id!";
120  }
121 
122  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[*theSurveyIndex].translation();
123  const CLHEP::HepRotation& rot = theSurveyValues->m_align[*theSurveyIndex].rotation();
124 
125  AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ),
126  align::RotationType( rot.xx(), rot.xy(), rot.xz(),
127  rot.yx(), rot.yy(), rot.yz(),
128  rot.zx(), rot.zy(), rot.zz() ) );
129 
130  surf.setWidth( ali->surface().width() );
131  surf.setLength( ali->surface().length() );
132 
133  ali->setSurvey( new SurveyDet( surf, error.matrix() ) );
134 
135  (*theSurveyIndex)++;
136 }
137 
138 //
139 // const member functions
140 //
141 
142 //
143 // static member functions
144 //
align::Scalar width() const
int i
Definition: DBlmapReader.cc:9
ErrorMatrix matrix() const
Definition: SurveyError.h:76
align::Alignables DTBarrel()
void setWidth(align::Scalar width)
uint8_t structureType() const
Definition: SurveyError.h:66
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
void addSurveyInfo_(Alignable *ali, unsigned int *theSurveyIndex, const Alignments *theSurveyValues, const SurveyErrors *theSurveyErrors) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void setLength(align::Scalar length)
align::Alignables CSCEndcaps()
virtual AlignableMuon * newAlignableMuon(const edm::EventSetup &iSetup) const
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
align::ID rawId() const
Definition: SurveyError.h:71
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
align::Scalar length() const
boost::shared_ptr< CSCGeometry > idealCSCGeometry(const edm::EventSetup &iSetup) const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:268
const T & get() const
Definition: EventSetup.h:55
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:23
Constructor of the full muon geometry.
Definition: AlignableMuon.h:36
const DetId & geomDetId() const
Definition: Alignable.h:177
boost::shared_ptr< DTGeometry > idealDTGeometry(const edm::EventSetup &iSetup) const