CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/Alignment/MuonAlignment/src/AlignableCSCEndcap.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/MuonAlignment/interface/AlignableCSCEndcap.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 AlignableCSCEndcap::AlignableCSCEndcap( const std::vector<AlignableCSCStation*> cscStations ) 
00018    : AlignableComposite(cscStations[0]->id(), align::AlignableCSCEndcap)
00019 {
00020 
00021   theCSCStations.insert( theCSCStations.end(), cscStations.begin(), cscStations.end() );
00022 
00023   setSurface( computeSurface() );
00024    
00025 }
00026       
00027 
00029 AlignableCSCEndcap::~AlignableCSCEndcap() 
00030 {
00031   for ( std::vector<AlignableCSCStation*>::iterator iter = theCSCStations.begin(); 
00032         iter != theCSCStations.end(); iter++)
00033     delete *iter;
00034 
00035 }
00036 
00038 AlignableCSCStation &AlignableCSCEndcap::station(int i) 
00039 {
00040   
00041   if (i >= size() ) 
00042         throw cms::Exception("LogicError") << "Station index (" << i << ") out of range";
00043 
00044   return *theCSCStations[i];
00045   
00046 }
00047 
00048 
00051 AlignableSurface AlignableCSCEndcap::computeSurface()
00052 {
00053 
00054   return AlignableSurface( computePosition(), computeOrientation() );
00055 
00056 }
00057 
00058 
00059 
00061 AlignableCSCEndcap::PositionType AlignableCSCEndcap::computePosition() 
00062 {
00063 
00064   float zz = 0.;
00065 
00066   for ( std::vector<AlignableCSCStation*>::iterator ilayer = theCSCStations.begin();
00067                 ilayer != theCSCStations.end(); ilayer++ )
00068     zz += (*ilayer)->globalPosition().z();
00069 
00070   zz /= static_cast<float>(theCSCStations.size());
00071 
00072   return PositionType( 0.0, 0.0, zz );
00073 
00074 }
00075 
00076 
00078 AlignableCSCEndcap::RotationType AlignableCSCEndcap::computeOrientation() 
00079 {
00080   return RotationType();
00081 }
00082 
00083 
00085 std::ostream &operator << (std::ostream& os, const AlignableCSCEndcap& b )
00086 {
00087 
00088   os << "This EndCap contains " << b.theCSCStations.size() << " CSC stations" << std::endl;
00089   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," 
00090      << b.globalPosition().perp() << "," << b.globalPosition().z();
00091   os << "),  orientation:" << std::endl<< b.globalRotation() << std::endl;
00092   return os;
00093 
00094 }
00095 
00096 
00098 void AlignableCSCEndcap::dump( void ) const
00099 {
00100 
00101   edm::LogInfo("AlignableDump") << (*this);
00102   for ( std::vector<AlignableCSCStation*>::const_iterator iLayer = theCSCStations.begin();
00103                 iLayer != theCSCStations.end(); iLayer++ )
00104         (*iLayer)->dump();
00105 
00106 }
00107 
00108 //__________________________________________________________________________________________________
00109 
00110 Alignments* AlignableCSCEndcap::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 
00133 AlignmentErrors* AlignableCSCEndcap::alignmentErrors( void ) const
00134 {
00135 
00136   std::vector<Alignable*> comp = this->components();
00137   AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
00138 
00139   // Add components recursively
00140   for ( std::vector<Alignable*>::iterator i=comp.begin(); i!=comp.end(); i++ )
00141     {
00142           AlignmentErrors* tmpAlignmentErrors = (*i)->alignmentErrors();
00143       std::copy( tmpAlignmentErrors->m_alignError.begin(), tmpAlignmentErrors->m_alignError.end(), 
00144                                  std::back_inserter(m_alignmentErrors->m_alignError) );
00145           delete tmpAlignmentErrors;
00146     }
00147 
00148   std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(), 
00149                          lessAlignmentDetId<AlignTransformError>() );
00150 
00151   return m_alignmentErrors;
00152 
00153 }
00154