CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Alignment/MuonAlignment/src/AlignableCSCRing.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/MuonAlignment/interface/AlignableCSCRing.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 
00013 
00015 AlignableCSCRing::AlignableCSCRing( const std::vector<AlignableCSCChamber*> cscChambers ) 
00016    : AlignableComposite(cscChambers[0]->id(), align::AlignableCSCRing)
00017 {
00018 
00019   theCSCChambers.insert( theCSCChambers.end(), cscChambers.begin(), cscChambers.end() );
00020 
00021   setSurface( computeSurface() );
00022    
00023 }
00024       
00025 
00027 AlignableCSCRing::~AlignableCSCRing() 
00028 {
00029   for ( std::vector<AlignableCSCChamber*>::iterator iter = theCSCChambers.begin(); 
00030         iter != theCSCChambers.end(); iter++)
00031     delete *iter;
00032 
00033 }
00034 
00036 AlignableCSCChamber &AlignableCSCRing::chamber(int i) 
00037 {
00038   
00039   if (i >= size() ) 
00040         throw cms::Exception("LogicError") << "CSC Chamber index (" << i << ") out of range";
00041 
00042   return *theCSCChambers[i];
00043   
00044 }
00045 
00046 
00049 AlignableSurface AlignableCSCRing::computeSurface()
00050 {
00051 
00052   return AlignableSurface( computePosition(), computeOrientation() );
00053 
00054 }
00055 
00056 
00057 
00059 AlignableCSCRing::PositionType AlignableCSCRing::computePosition()  
00060 {
00061 
00062   float zz = 0.;
00063 
00064   for ( std::vector<AlignableCSCChamber*>::iterator ichamber = theCSCChambers.begin();
00065                 ichamber != theCSCChambers.end(); ichamber++ )
00066     zz += (*ichamber)->globalPosition().z();
00067 
00068   zz /= static_cast<float>(theCSCChambers.size());
00069 
00070   return PositionType( 0.0, 0.0, zz );
00071 
00072 }
00073 
00074 
00076 AlignableCSCRing::RotationType AlignableCSCRing::computeOrientation() 
00077 {
00078   return RotationType();
00079 }
00080 
00081 
00082 // /// Twists all components by given angle
00083 // void AlignableCSCRing::twist(float rad) 
00084 // {
00085 //   for ( std::vector<AlignableCSCChamber*>::iterator iter = theCSCChambers.begin();
00086 //            iter != theCSCChambers.end(); iter++ )
00087 //         (*iter)->twist(rad);
00088 
00089 // }
00090 
00091 
00093 std::ostream &operator << (std::ostream& os, const AlignableCSCRing& b )
00094 {
00095 
00096   os << "This CSC Ring contains " << b.theCSCChambers.size() << " CSC chambers" << std::endl;
00097   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," 
00098      << b.globalPosition().perp() << "," << b.globalPosition().z();
00099   os << "),  orientation:" << std::endl<< b.globalRotation() << std::endl;
00100   return os;
00101 
00102 }
00103 
00104 
00106 void AlignableCSCRing::dump( void ) const
00107 {
00108 
00109   edm::LogInfo("AlignableDump") << (*this);
00110   for ( std::vector<AlignableCSCChamber*>::const_iterator iChamber = theCSCChambers.begin();
00111                 iChamber != theCSCChambers.end(); iChamber++ )
00112          edm::LogInfo("AlignableDump")  << (**iChamber);
00113 
00114 }