CMS 3D CMS Logo

Public Member Functions | Private Attributes

AlignableDetUnit Class Reference

#include <AlignableDetUnit.h>

Inheritance diagram for AlignableDetUnit:
Alignable

List of all members.

Public Member Functions

virtual void addAlignmentPositionError (const AlignmentPositionError &ape, bool)
virtual void addAlignmentPositionErrorFromLocalRotation (const RotationType &rot, bool)
virtual void addAlignmentPositionErrorFromRotation (const RotationType &rot, bool)
virtual void addComponent (Alignable *)
 No components here => exception!
virtual void addSurfaceDeformation (const SurfaceDeformation *deformation, bool)
 Add surface deformation parameters to the existing ones (2nd argument without effect)
 AlignableDetUnit (const GeomDetUnit *geomDetUnit)
 Constructor from GeomDetUnit - must not be NULL pointer!
virtual StructureType alignableObjectId () const
 Return the alignable type identifier.
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 cacheTransformation ()
 cache the current position, rotation and other parameters (e.g. surface deformations)
virtual Alignables components () const
 Returns a null vector (no components here)
virtual void dump () const
 Printout information about GeomDet.
virtual void move (const GlobalVector &displacement)
 Move with respect to the global reference frame.
virtual void recursiveComponents (Alignables &result) const
 Do nothing (no components here, so no subcomponents either...)
virtual void restoreCachedTransformation ()
 restore the previously cached transformation
virtual void rotateInGlobalFrame (const RotationType &rotation)
 Rotation with respect to the global reference frame.
virtual void setAlignmentPositionError (const AlignmentPositionError &ape, bool)
 Set the AlignmentPositionError (no components => second argument ignored)
virtual void setSurfaceDeformation (const SurfaceDeformation *deformation, bool)
 Set surface deformation parameters (2nd argument without effect)
virtual int surfaceDeformationIdPairs (std::vector< std::pair< int, SurfaceDeformation * > > &) const
 Return surface deformations.
virtual ~AlignableDetUnit ()
 Destructor.

Private Attributes

AlignmentPositionErrortheAlignmentPositionError
SurfaceDeformationtheCachedSurfaceDeformation
SurfaceDeformationtheSurfaceDeformation

Detailed Description

A concrete class that allows to (mis)align a DetUnit.

Typically all AlignableComposites have (directly or indirectly) this one as the ultimate component.

Definition at line 13 of file AlignableDetUnit.h.


Constructor & Destructor Documentation

AlignableDetUnit::AlignableDetUnit ( const GeomDetUnit geomDetUnit)

Constructor from GeomDetUnit - must not be NULL pointer!

Definition at line 15 of file AlignableDetUnit.cc.

References GeomDet::alignmentPositionError(), setAlignmentPositionError(), setSurfaceDeformation(), GeomDetUnit::surfaceDeformation(), and Alignable::theDeepComponents.

Referenced by alignableObjectId().

                                                                 : // rely on non-NULL pointer!
  Alignable(geomDetUnit->geographicalId().rawId(), geomDetUnit->surface()),
  theAlignmentPositionError(0),
  theSurfaceDeformation(0),
  theCachedSurfaceDeformation(0)
{
  if (geomDetUnit->alignmentPositionError()) { // take over APE from geometry
    // 2nd argument w/o effect:
    this->setAlignmentPositionError(*(geomDetUnit->alignmentPositionError()), false);
  }

  if (geomDetUnit->surfaceDeformation()) { // take over surface modification
    // 2nd argument w/o effect:
    this->setSurfaceDeformation(geomDetUnit->surfaceDeformation(), false);
  }
  
  theDeepComponents.push_back(this);

}
AlignableDetUnit::~AlignableDetUnit ( ) [virtual]

Member Function Documentation

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

Add (or set if it does not exist yet) the AlignmentPositionError (no components => second argument without effect)

Implements Alignable.

Definition at line 84 of file AlignableDetUnit.cc.

References setAlignmentPositionError(), and theAlignmentPositionError.

Referenced by addAlignmentPositionErrorFromRotation().

{

  if ( !theAlignmentPositionError )
    this->setAlignmentPositionError( ape, propagateDown ); // 2nd argument w/o effect
  else 
    *theAlignmentPositionError += ape;
}
void AlignableDetUnit::addAlignmentPositionErrorFromLocalRotation ( const RotationType rot,
bool  propagateDown 
) [virtual]

Add (or set if it does not exist yet) the AlignmentPositionError resulting from a rotation in the local reference frame (no components => second argument without effect)

Implements Alignable.

Definition at line 116 of file AlignableDetUnit.cc.

References addAlignmentPositionErrorFromRotation(), Alignable::globalRotation(), and TkRotation< T >::multiplyInverse().

{

  RotationType globalRot = globalRotation().multiplyInverse(rot*globalRotation());
  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown); // 2nd argument w/o effect

}
void AlignableDetUnit::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 (no components => second argument without effect)

Implements Alignable.

Definition at line 96 of file AlignableDetUnit.cc.

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

Referenced by addAlignmentPositionErrorFromLocalRotation().

{

  // 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 ); // 2nd argument w/o effect

}
void AlignableDetUnit::addComponent ( Alignable ) [virtual]

No components here => exception!

Implements Alignable.

Definition at line 44 of file AlignableDetUnit.cc.

References Exception.

{
  throw cms::Exception("LogicError") 
    << "AlignableDetUnit cannot have components, but try to add one!";
}
void AlignableDetUnit::addSurfaceDeformation ( const SurfaceDeformation deformation,
bool  propagateDown 
) [virtual]

Add surface deformation parameters to the existing ones (2nd argument without effect)

Implements Alignable.

Definition at line 138 of file AlignableDetUnit.cc.

References SurfaceDeformation::add(), setSurfaceDeformation(), theSurfaceDeformation, and SurfaceDeformation::type().

{
  if (!deformation) {
    // nothing to do
  } else if (!theSurfaceDeformation) {
    this->setSurfaceDeformation(deformation, propagateDown); // fine since no components
  } else if (!theSurfaceDeformation->add(*deformation)) {
    edm::LogError("Alignment") << "@SUB=AlignableDetUnit::addSurfaceDeformation"
                               << "Cannot add deformation type " << deformation->type()
                               << " to type " << theSurfaceDeformation->type()
                               << ", so erase deformation information.";
    delete theSurfaceDeformation;
    theSurfaceDeformation = 0;
  }
}
virtual StructureType AlignableDetUnit::alignableObjectId ( ) const [inline, virtual]

Return the alignable type identifier.

Implements Alignable.

Definition at line 62 of file AlignableDetUnit.h.

References AlignableDetUnit().

AlignmentErrors * AlignableDetUnit::alignmentErrors ( void  ) const [virtual]

Return vector of alignment errors.

Implements Alignable.

Definition at line 192 of file AlignableDetUnit.cc.

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

{
  
  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
  
  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 );
  
  return m_alignmentErrors;

}
const AlignmentPositionError* AlignableDetUnit::alignmentPositionError ( ) const [inline]

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

Definition at line 83 of file AlignableDetUnit.h.

References theAlignmentPositionError.

Referenced by AlignableDetOrUnitPtr::alignmentPositionError().

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

Return vector of alignment data.

Implements Alignable.

Definition at line 169 of file AlignableDetUnit.cc.

References Alignable::geomDetId(), Alignable::globalPosition(), Alignable::globalRotation(), Alignments::m_align, DetId::rawId(), makeMuonMisalignmentScenario::rot, 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 alignments (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 );

  return m_alignments;

}
void AlignableDetUnit::cacheTransformation ( ) [virtual]
virtual Alignables AlignableDetUnit::components ( ) const [inline, virtual]

Returns a null vector (no components here)

Implements Alignable.

Definition at line 28 of file AlignableDetUnit.h.

{ return Alignables(); }
void AlignableDetUnit::dump ( void  ) const [virtual]

Printout information about GeomDet.

Implements Alignable.

Definition at line 156 of file AlignableDetUnit.cc.

References Alignable::displacement(), Alignable::globalPosition(), Alignable::globalRotation(), and Alignable::rotation().

{

  edm::LogInfo("AlignableDump") 
    << " AlignableDetUnit has position = " << this->globalPosition() 
    << ", orientation:" << std::endl << this->globalRotation() << std::endl
    << " total displacement and rotation: " << this->displacement() << std::endl
    << this->rotation();

}
void AlignableDetUnit::move ( const GlobalVector displacement) [virtual]

Move with respect to the global reference frame.

Implements Alignable.

Definition at line 51 of file AlignableDetUnit.cc.

References Alignable::addDisplacement(), GloballyPositioned< T >::move(), and Alignable::theSurface.

{
  
  theSurface.move( displacement );
  this->addDisplacement( displacement );

}
virtual void AlignableDetUnit::recursiveComponents ( Alignables result) const [inline, virtual]

Do nothing (no components here, so no subcomponents either...)

Implements Alignable.

Definition at line 31 of file AlignableDetUnit.h.

{}
void AlignableDetUnit::restoreCachedTransformation ( ) [virtual]
void AlignableDetUnit::rotateInGlobalFrame ( const RotationType rotation) [virtual]

Rotation with respect to the global reference frame.

Implements Alignable.

Definition at line 61 of file AlignableDetUnit.cc.

References Alignable::addRotation(), GloballyPositioned< T >::rotate(), and Alignable::theSurface.

void AlignableDetUnit::setAlignmentPositionError ( const AlignmentPositionError ape,
bool   
) [virtual]

Set the AlignmentPositionError (no components => second argument ignored)

Implements Alignable.

Definition at line 71 of file AlignableDetUnit.cc.

References theAlignmentPositionError.

Referenced by addAlignmentPositionError(), and AlignableDetUnit().

void AlignableDetUnit::setSurfaceDeformation ( const SurfaceDeformation deformation,
bool   
) [virtual]

Set surface deformation parameters (2nd argument without effect)

Implements Alignable.

Definition at line 126 of file AlignableDetUnit.cc.

References SurfaceDeformation::clone(), and theSurfaceDeformation.

Referenced by addSurfaceDeformation(), AlignableDetUnit(), and restoreCachedTransformation().

{
  delete theSurfaceDeformation; // OK for zero pointers
  if (deformation) {
    theSurfaceDeformation = deformation->clone();
  } else {
    theSurfaceDeformation = 0;
  }
}
int AlignableDetUnit::surfaceDeformationIdPairs ( std::vector< std::pair< int, SurfaceDeformation * > > &  result) const [virtual]

Return surface deformations.

Implements Alignable.

Definition at line 213 of file AlignableDetUnit.cc.

References Alignable::geomDetId(), query::result, and theSurfaceDeformation.

{
  if ( theSurfaceDeformation ) {
    result.push_back( std::pair<int,SurfaceDeformation*>(this->geomDetId().rawId(),theSurfaceDeformation) );
    return 1;
  }
  
  return 0;
}

Member Data Documentation