CMS 3D CMS Logo

Public Member Functions | Private Attributes

AlignableDet Class Reference

#include <AlignableDet.h>

Inheritance diagram for AlignableDet:
AlignableComposite Alignable AlignableCSCChamber AlignableDTChamber AlignableDTSuperLayer AlignableSiStripDet

List of all members.

Public Member Functions

virtual void addAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown)
virtual void addAlignmentPositionErrorFromRotation (const RotationType &rot, bool propagateDown)
 AlignableDet (const GeomDet *geomDet, bool addComponents=true)
virtual AlignmentErrorsalignmentErrors () const
 Return vector of alignment errors.
const AlignmentPositionErroralignmentPositionError () const
 alignment position error - for checking only, otherwise use alignmentErrors() above!
virtual Alignmentsalignments () const
 Return vector of alignment data.
virtual void setAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown)
 Set the AlignmentPositionError and, if (propagateDown), to all components.
virtual ~AlignableDet ()
 Destructor.

Private Attributes

AlignmentPositionErrortheAlignmentPositionError

Detailed Description

An AlignableComposite corresponding to a composite GeomDet direct components are AlignableDetUnits or AlignableDets.

Definition at line 8 of file AlignableDet.h.


Constructor & Destructor Documentation

AlignableDet::AlignableDet ( const GeomDet geomDet,
bool  addComponents = true 
)

Constructor: If addComponents = true, creates components for geomDet's components, assuming they are GeomDetUnits

Definition at line 16 of file AlignableDet.cc.

References AlignableComposite::addComponent(), align::AlignableDetUnit, GeomDet::alignmentPositionError(), GeomDet::components(), Exception, GeomDet::geographicalId(), DetId::rawId(), setAlignmentPositionError(), GeomDet::surface(), Alignable::theSurface, and csvLumiCalc::unit.

                                                                       : 
  AlignableComposite( geomDet ), 
  theAlignmentPositionError(0)
{
  if (geomDet->alignmentPositionError()) {
    // false: do not propagate APE to (anyway not yet existing) daughters
    this->setAlignmentPositionError(*(geomDet->alignmentPositionError()), false); 
  }

  if (addComponents) {
    if ( geomDet->components().size() == 0 ) { // Is a DetUnit
      throw cms::Exception("BadHierarchy") << "[AlignableDet] GeomDet with DetId " 
                                           << geomDet->geographicalId().rawId() 
                                           << " has no components, use AlignableDetUnit.\n";
    } else { // Push back all components
      const std::vector<const GeomDet*>& geomDets = geomDet->components();
      for (std::vector<const GeomDet*>::const_iterator idet = geomDets.begin(); 
            idet != geomDets.end(); ++idet) {
        const GeomDetUnit *unit = dynamic_cast<const GeomDetUnit*>(*idet);
        if (!unit) {
          throw cms::Exception("BadHierarchy") 
            << "[AlignableDet] component not GeomDetUnit, call with addComponents==false" 
            << " and build hierarchy yourself.\n";  // e.g. AlignableDTChamber
        }
        this->addComponent(new AlignableDetUnit(unit));
      }
    }
    // Ensure that the surface is not screwed up by addComponent, it must stay the GeomDet's one:
    theSurface = AlignableSurface(geomDet->surface());
  } // end addComponents  
}
AlignableDet::~AlignableDet ( ) [virtual]

Destructor.

Definition at line 50 of file AlignableDet.cc.

References theAlignmentPositionError.


Member Function Documentation

void AlignableDet::addAlignmentPositionError ( const AlignmentPositionError ape,
bool  propagateDown 
) [virtual]

Add (or set if it does not exist yet) the AlignmentPositionError, if (propagateDown), add also to all components

Reimplemented from AlignableComposite.

Definition at line 73 of file AlignableDet.cc.

References theAlignmentPositionError.

Referenced by addAlignmentPositionErrorFromRotation().

void AlignableDet::addAlignmentPositionErrorFromRotation ( const RotationType rot,
bool  propagateDown 
) [virtual]

Add (or set if it does not exist yet) the AlignmentPositionError resulting from a rotation in the global reference frame, if (propagateDown), add also to all components

Reimplemented from AlignableComposite.

Definition at line 87 of file AlignableDet.cc.

References addAlignmentPositionError(), PV3DBase< T, PVType, FrameType >::basicVector(), TkRotation< T >::multiplyInverse(), Alignable::surface(), AlignableSurface::toGlobal(), and tablePrinter::width.

{

  // average error calculated by movement of a local point at
  // (xWidth/2,yLength/2,0) caused by the rotation rot
  GlobalVector localPositionVector = surface().toGlobal( LocalVector(.5 * surface().width(), .5 * surface().length(), 0.) );

  LocalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
  GlobalVector gv( rot.multiplyInverse(lpvgf) - lpvgf );

  AlignmentPositionError  ape( gv.x(),gv.y(),gv.z() );
  this->addAlignmentPositionError( ape, propagateDown );

  this->AlignableComposite::addAlignmentPositionErrorFromRotation( rot, propagateDown );

}
AlignmentErrors * AlignableDet::alignmentErrors ( void  ) const [virtual]

Return vector of alignment errors.

Reimplemented from AlignableComposite.

Definition at line 135 of file AlignableDet.cc.

References asHepMatrix(), filterCSVwithJSON::copy, Alignable::geomDetId(), AlignmentPositionError::globalError(), AlignmentErrors::m_alignError, GlobalErrorBase< T, ErrorWeightType >::matrix(), DetId::rawId(), and theAlignmentPositionError.

{

  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();

  // Add associated alignment position error
  uint32_t detId = this->geomDetId().rawId();
  CLHEP::HepSymMatrix clhepSymMatrix(3,0);
  if ( theAlignmentPositionError ) // Might not be set
    clhepSymMatrix= asHepMatrix(theAlignmentPositionError->globalError().matrix());
  AlignTransformError transformError( clhepSymMatrix, detId );
  m_alignmentErrors->m_alignError.push_back( transformError );

  // Add those from components
  AlignmentErrors *compAlignmentErrs = this->AlignableComposite::alignmentErrors();
  std::copy(compAlignmentErrs->m_alignError.begin(), compAlignmentErrs->m_alignError.end(),
            std::back_inserter(m_alignmentErrors->m_alignError));
  delete compAlignmentErrs;
  

  return m_alignmentErrors;
}
const AlignmentPositionError* AlignableDet::alignmentPositionError ( ) const [inline]

alignment position error - for checking only, otherwise use alignmentErrors() above!

Definition at line 43 of file AlignableDet.h.

References theAlignmentPositionError.

Referenced by AlignableDetOrUnitPtr::alignmentPositionError().

Alignments * AlignableDet::alignments ( void  ) const [virtual]

Return vector of alignment data.

Reimplemented from AlignableComposite.

Reimplemented in AlignableSiStripDet.

Definition at line 106 of file AlignableDet.cc.

References filterCSVwithJSON::copy, Alignable::geomDetId(), Alignable::globalPosition(), Alignable::globalRotation(), Alignments::m_align, DetId::rawId(), makeMuonMisalignmentScenario::rot, create_public_pileup_plots::transform, x, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), detailsBasic3DVector::y, TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), z, TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

{

  Alignments* m_alignments = new Alignments();
  RotationType rot( this->globalRotation() );

  // Get position, rotation, detId
  CLHEP::Hep3Vector clhepVector( globalPosition().x(), globalPosition().y(), globalPosition().z() );
  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
                                        rot.yx(), rot.yy(), rot.yz(),
                                        rot.zx(), rot.zy(), rot.zz() ) );
  uint32_t detId = this->geomDetId().rawId();
  
  AlignTransform transform( clhepVector, clhepRotation, detId );
  
  // Add to alignments container
  m_alignments->m_align.push_back( transform );

  // Add those from components
  Alignments *compAlignments = this->AlignableComposite::alignments();
  std::copy(compAlignments->m_align.begin(), compAlignments->m_align.end(), 
            std::back_inserter(m_alignments->m_align));
  delete compAlignments;


  return m_alignments;
}
void AlignableDet::setAlignmentPositionError ( const AlignmentPositionError ape,
bool  propagateDown 
) [virtual]

Set the AlignmentPositionError and, if (propagateDown), to all components.

Reimplemented from AlignableComposite.

Definition at line 59 of file AlignableDet.cc.

References theAlignmentPositionError.

Referenced by AlignableDet().


Member Data Documentation