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.6 $
0005  *  \author Andre Sznajder - UERJ(Brazil)
0006  */
0007 
0008 #include "Alignment/MuonAlignment/interface/AlignableCSCStation.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 /// The constructor simply copies the vector of CSC Rings and computes the surface from them
0012 AlignableCSCStation::AlignableCSCStation(const std::vector<AlignableCSCRing*>& cscRings)
0013     : AlignableComposite(cscRings[0]->id(), align::AlignableCSCStation) {
0014   theCSCRings.insert(theCSCRings.end(), cscRings.begin(), cscRings.end());
0015 
0016   // maintain also list of components
0017   for (const auto& ring : cscRings) {
0018     const auto mother = ring->mother();
0019     this->addComponent(ring);  // components will be deleted by dtor of AlignableComposite
0020     ring->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 Ring at given index
0028 AlignableCSCRing& AlignableCSCStation::ring(int i) {
0029   if (i >= size())
0030     throw cms::Exception("LogicError") << "CSC Ring index (" << i << ") out of range";
0031 
0032   return *theCSCRings[i];
0033 }
0034 
0035 /// Returns surface corresponding to current position
0036 /// and orientation, as given by average on all components
0037 AlignableSurface AlignableCSCStation::computeSurface() {
0038   return AlignableSurface(computePosition(), computeOrientation());
0039 }
0040 
0041 /// Compute average z position from all components (x and y forced to 0)
0042 AlignableCSCStation::PositionType AlignableCSCStation::computePosition() {
0043   float zz = 0.;
0044 
0045   for (std::vector<AlignableCSCRing*>::iterator ilayer = theCSCRings.begin(); ilayer != theCSCRings.end(); ilayer++)
0046     zz += (*ilayer)->globalPosition().z();
0047 
0048   zz /= static_cast<float>(theCSCRings.size());
0049 
0050   return PositionType(0.0, 0.0, zz);
0051 }
0052 
0053 /// Just initialize to default given by default constructor of a RotationType
0054 AlignableCSCStation::RotationType AlignableCSCStation::computeOrientation() { return RotationType(); }
0055 
0056 // /// Twists all components by given angle
0057 // void AlignableCSCStation::twist(float rad)
0058 // {
0059 //   for ( std::vector<AlignableCSCRing*>::iterator iter = theCSCRings.begin();
0060 //            iter != theCSCRings.end(); iter++ )
0061 //         (*iter)->twist(rad);
0062 
0063 // }
0064 
0065 /// Output Station information
0066 std::ostream& operator<<(std::ostream& os, const AlignableCSCStation& b) {
0067   os << "This CSC Station contains " << b.theCSCRings.size() << " CSC rings" << std::endl;
0068   os << "(phi, r, z) =  (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << ","
0069      << b.globalPosition().z();
0070   os << "),  orientation:" << std::endl << b.globalRotation() << std::endl;
0071   return os;
0072 }
0073 
0074 /// Recursive printout of whole CSC Station structure
0075 void AlignableCSCStation::dump(void) const {
0076   edm::LogInfo("AlignableDump") << (*this);
0077   for (std::vector<AlignableCSCRing*>::const_iterator iRing = theCSCRings.begin(); iRing != theCSCRings.end(); iRing++)
0078     edm::LogInfo("AlignableDump") << (**iRing);
0079 }