Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \file
0002  *
0003  *  $Date: 2008/04/10 16:36:41 $
0004  *  $Revision: 1.7 $
0005  *  \author Andre Sznajder - UERJ(Brazil)
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 /// The constructor simply copies the vector of wheels and computes the surface from them
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   // maintain also list of components
0021   for (const auto& wheel : dtWheels) {
0022     const auto mother = wheel->mother();
0023     this->addComponent(wheel);  // components will be deleted by dtor of AlignableComposite
0024     wheel->setMother(mother);   // restore previous behaviour where mother is not set
0025   }
0026 
0027   setSurface(computeSurface());
0028   compConstraintType_ = Alignable::CompConstraintType::POSITION_Z;
0029 }
0030 
0031 /// Return AlignableBarrelLayer at given index
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 /// Returns surface corresponding to current position
0040 /// and orientation, as given by average on all components
0041 AlignableSurface AlignableDTBarrel::computeSurface() {
0042   return AlignableSurface(computePosition(), computeOrientation());
0043 }
0044 
0045 /// Compute average z position from all components (x and y forced to 0)
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 /// Just initialize to default given by default constructor of a RotationType
0058 AlignableDTBarrel::RotationType AlignableDTBarrel::computeOrientation() { return RotationType(); }
0059 
0060 /// Output Half Barrel information
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 /// Recursive printout of whole Half Barrel structure
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   // Add components recursively
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   // sort by rawId
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   // Add components recursively
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   // sort by rawId
0106   std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end());
0107 
0108   return m_alignmentErrors;
0109 }