Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:41

0001 /* AlignableGEMEndcap
0002  * \author Hyunyong Kim - TAMU
0003  */
0004 #include <memory>
0005 
0006 #include "Alignment/MuonAlignment/interface/AlignableGEMEndcap.h"
0007 #include "CondFormats/Alignment/interface/Alignments.h"
0008 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 AlignableGEMEndcap::AlignableGEMEndcap(const std::vector<AlignableGEMStation*>& GEMStations)
0012     : AlignableComposite(GEMStations[0]->id(), align::AlignableGEMEndcap) {
0013   theGEMStations.insert(theGEMStations.end(), GEMStations.begin(), GEMStations.end());
0014 
0015   for (const auto& station : GEMStations) {
0016     const auto mother = station->mother();
0017     this->addComponent(station);
0018     station->setMother(mother);
0019   }
0020 
0021   setSurface(computeSurface());
0022   compConstraintType_ = Alignable::CompConstraintType::POSITION_Z;
0023 }
0024 
0025 AlignableGEMStation& AlignableGEMEndcap::station(int i) {
0026   if (i >= size())
0027     throw cms::Exception("LogicError") << "Station index (" << i << ") out of range";
0028 
0029   return *theGEMStations[i];
0030 }
0031 
0032 AlignableSurface AlignableGEMEndcap::computeSurface() {
0033   return AlignableSurface(computePosition(), computeOrientation());
0034 }
0035 
0036 AlignableGEMEndcap::PositionType AlignableGEMEndcap::computePosition() {
0037   float zz = 0.;
0038 
0039   for (std::vector<AlignableGEMStation*>::iterator ilayer = theGEMStations.begin(); ilayer != theGEMStations.end();
0040        ilayer++)
0041     zz += (*ilayer)->globalPosition().z();
0042 
0043   zz /= static_cast<float>(theGEMStations.size());
0044 
0045   return PositionType(0.0, 0.0, zz);
0046 }
0047 
0048 AlignableGEMEndcap::RotationType AlignableGEMEndcap::computeOrientation() { return RotationType(); }
0049 
0050 std::ostream& operator<<(std::ostream& os, const AlignableGEMEndcap& b) {
0051   os << "This EndCap contains " << b.theGEMStations.size() << " GEM stations" << std::endl;
0052   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << ","
0053      << b.globalPosition().z();
0054   os << "),  orientation:" << std::endl << b.globalRotation() << std::endl;
0055   return os;
0056 }
0057 
0058 void AlignableGEMEndcap::dump(void) const {
0059   edm::LogInfo("AlignableDump") << (*this);
0060   for (std::vector<AlignableGEMStation*>::const_iterator iLayer = theGEMStations.begin();
0061        iLayer != theGEMStations.end();
0062        iLayer++)
0063     (*iLayer)->dump();
0064 }
0065 
0066 Alignments* AlignableGEMEndcap::alignments(void) const {
0067   Alignments* m_alignments = new Alignments();
0068 
0069   for (const auto& i : this->components()) {
0070     std::unique_ptr<Alignments> tmpAlignments{i->alignments()};
0071     std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
0072   }
0073 
0074   std::sort(m_alignments->m_align.begin(), m_alignments->m_align.end());
0075 
0076   return m_alignments;
0077 }
0078 
0079 AlignmentErrorsExtended* AlignableGEMEndcap::alignmentErrors(void) const {
0080   AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
0081 
0082   for (const auto& i : this->components()) {
0083     std::unique_ptr<AlignmentErrorsExtended> tmpAlignmentErrorsExtended{i->alignmentErrors()};
0084     std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(),
0085               tmpAlignmentErrorsExtended->m_alignError.end(),
0086               std::back_inserter(m_alignmentErrors->m_alignError));
0087   }
0088 
0089   std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end());
0090 
0091   return m_alignmentErrors;
0092 }