File indexing completed on 2024-04-06 11:56:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "Alignment/CommonAlignment/interface/AlignableDetUnit.h"
0011 #include "CondFormats/Alignment/interface/Alignments.h"
0012 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0013 #include "CLHEP/Vector/RotationInterfaces.h"
0014 #include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h"
0015 #include "Alignment/CommonAlignment/interface/AlignableBeamSpot.h"
0016
0017 #include "FWCore/Utilities/interface/Exception.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020
0021 AlignableBeamSpot::AlignableBeamSpot()
0022 : Alignable(AlignableBeamSpot::detId().rawId(), AlignableSurface()),
0023 theAlignmentPositionError(nullptr),
0024 theInitializedFlag(false) {}
0025
0026
0027 AlignableBeamSpot::~AlignableBeamSpot() { delete theAlignmentPositionError; }
0028
0029
0030 void AlignableBeamSpot::move(const GlobalVector& displacement) {
0031 theSurface.move(displacement);
0032 this->addDisplacement(displacement);
0033 }
0034
0035
0036 void AlignableBeamSpot::rotateInGlobalFrame(const RotationType& rotation) {
0037 theSurface.rotate(rotation);
0038 this->addRotation(rotation);
0039 }
0040
0041
0042 void AlignableBeamSpot::setAlignmentPositionError(const AlignmentPositionError& ape, bool propagateDown) {
0043 if (!theAlignmentPositionError)
0044 theAlignmentPositionError = new AlignmentPositionError(ape);
0045 else
0046 *theAlignmentPositionError = ape;
0047 }
0048
0049
0050 void AlignableBeamSpot::addAlignmentPositionError(const AlignmentPositionError& ape, bool propagateDown) {
0051 if (!theAlignmentPositionError) {
0052 theAlignmentPositionError = new AlignmentPositionError(ape);
0053 } else {
0054 *theAlignmentPositionError += ape;
0055 }
0056 }
0057
0058
0059 void AlignableBeamSpot::addAlignmentPositionErrorFromRotation(const RotationType& rot, bool propagateDown) {}
0060
0061
0062
0063
0064
0065 void AlignableBeamSpot::addAlignmentPositionErrorFromLocalRotation(const RotationType& rot, bool propagateDown) {}
0066
0067
0068 void AlignableBeamSpot::setSurfaceDeformation(const SurfaceDeformation*, bool) {
0069 edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::setSurfaceDeformation"
0070 << "Useless method for beam spot, do nothing.";
0071 }
0072
0073
0074 void AlignableBeamSpot::addSurfaceDeformation(const SurfaceDeformation*, bool) {
0075 edm::LogInfo("Alignment") << "@SUB=AlignableBeamSpot::addSurfaceDeformation"
0076 << "Useless method for beam spot, do nothing.";
0077 }
0078
0079
0080 void AlignableBeamSpot::dump(void) const {
0081
0082
0083 LocalVector lv(0.0, 0.0, 1.0);
0084 GlobalVector gv = theSurface.toGlobal(lv);
0085
0086 edm::LogInfo("AlignableDump") << " Alignable of type " << this->alignableObjectId() << " has 0 components"
0087 << std::endl
0088 << " position = " << this->globalPosition() << ", orientation:" << std::endl
0089 << std::flush << this->globalRotation() << std::endl
0090 << std::flush << " dxdz = " << gv.x() / gv.z() << " dydz = " << gv.y() / gv.z()
0091 << std::endl;
0092 }
0093
0094
0095 Alignments* AlignableBeamSpot::alignments() const {
0096 Alignments* m_alignments = new Alignments();
0097 RotationType rot(this->globalRotation());
0098
0099
0100 CLHEP::Hep3Vector clhepVector(globalPosition().x(), globalPosition().y(), globalPosition().z());
0101 CLHEP::HepRotation clhepRotation(
0102 CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
0103 uint32_t detId = theId;
0104
0105 AlignTransform transform(clhepVector, clhepRotation, detId);
0106
0107
0108 m_alignments->m_align.push_back(transform);
0109
0110 return m_alignments;
0111 }
0112
0113
0114 AlignmentErrorsExtended* AlignableBeamSpot::alignmentErrors(void) const {
0115 AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
0116
0117
0118 uint32_t detId = theId;
0119 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
0120 if (theAlignmentPositionError)
0121 clhepSymMatrix = asHepMatrix(theAlignmentPositionError->globalError().matrix());
0122 AlignTransformErrorExtended transformError(clhepSymMatrix, detId);
0123 m_alignmentErrors->m_alignError.push_back(transformError);
0124
0125 return m_alignmentErrors;
0126 }
0127
0128
0129 void AlignableBeamSpot::initialize(double x, double y, double z, double dxdz, double dydz) {
0130 if (theInitializedFlag)
0131 return;
0132
0133 GlobalVector gv(x, y, z);
0134 theSurface.move(gv);
0135
0136 double angleY = std::atan(dxdz);
0137 double angleX = -std::atan(dydz);
0138
0139 align::RotationType rotY(std::cos(angleY), 0., -std::sin(angleY), 0., 1., 0., std::sin(angleY), 0., std::cos(angleY));
0140
0141 align::RotationType rotX(1., 0., 0., 0., std::cos(angleX), std::sin(angleX), 0., -std::sin(angleX), std::cos(angleX));
0142
0143 theSurface.rotate(rotY * rotX);
0144
0145 this->dump();
0146
0147 theInitializedFlag = true;
0148 }
0149
0150
0151 void AlignableBeamSpot::reset() {
0152 Alignable::update(this->id(), AlignableSurface());
0153 delete theAlignmentPositionError;
0154 theAlignmentPositionError = nullptr;
0155 theInitializedFlag = false;
0156 }
0157
0158
0159 const align::Alignables AlignableBeamSpot::emptyComponents_{};