CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableDet.cc
Go to the documentation of this file.
4 #include "CLHEP/Vector/RotationInterfaces.h"
8 
10 
13 
14 
15 //__________________________________________________________________________________________________
16 AlignableDet::AlignableDet( const GeomDet* geomDet, bool addComponents ) :
17  AlignableComposite( geomDet ),
18  theAlignmentPositionError(0)
19 {
20  if (geomDet->alignmentPositionError()) {
21  // false: do not propagate APE to (anyway not yet existing) daughters
22  this->setAlignmentPositionError(*(geomDet->alignmentPositionError()), false);
23  }
24 
25  if (addComponents) {
26  if ( geomDet->components().size() == 0 ) { // Is a DetUnit
27  throw cms::Exception("BadHierarchy") << "[AlignableDet] GeomDet with DetId "
28  << geomDet->geographicalId().rawId()
29  << " has no components, use AlignableDetUnit.\n";
30  } else { // Push back all components
31  const std::vector<const GeomDet*>& geomDets = geomDet->components();
32  for (std::vector<const GeomDet*>::const_iterator idet = geomDets.begin();
33  idet != geomDets.end(); ++idet) {
34  const GeomDetUnit *unit = dynamic_cast<const GeomDetUnit*>(*idet);
35  if (!unit) {
36  throw cms::Exception("BadHierarchy")
37  << "[AlignableDet] component not GeomDetUnit, call with addComponents==false"
38  << " and build hierarchy yourself.\n"; // e.g. AlignableDTChamber
39  }
40  this->addComponent(new AlignableDetUnit(unit));
41  }
42  }
43  // Ensure that the surface is not screwed up by addComponent, it must stay the GeomDet's one:
44  theSurface = AlignableSurface(geomDet->surface());
45  } // end addComponents
46 }
47 
48 
49 //__________________________________________________________________________________________________
51 {
52 
54 
55 }
56 
57 
58 //__________________________________________________________________________________________________
60 {
61 
64  else
66 
67  this->AlignableComposite::setAlignmentPositionError( ape, propagateDown );
68 
69 }
70 
71 
72 //__________________________________________________________________________________________________
74 {
75 
78  } else {
80  }
81 
82  this->AlignableComposite::addAlignmentPositionError( ape, propagateDown );
83 
84 }
85 
86 //__________________________________________________________________________________________________
88  bool propagateDown)
89 {
90 
91  // average error calculated by movement of a local point at
92  // (xWidth/2,yLength/2,0) caused by the rotation rot
93  GlobalVector localPositionVector = surface().toGlobal( LocalVector(.5 * surface().width(), .5 * surface().length(), 0.) );
94 
95  LocalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
96  GlobalVector gv( rot.multiplyInverse(lpvgf) - lpvgf );
97 
98  AlignmentPositionError ape( gv.x(),gv.y(),gv.z() );
99  this->addAlignmentPositionError( ape, propagateDown );
100 
102 
103 }
104 
105 //__________________________________________________________________________________________________
107 {
108 
109  Alignments* m_alignments = new Alignments();
110  RotationType rot( this->globalRotation() );
111 
112  // Get position, rotation, detId
113  CLHEP::Hep3Vector clhepVector( globalPosition().x(), globalPosition().y(), globalPosition().z() );
114  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
115  rot.yx(), rot.yy(), rot.yz(),
116  rot.zx(), rot.zy(), rot.zz() ) );
117  uint32_t detId = this->geomDetId().rawId();
118 
119  AlignTransform transform( clhepVector, clhepRotation, detId );
120 
121  // Add to alignments container
122  m_alignments->m_align.push_back( transform );
123 
124  // Add those from components
125  Alignments *compAlignments = this->AlignableComposite::alignments();
126  std::copy(compAlignments->m_align.begin(), compAlignments->m_align.end(),
127  std::back_inserter(m_alignments->m_align));
128  delete compAlignments;
129 
130 
131  return m_alignments;
132 }
133 
134 //__________________________________________________________________________________________________
136 {
137 
138  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
139 
140  // Add associated alignment position error
141  uint32_t detId = this->geomDetId().rawId();
142  CLHEP::HepSymMatrix clhepSymMatrix(3,0);
143  if ( theAlignmentPositionError ) // Might not be set
145  AlignTransformError transformError( clhepSymMatrix, detId );
146  m_alignmentErrors->m_alignError.push_back( transformError );
147 
148  // Add those from components
149  AlignmentErrors *compAlignmentErrs = this->AlignableComposite::alignmentErrors();
150  std::copy(compAlignmentErrs->m_alignError.begin(), compAlignmentErrs->m_alignError.end(),
151  std::back_inserter(m_alignmentErrors->m_alignError));
152  delete compAlignmentErrs;
153 
154 
155  return m_alignmentErrors;
156 }
T xx() const
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:49
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
std::vector< AlignTransformError > m_alignError
const AlgebraicSymMatrix33 & matrix() const
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
Set the AlignmentPositionError and, if (propagateDown), to all components.
Definition: AlignableDet.cc:59
T yx() const
virtual Alignments * alignments() const
Return vector of alignment data.
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
align::LocalVector LocalVector
Definition: Alignable.h:38
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
float float float z
virtual AlignmentErrors * alignmentErrors() const
Return vector of alignment errors.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T zx() const
T xy() const
virtual AlignmentErrors * alignmentErrors() const
Return vector of alignment errors.
T zz() const
string unit
Definition: csvLumiCalc.py:46
T zy() const
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool propagateDown)
Definition: AlignableDet.cc:87
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
virtual Alignments * alignments() const
Return alignment data.
T yy() const
virtual std::vector< const GeomDet * > components() const =0
Returns direct components, if any.
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
Definition: AlignableDet.cc:73
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
const GlobalError & globalError() const
AlignableDet(const GeomDet *geomDet, bool addComponents=true)
Definition: AlignableDet.cc:16
T xz() const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
Definition: DDAxes.h:10
virtual ~AlignableDet()
Destructor.
Definition: AlignableDet.cc:50
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:88
T yz() const
const DetId & geomDetId() const
Definition: Alignable.h:177
AlignableSurface theSurface
Definition: Alignable.h:222
virtual void addComponent(Alignable *component)