File indexing completed on 2024-04-06 11:56:40
0001
0002
0003
0004
0005
0006
0007
0008 #include <memory>
0009
0010 #include "Alignment/MuonAlignment/interface/AlignableDTBarrel.h"
0011 #include "CondFormats/Alignment/interface/Alignments.h"
0012 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015
0016 AlignableDTBarrel::AlignableDTBarrel(const std::vector<AlignableDTWheel*>& dtWheels)
0017 : AlignableComposite(dtWheels[0]->id(), align::AlignableDTBarrel) {
0018 theDTWheels.insert(theDTWheels.end(), dtWheels.begin(), dtWheels.end());
0019
0020
0021 for (const auto& wheel : dtWheels) {
0022 const auto mother = wheel->mother();
0023 this->addComponent(wheel);
0024 wheel->setMother(mother);
0025 }
0026
0027 setSurface(computeSurface());
0028 compConstraintType_ = Alignable::CompConstraintType::POSITION_Z;
0029 }
0030
0031
0032 AlignableDTWheel& AlignableDTBarrel::wheel(int i) {
0033 if (i >= size())
0034 throw cms::Exception("LogicError") << "Wheel index (" << i << ") out of range";
0035
0036 return *theDTWheels[i];
0037 }
0038
0039
0040
0041 AlignableSurface AlignableDTBarrel::computeSurface() {
0042 return AlignableSurface(computePosition(), computeOrientation());
0043 }
0044
0045
0046 AlignableDTBarrel::PositionType AlignableDTBarrel::computePosition() {
0047 float zz = 0.;
0048
0049 for (std::vector<AlignableDTWheel*>::iterator ilayer = theDTWheels.begin(); ilayer != theDTWheels.end(); ilayer++)
0050 zz += (*ilayer)->globalPosition().z();
0051
0052 zz /= static_cast<float>(theDTWheels.size());
0053
0054 return PositionType(0.0, 0.0, zz);
0055 }
0056
0057
0058 AlignableDTBarrel::RotationType AlignableDTBarrel::computeOrientation() { return RotationType(); }
0059
0060
0061 std::ostream& operator<<(std::ostream& os, const AlignableDTBarrel& b) {
0062 os << "This DTBarrel contains " << b.theDTWheels.size() << " Barrel wheels" << std::endl;
0063 os << "(phi, r, z) = (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << ","
0064 << b.globalPosition().z();
0065 os << "), orientation:" << std::endl << b.globalRotation() << std::endl;
0066 return os;
0067 }
0068
0069
0070 void AlignableDTBarrel::dump(void) const {
0071 edm::LogInfo("AlignableDump") << (*this);
0072 for (std::vector<AlignableDTWheel*>::const_iterator iWheel = theDTWheels.begin(); iWheel != theDTWheels.end();
0073 iWheel++)
0074 (*iWheel)->dump();
0075 }
0076
0077
0078 Alignments* AlignableDTBarrel::alignments(void) const {
0079 Alignments* m_alignments = new Alignments();
0080
0081
0082 for (const auto& i : this->components()) {
0083 std::unique_ptr<Alignments> tmpAlignments{i->alignments()};
0084 std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
0085 }
0086
0087
0088 std::sort(m_alignments->m_align.begin(), m_alignments->m_align.end());
0089
0090 return m_alignments;
0091 }
0092
0093
0094 AlignmentErrorsExtended* AlignableDTBarrel::alignmentErrors(void) const {
0095 AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
0096
0097
0098 for (const auto& i : this->components()) {
0099 std::unique_ptr<AlignmentErrorsExtended> tmpAlignmentErrorsExtended{i->alignmentErrors()};
0100 std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(),
0101 tmpAlignmentErrorsExtended->m_alignError.end(),
0102 std::back_inserter(m_alignmentErrors->m_alignError));
0103 }
0104
0105
0106 std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end());
0107
0108 return m_alignmentErrors;
0109 }