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