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 //__________________________________________________________________________________________________
28 
29 //__________________________________________________________________________________________________
30 void AlignableBeamSpot::move(const GlobalVector& displacement) {
32  this->addDisplacement(displacement);
33 }
34 
35 //__________________________________________________________________________________________________
38  this->addRotation(rotation);
39 }
40 
41 //__________________________________________________________________________________________________
45  else
47 }
48 
49 //__________________________________________________________________________________________________
53  } else {
55  }
56 }
57 
58 //__________________________________________________________________________________________________
60 
61 //__________________________________________________________________________________________________
66 
67 //__________________________________________________________________________________________________
69  edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::setSurfaceDeformation"
70  << "Useless method for beam spot, do nothing.";
71 }
72 
73 //__________________________________________________________________________________________________
75  edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::addSurfaceDeformation"
76  << "Useless method for beam spot, do nothing.";
77 }
78 
79 //__________________________________________________________________________________________________
80 void AlignableBeamSpot::dump(void) const {
81  // Dump this
82 
83  LocalVector lv(0.0, 0.0, 1.0);
85 
86  edm::LogInfo("AlignableDump") << " Alignable of type " << this->alignableObjectId() << " has 0 components"
87  << std::endl
88  << " position = " << this->globalPosition() << ", orientation:" << std::endl
89  << std::flush << this->globalRotation() << std::endl
90  << std::flush << " dxdz = " << gv.x() / gv.z() << " dydz = " << gv.y() / gv.z()
91  << std::endl;
92 }
93 
94 //__________________________________________________________________________________________________
96  Alignments* m_alignments = new Alignments();
98 
99  // Get position, rotation, detId
100  CLHEP::Hep3Vector clhepVector(globalPosition().x(), globalPosition().y(), globalPosition().z());
101  CLHEP::HepRotation clhepRotation(
102  CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
103  uint32_t detId = theId;
104 
105  AlignTransform transform(clhepVector, clhepRotation, detId);
106 
107  // Add to alignments container
108  m_alignments->m_align.push_back(transform);
109 
110  return m_alignments;
111 }
112 
113 //__________________________________________________________________________________________________
115  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
116 
117  // Add associated alignment position error
118  uint32_t detId = theId;
119  CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
120  if (theAlignmentPositionError) // Might not be set
122  AlignTransformErrorExtended transformError(clhepSymMatrix, detId);
123  m_alignmentErrors->m_alignError.push_back(transformError);
124 
125  return m_alignmentErrors;
126 }
127 
128 //______________________________________________________________________________
129 void AlignableBeamSpot::initialize(double x, double y, double z, double dxdz, double dydz) {
130  if (theInitializedFlag)
131  return;
132 
133  GlobalVector gv(x, y, z);
134  theSurface.move(gv);
135 
136  double angleY = std::atan(dxdz);
137  double angleX = -std::atan(dydz);
138 
139  align::RotationType rotY(std::cos(angleY), 0., -std::sin(angleY), 0., 1., 0., std::sin(angleY), 0., std::cos(angleY));
140 
141  align::RotationType rotX(1., 0., 0., 0., std::cos(angleX), std::sin(angleX), 0., -std::sin(angleX), std::cos(angleX));
142 
143  theSurface.rotate(rotY * rotX);
144 
145  this->dump();
146 
147  theInitializedFlag = true;
148 }
149 
150 //______________________________________________________________________________
152  Alignable::update(this->id(), AlignableSurface());
154  theAlignmentPositionError = nullptr;
155  theInitializedFlag = false;
156 }
157 
158 //______________________________________________________________________________
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
const AlgebraicSymMatrix66 & matrix() const
void initialize(double x, double y, double z, double dxdz, double dydz)
initialize the alignable with the passed beam spot parameters
float dydz
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:60
void update(align::ID, const AlignableSurface &)
Definition: Alignable.cc:45
void move(const GlobalVector &displacement) override
Move with respect to the global reference frame.
float dxdz
T z() const
Definition: PV3DBase.h:61
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void rotateInGlobalFrame(const RotationType &rotation) override
Rotation interpreted in global reference frame.
void move(const GlobalVector &displacement)
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
float float float z
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
void dump() const override
Recursive printout of alignable structure.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
~AlignableBeamSpot() override
Destructor.
void addSurfaceDeformation(const SurfaceDeformation *, bool) override
do no use, for compatibility only
void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool propagateDown) override
void addAlignmentPositionErrorFromLocalRotation(const RotationType &rotation, bool propagateDown) override
static const Alignables emptyComponents_
Log< level::Info, false > LogInfo
AlignmentErrorsExtended * alignmentErrors() const override
Return vector of alignment errors.
StructureType alignableObjectId() const override
Return the alignable type identifier.
static const DetId detId()
std::vector< AlignTransformErrorExtended > m_alignError
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:193
AlignmentPositionError * theAlignmentPositionError
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:141
const GlobalErrorExtended & globalError() const
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:190
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
void rotate(const RotationType &rotation)
void reset()
reset beam spot to the uninitialized state
void setSurfaceDeformation(const SurfaceDeformation *, bool) override
do no use, for compatibility only
float x
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
align::ID theId
Definition: Alignable.h:235
Alignments * alignments() const override
Return vector of alignment data.
AlignableSurface theSurface
Definition: Alignable.h:237
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:144
unsigned transform(const HcalDetId &id, unsigned transformCode)