CMS 3D CMS Logo

AlignableBeamSpot.cc
Go to the documentation of this file.
1 
13 #include "CLHEP/Vector/RotationInterfaces.h"
16 
19 
20 //__________________________________________________________________________________________________
22  Alignable( AlignableBeamSpot::detId().rawId(), AlignableSurface() ),
23  theAlignmentPositionError(nullptr),
24  theInitializedFlag(false)
25 {
26 
27 }
28 
29 //__________________________________________________________________________________________________
31 {
33 }
34 
35 //__________________________________________________________________________________________________
37 {
38  theSurface.move( displacement );
39  this->addDisplacement( displacement );
40 }
41 
42 //__________________________________________________________________________________________________
44 {
45  theSurface.rotate( rotation );
46  this->addRotation( rotation );
47 }
48 
49 //__________________________________________________________________________________________________
51 {
54  else
56 }
57 
58 //__________________________________________________________________________________________________
60 {
63  } else {
65  }
66 }
67 
68 //__________________________________________________________________________________________________
70  bool propagateDown)
71 {
72 
73 }
74 
75 //__________________________________________________________________________________________________
80  bool propagateDown )
81 {
82 
83 }
84 
85 //__________________________________________________________________________________________________
87 {
88  edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::setSurfaceDeformation"
89  << "Useless method for beam spot, do nothing.";
90 }
91 
92 //__________________________________________________________________________________________________
94 {
95  edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::addSurfaceDeformation"
96  << "Useless method for beam spot, do nothing.";
97 }
98 
99 //__________________________________________________________________________________________________
100 void AlignableBeamSpot::dump( void ) const
101 {
102  // Dump this
103 
104  LocalVector lv(0.0, 0.0, 1.0);
106 
107  edm::LogInfo("AlignableDump")
108  << " Alignable of type " << this->alignableObjectId()
109  << " has 0 components" << std::endl
110  << " position = " << this->globalPosition() << ", orientation:" << std::endl << std::flush
111  << this->globalRotation() << std::endl << std::flush
112  << " dxdz = " << gv.x()/gv.z() << " dydz = " << gv.y()/gv.z() << std::endl;
113 }
114 
115 //__________________________________________________________________________________________________
117 {
118  Alignments* m_alignments = new Alignments();
119  RotationType rot( this->globalRotation() );
120 
121  // Get position, rotation, detId
122  CLHEP::Hep3Vector clhepVector( globalPosition().x(), globalPosition().y(), globalPosition().z() );
123  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
124  rot.yx(), rot.yy(), rot.yz(),
125  rot.zx(), rot.zy(), rot.zz() ) );
126  uint32_t detId = theId;
127 
128  AlignTransform transform( clhepVector, clhepRotation, detId );
129 
130  // Add to alignments container
131  m_alignments->m_align.push_back( transform );
132 
133  return m_alignments;
134 }
135 
136 //__________________________________________________________________________________________________
138 {
139  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
140 
141  // Add associated alignment position error
142  uint32_t detId = theId;
143  CLHEP::HepSymMatrix clhepSymMatrix(6,0);
144  if ( theAlignmentPositionError ) // Might not be set
146  AlignTransformErrorExtended transformError( clhepSymMatrix, detId );
147  m_alignmentErrors->m_alignError.push_back( transformError );
148 
149  return m_alignmentErrors;
150 }
151 
152 //______________________________________________________________________________
153 void AlignableBeamSpot::initialize(double x, double y, double z,
154  double dxdz, double dydz)
155 {
156  if (theInitializedFlag) return;
157 
158  GlobalVector gv(x, y, z);
159  theSurface.move(gv);
160 
161  double angleY = std::atan(dxdz);
162  double angleX = -std::atan(dydz);
163 
164  align::RotationType rotY( std::cos(angleY), 0., -std::sin(angleY),
165  0., 1., 0.,
166  std::sin(angleY), 0., std::cos(angleY) );
167 
168  align::RotationType rotX( 1., 0., 0.,
169  0., std::cos(angleX), std::sin(angleX),
170  0., -std::sin(angleX), std::cos(angleX) );
171 
172  theSurface.rotate(rotY * rotX);
173 
174  this->dump();
175 
176  theInitializedFlag = true;
177 }
178 
179 //______________________________________________________________________________
181 {
182  Alignable::update(this->id(), AlignableSurface());
184  theAlignmentPositionError = nullptr;
185  theInitializedFlag = false;
186 }
187 
188 //______________________________________________________________________________
T xx() const
void initialize(double x, double y, double z, double dxdz, double dydz)
initialize the alignable with the passed beam spot parameters
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:54
void update(align::ID, const AlignableSurface &)
Definition: Alignable.cc:49
void move(const GlobalVector &displacement) override
Move with respect to the global reference frame.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:144
void dump() const override
Recursive printout of alignable structure.
#define nullptr
T y() const
Definition: PV3DBase.h:63
T yx() const
void rotateInGlobalFrame(const RotationType &rotation) override
Rotation interpreted in global reference frame.
void move(const GlobalVector &displacement)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
AlignmentErrorsExtended * alignmentErrors() const override
Return vector of alignment errors.
void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
Set the AlignmentPositionError and, if (propagateDown), to all components.
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
const GlobalErrorExtended & globalError() const
T zx() const
T xy() const
T zz() const
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:147
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
~AlignableBeamSpot() override
Destructor.
T zy() const
void addSurfaceDeformation(const SurfaceDeformation *, bool) override
do no use, for compatibility only
T yy() const
void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool propagateDown) override
const AlgebraicSymMatrix66 & matrix() const
void addAlignmentPositionErrorFromLocalRotation(const RotationType &rotation, bool propagateDown) override
static const Alignables emptyComponents_
static const DetId detId()
std::vector< AlignTransformErrorExtended > m_alignError
StructureType alignableObjectId() const override
Return the alignable type identifier.
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:254
AlignmentPositionError * theAlignmentPositionError
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:246
std::vector< Alignable * > Alignables
Definition: Utilities.h:32
void rotate(const RotationType &rotation)
void reset()
reset beam spot to the uninitialized state
T xz() const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
void setSurfaceDeformation(const SurfaceDeformation *, bool) override
do no use, for compatibility only
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
align::ID theId
Definition: Alignable.h:244
T x() const
Definition: PV3DBase.h:62
T yz() const
AlignableSurface theSurface
Definition: Alignable.h:246
Alignments * alignments() const override
Return vector of alignment data.