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