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/AlignableCSCEndcap.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 AlignableCSCEndcap::AlignableCSCEndcap(const std::vector<AlignableCSCStation*>& cscStations)
0017 : AlignableComposite(cscStations[0]->id(), align::AlignableCSCEndcap) {
0018 theCSCStations.insert(theCSCStations.end(), cscStations.begin(), cscStations.end());
0019
0020
0021 for (const auto& station : cscStations) {
0022 const auto mother = station->mother();
0023 this->addComponent(station);
0024 station->setMother(mother);
0025 }
0026
0027 setSurface(computeSurface());
0028 compConstraintType_ = Alignable::CompConstraintType::POSITION_Z;
0029 }
0030
0031
0032 AlignableCSCStation& AlignableCSCEndcap::station(int i) {
0033 if (i >= size())
0034 throw cms::Exception("LogicError") << "Station index (" << i << ") out of range";
0035
0036 return *theCSCStations[i];
0037 }
0038
0039
0040
0041 AlignableSurface AlignableCSCEndcap::computeSurface() {
0042 return AlignableSurface(computePosition(), computeOrientation());
0043 }
0044
0045
0046 AlignableCSCEndcap::PositionType AlignableCSCEndcap::computePosition() {
0047 float zz = 0.;
0048
0049 for (std::vector<AlignableCSCStation*>::iterator ilayer = theCSCStations.begin(); ilayer != theCSCStations.end();
0050 ilayer++)
0051 zz += (*ilayer)->globalPosition().z();
0052
0053 zz /= static_cast<float>(theCSCStations.size());
0054
0055 return PositionType(0.0, 0.0, zz);
0056 }
0057
0058
0059 AlignableCSCEndcap::RotationType AlignableCSCEndcap::computeOrientation() { return RotationType(); }
0060
0061
0062 std::ostream& operator<<(std::ostream& os, const AlignableCSCEndcap& b) {
0063 os << "This EndCap contains " << b.theCSCStations.size() << " CSC stations" << std::endl;
0064 os << "(phi, r, z) = (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << ","
0065 << b.globalPosition().z();
0066 os << "), orientation:" << std::endl << b.globalRotation() << std::endl;
0067 return os;
0068 }
0069
0070
0071 void AlignableCSCEndcap::dump(void) const {
0072 edm::LogInfo("AlignableDump") << (*this);
0073 for (std::vector<AlignableCSCStation*>::const_iterator iLayer = theCSCStations.begin();
0074 iLayer != theCSCStations.end();
0075 iLayer++)
0076 (*iLayer)->dump();
0077 }
0078
0079
0080
0081 Alignments* AlignableCSCEndcap::alignments(void) const {
0082 Alignments* m_alignments = new Alignments();
0083
0084
0085 for (const auto& i : this->components()) {
0086 std::unique_ptr<Alignments> tmpAlignments{i->alignments()};
0087 std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
0088 }
0089
0090
0091 std::sort(m_alignments->m_align.begin(), m_alignments->m_align.end());
0092
0093 return m_alignments;
0094 }
0095
0096
0097
0098 AlignmentErrorsExtended* AlignableCSCEndcap::alignmentErrors(void) const {
0099 AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
0100
0101
0102 for (const auto& i : this->components()) {
0103 std::unique_ptr<AlignmentErrorsExtended> tmpAlignmentErrorsExtended{i->alignmentErrors()};
0104 std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(),
0105 tmpAlignmentErrorsExtended->m_alignError.end(),
0106 std::back_inserter(m_alignmentErrors->m_alignError));
0107 }
0108
0109
0110 std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end());
0111
0112 return m_alignmentErrors;
0113 }