CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Alignment/MuonAlignment/src/AlignableDTBarrel.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/MuonAlignment/interface/AlignableDTBarrel.h"
00010 #include "CondFormats/Alignment/interface/Alignments.h" 
00011 #include "CondFormats/Alignment/interface/AlignmentErrors.h" 
00012 #include "CondFormats/Alignment/interface/AlignmentSorter.h" 
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 
00015 
00017 AlignableDTBarrel::AlignableDTBarrel( const std::vector<AlignableDTWheel*> dtWheels ) 
00018    : AlignableComposite(dtWheels[0]->id(), align::AlignableDTBarrel)
00019 {
00020 
00021   theDTWheels.insert( theDTWheels.end(), dtWheels.begin(), dtWheels.end() );
00022 
00023   setSurface( computeSurface() );
00024    
00025 }
00026       
00027 
00029 AlignableDTBarrel::~AlignableDTBarrel() 
00030 {
00031   for ( std::vector<AlignableDTWheel*>::iterator iter = theDTWheels.begin(); 
00032         iter != theDTWheels.end(); iter++)
00033     delete *iter;
00034 
00035 }
00036 
00038 AlignableDTWheel &AlignableDTBarrel::wheel(int i) 
00039 {
00040   
00041   if (i >= size() ) 
00042         throw cms::Exception("LogicError") << "Wheel index (" << i << ") out of range";
00043 
00044   return *theDTWheels[i];
00045   
00046 }
00047 
00048 
00051 AlignableSurface AlignableDTBarrel::computeSurface()
00052 {
00053 
00054   return AlignableSurface( computePosition(), computeOrientation() );
00055 
00056 }
00057 
00058 
00059 
00061 AlignableDTBarrel::PositionType AlignableDTBarrel::computePosition() 
00062 {
00063 
00064   float zz = 0.;
00065 
00066   for ( std::vector<AlignableDTWheel*>::iterator ilayer = theDTWheels.begin();
00067                 ilayer != theDTWheels.end(); ilayer++ )
00068     zz += (*ilayer)->globalPosition().z();
00069 
00070   zz /= static_cast<float>(theDTWheels.size());
00071 
00072   return PositionType( 0.0, 0.0, zz );
00073 
00074 }
00075 
00076 
00078 AlignableDTBarrel::RotationType AlignableDTBarrel::computeOrientation() 
00079 {
00080   return RotationType();
00081 }
00082 
00083 
00084 
00086 std::ostream &operator << (std::ostream& os, const AlignableDTBarrel& b )
00087 {
00088 
00089   os << "This DTBarrel contains " << b.theDTWheels.size() << " Barrel wheels" << std::endl;
00090   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," 
00091      << b.globalPosition().perp() << "," << b.globalPosition().z();
00092   os << "),  orientation:" << std::endl<< b.globalRotation() << std::endl;
00093   return os;
00094 
00095 }
00096 
00097 
00099 void AlignableDTBarrel::dump( void ) const
00100 {
00101 
00102   edm::LogInfo("AlignableDump") << (*this);
00103   for ( std::vector<AlignableDTWheel*>::const_iterator iWheel = theDTWheels.begin();
00104                 iWheel != theDTWheels.end(); iWheel++ )
00105         (*iWheel)->dump();
00106 
00107 }
00108 
00109 //__________________________________________________________________________________________________
00110 Alignments* AlignableDTBarrel::alignments( void ) const
00111 {
00112 
00113   std::vector<Alignable*> comp = this->components();
00114   Alignments* m_alignments = new Alignments();
00115   // Add components recursively
00116   for ( std::vector<Alignable*>::iterator i=comp.begin(); i!=comp.end(); i++ )
00117     {
00118       Alignments* tmpAlignments = (*i)->alignments();
00119       std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), 
00120                                  std::back_inserter(m_alignments->m_align) );
00121           delete tmpAlignments;
00122     }
00123 
00124   std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(), 
00125                          lessAlignmentDetId<AlignTransform>() );
00126 
00127   return m_alignments;
00128 
00129 }
00130 
00131 //__________________________________________________________________________________________________
00132 AlignmentErrors* AlignableDTBarrel::alignmentErrors( void ) const
00133 {
00134 
00135   std::vector<Alignable*> comp = this->components();
00136   AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
00137 
00138   // Add components recursively
00139   for ( std::vector<Alignable*>::iterator i=comp.begin(); i!=comp.end(); i++ )
00140     {
00141           AlignmentErrors* tmpAlignmentErrors = (*i)->alignmentErrors();
00142       std::copy( tmpAlignmentErrors->m_alignError.begin(), tmpAlignmentErrors->m_alignError.end(), 
00143                                  std::back_inserter(m_alignmentErrors->m_alignError) );
00144           delete tmpAlignmentErrors;
00145     }
00146 
00147   std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(), 
00148                          lessAlignmentDetId<AlignTransformError>() );
00149 
00150   return m_alignmentErrors;
00151 
00152 }
00153 
00154