Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:21

0001 /** \file
0002  *
0003  *  $Date: 2008/04/10 16:36:41 $
0004  *  $Revision: 1.2 $
0005  *  \author Jim Pivarski - Texas A&M University
0006  */
0007 
0008 #include "Alignment/MuonAlignment/interface/AlignableCSCRing.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 /// The constructor simply copies the vector of CSC Chambers and computes the surface from them
0012 AlignableCSCRing::AlignableCSCRing(const std::vector<AlignableCSCChamber*>& cscChambers)
0013     : AlignableComposite(cscChambers[0]->id(), align::AlignableCSCRing) {
0014   theCSCChambers.insert(theCSCChambers.end(), cscChambers.begin(), cscChambers.end());
0015 
0016   // maintain also list of components
0017   for (const auto& chamber : cscChambers) {
0018     const auto mother = chamber->mother();
0019     this->addComponent(chamber);  // components will be deleted by dtor of AlignableComposite
0020     chamber->setMother(mother);   // restore previous behaviour where mother is not set
0021   }
0022 
0023   setSurface(computeSurface());
0024   compConstraintType_ = Alignable::CompConstraintType::POSITION_Z;
0025 }
0026 
0027 /// Return Alignable CSC Chamber at given index
0028 AlignableCSCChamber& AlignableCSCRing::chamber(int i) {
0029   if (i >= size())
0030     throw cms::Exception("LogicError") << "CSC Chamber index (" << i << ") out of range";
0031 
0032   return *theCSCChambers[i];
0033 }
0034 
0035 /// Returns surface corresponding to current position
0036 /// and orientation, as given by average on all components
0037 AlignableSurface AlignableCSCRing::computeSurface() {
0038   return AlignableSurface(computePosition(), computeOrientation());
0039 }
0040 
0041 /// Compute average z position from all components (x and y forced to 0)
0042 AlignableCSCRing::PositionType AlignableCSCRing::computePosition() {
0043   float zz = 0.;
0044 
0045   for (std::vector<AlignableCSCChamber*>::iterator ichamber = theCSCChambers.begin(); ichamber != theCSCChambers.end();
0046        ichamber++)
0047     zz += (*ichamber)->globalPosition().z();
0048 
0049   zz /= static_cast<float>(theCSCChambers.size());
0050 
0051   return PositionType(0.0, 0.0, zz);
0052 }
0053 
0054 /// Just initialize to default given by default constructor of a RotationType
0055 AlignableCSCRing::RotationType AlignableCSCRing::computeOrientation() { return RotationType(); }
0056 
0057 // /// Twists all components by given angle
0058 // void AlignableCSCRing::twist(float rad)
0059 // {
0060 //   for ( std::vector<AlignableCSCChamber*>::iterator iter = theCSCChambers.begin();
0061 //            iter != theCSCChambers.end(); iter++ )
0062 //         (*iter)->twist(rad);
0063 
0064 // }
0065 
0066 /// Output Ring information
0067 std::ostream& operator<<(std::ostream& os, const AlignableCSCRing& b) {
0068   os << "This CSC Ring contains " << b.theCSCChambers.size() << " CSC chambers" << std::endl;
0069   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << ","
0070      << b.globalPosition().z();
0071   os << "),  orientation:" << std::endl << b.globalRotation() << std::endl;
0072   return os;
0073 }
0074 
0075 /// Recursive printout of whole CSC Ring structure
0076 void AlignableCSCRing::dump(void) const {
0077   edm::LogInfo("AlignableDump") << (*this);
0078   for (std::vector<AlignableCSCChamber*>::const_iterator iChamber = theCSCChambers.begin();
0079        iChamber != theCSCChambers.end();
0080        iChamber++)
0081     edm::LogInfo("AlignableDump") << (**iChamber);
0082 }