CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

AlignableComposite Class Reference

#include <AlignableComposite.h>

Inheritance diagram for AlignableComposite:
Alignable AlignableCSCEndcap AlignableCSCRing AlignableCSCStation AlignableDet AlignableDTBarrel AlignableDTStation AlignableDTWheel AlignableMuon AlignableTracker

List of all members.

Public Member Functions

virtual void addAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown)
virtual void addAlignmentPositionErrorFromLocalRotation (const RotationType &rotation, bool propagateDown)
virtual void addAlignmentPositionErrorFromRotation (const RotationType &rotation, bool propagateDown)
virtual void addComponent (Alignable *component)
virtual void addSurfaceDeformation (const SurfaceDeformation *deformation, bool propagateDown)
 AlignableComposite (align::ID id, StructureType aType, const RotationType &rot=RotationType())
virtual StructureType alignableObjectId () const
 Return the alignable type identifier.
virtual AlignmentErrorsalignmentErrors () const
 Return vector of alignment errors.
virtual Alignmentsalignments () const
 Return alignment data.
virtual Alignables components () const
 Return vector of direct components.
virtual void dump () const
 Recursive printout of alignable structure.
virtual void move (const GlobalVector &displacement)
 Move with respect to the global reference frame.
virtual void moveComponentLocal (const int i, const LocalVector &localDisplacement)
 Move a single component with respect to the local reference frame.
virtual void moveComponentsLocal (const LocalVector &localDisplacement)
 Move with respect to the local reference frame.
virtual void recursiveComponents (Alignables &result) const
 Provide all components, subcomponents etc. (cf. description in base class)
virtual void rotateInGlobalFrame (const RotationType &rotation)
 Rotation interpreted in global reference frame.
virtual void setAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown)
virtual void setSurfaceDeformation (const SurfaceDeformation *deformation, bool propagateDown)
 Set the surface deformation parameters - if (!propagateDown) do not affect daughters.
virtual int surfaceDeformationIdPairs (std::vector< std::pair< int, SurfaceDeformation * > > &) const
 Return surface deformations.
virtual ~AlignableComposite ()
 deleting its components

Protected Member Functions

 AlignableComposite (const GeomDet *geomDet)
 Constructor from GeomDet, only for use in AlignableDet.
void setSurface (const AlignableSurface &s)

Protected Attributes

StructureType theStructureType

Private Member Functions

 AlignableComposite ()
 default constructor hidden

Private Attributes

Alignables theComponents

Detailed Description

Definition at line 25 of file AlignableComposite.h.


Constructor & Destructor Documentation

AlignableComposite::AlignableComposite ( align::ID  id,
StructureType  aType,
const RotationType rot = RotationType() 
)

Constructor for a composite with given rotation. Position can be found from average of daughters' positions later, using addComponent(Alignable*).

Definition at line 20 of file AlignableComposite.cc.

AlignableComposite::~AlignableComposite ( ) [virtual]

deleting its components

Definition at line 28 of file AlignableComposite.cc.

References i, and theComponents.

{
  for (unsigned int i = 0; i < theComponents.size(); ++i) delete theComponents[i];
}
AlignableComposite::AlignableComposite ( const GeomDet geomDet) [explicit, protected]

Constructor from GeomDet, only for use in AlignableDet.

Definition at line 14 of file AlignableComposite.cc.

AlignableComposite::AlignableComposite ( ) [inline, private]

default constructor hidden

Definition at line 110 of file AlignableComposite.h.

Referenced by AlignableTracker::buildBarrel(), and AlignableTracker::buildTRK().

: Alignable (0, RotationType()) {};

Member Function Documentation

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

Add the AlignmentPositionError (if this Alignable is a Det) and, if (propagateDown), add to all the components of the composite

Implements Alignable.

Reimplemented in AlignableDet.

Definition at line 171 of file AlignableComposite.cc.

References components(), and i.

{

  // Since no geomDet is attached, alignable composites do not have an APE
  // The APE is, therefore, just propagated down
  if (!propagateDown) return;

  Alignables comp = this->components();
  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
    (*i)->addAlignmentPositionError(ape, propagateDown);
  }
  
}
void AlignableComposite::addAlignmentPositionErrorFromLocalRotation ( const RotationType rot,
bool  propagateDown 
) [virtual]

Add the AlignmentPositionError resulting from local rotation (if this Alignable is a Det) and, if (propagateDown), add to all the components of the composite

Adds the AlignmentPositionError (in x,y,z coordinates) that would result on the various components from a possible Rotation of a composite the rotation matrix is in interpreted in LOCAL coordinates of the composite

Implements Alignable.

Definition at line 227 of file AlignableComposite.cc.

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

{
  // if (!propagateDown) return; // No! Cannot yet jump out since
  // addAlignmentPositionErrorFromRotation(..) below might be overwritten in derived
  // classes to do something on 'this' (and in fact does so in AlignableDet).

  RotationType globalRot = globalRotation().multiplyInverse(rot*globalRotation());
  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown);

}
void AlignableComposite::addAlignmentPositionErrorFromRotation ( const RotationType rotation,
bool  propagateDown 
) [virtual]

Add the AlignmentPositionError resulting from global rotation (if this Alignable is a Det) and, if (propagateDown), add to all the components of the composite

Adds the AlignmentPositionError (in x,y,z coordinates) that would result on the various components from a possible Rotation of a composite the rotation matrix is in interpreted in GLOBAL coordinates

Implements Alignable.

Reimplemented in AlignableDet.

Definition at line 191 of file AlignableComposite.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), components(), Alignable::globalPosition(), i, and TkRotation< T >::multiplyInverse().

Referenced by addAlignmentPositionErrorFromLocalRotation().

{

  if (!propagateDown) return;

  Alignables comp = this->components();
  PositionType myPosition=this->globalPosition();

  for ( Alignables::const_iterator i=comp.begin(); i!=comp.end(); i++ )
    {

      // It is just similar to to the "movement" that results to the components
      // when the composite is rotated. 
      // Local Position given in coordinates of the GLOBAL Frame
      const GlobalVector localPositionVector = (**i).globalPosition()-myPosition;
      GlobalVector::BasicVectorType lpvgf = localPositionVector.basicVector();

      // rotate with GLOBAL rotation matrix  and subtract => moveVector in global coordinates
      // apparently... you have to use the inverse of the rotation here
      // (rotate the VECTOR rather than the frame) 
      GlobalVector moveVector( rotation.multiplyInverse(lpvgf) - lpvgf );    
      
      AlignmentPositionError ape( moveVector.x(), moveVector.y(), moveVector.z() );
      (*i)->addAlignmentPositionError( ape, propagateDown );
      (*i)->addAlignmentPositionErrorFromRotation( rotation, propagateDown );
          
    }

}
void AlignableComposite::addComponent ( Alignable component) [virtual]

Add a component and set its mother to this alignable. (Note: The component will be adopted, e.g. later deleted.) Also find average position of this composite from its modules' positions.

Implements Alignable.

Definition at line 33 of file AlignableComposite.cc.

References Alignable::deepComponents(), Alignable::globalPosition(), gen::k, GloballyPositioned< T >::move(), Alignable::setMother(), theComponents, Alignable::theDeepComponents, and Alignable::theSurface.

Referenced by AlignableDet::AlignableDet(), AlignableDTChamber::AlignableDTChamber(), and AlignableTracker::buildTRK().

{
  const Alignables& newComps = ali->deepComponents();

  theDeepComponents.insert( theDeepComponents.end(), newComps.begin(), newComps.end() );

  Scalar k = static_cast<Scalar>( newComps.size() ) / theDeepComponents.size();

  theSurface.move( ( ali->globalPosition() - globalPosition() ) * k );

  ali->setMother(this);
  theComponents.push_back(ali);
}
void AlignableComposite::addSurfaceDeformation ( const SurfaceDeformation deformation,
bool  propagateDown 
) [virtual]

Add the surface deformation parameters to the existing ones, if (!propagateDown) do not affect daughters.

Implements Alignable.

Definition at line 254 of file AlignableComposite.cc.

References components(), and i.

{
  // Only DetUnits have surface deformations.
  // The parameters are, therefore, just propagated down.
  if (!propagateDown) return;

  Alignables comp(this->components());
  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
    (*i)->addSurfaceDeformation(deformation, propagateDown);
  }
}
virtual StructureType AlignableComposite::alignableObjectId ( ) const [inline, virtual]

Return the alignable type identifier.

Implements Alignable.

Definition at line 86 of file AlignableComposite.h.

References theStructureType.

Referenced by dump(), and recursiveComponents().

{ return theStructureType; }
AlignmentErrors * AlignableComposite::alignmentErrors ( void  ) const [virtual]

Return vector of alignment errors.

Implements Alignable.

Reimplemented in AlignableDet, AlignableCSCEndcap, AlignableDTBarrel, AlignableMuon, and AlignableTracker.

Definition at line 315 of file AlignableComposite.cc.

References components(), filterCSVwithJSON::copy, i, and AlignmentErrors::m_alignError.

{

  // Recursively call alignmentsErrors, until we get to an AlignableDetUnit
  Alignables comp = this->components();

  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();

  // Add components recursively
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
    {
      AlignmentErrors* tmpAlignmentErrors = (*i)->alignmentErrors();
      std::copy( tmpAlignmentErrors->m_alignError.begin(), tmpAlignmentErrors->m_alignError.end(), 
                 std::back_inserter(m_alignmentErrors->m_alignError) );
          delete tmpAlignmentErrors;
    }

  
  return m_alignmentErrors;

}
Alignments * AlignableComposite::alignments ( void  ) const [virtual]

Return alignment data.

Implements Alignable.

Reimplemented in AlignableDet, AlignableCSCEndcap, AlignableDTBarrel, AlignableMuon, AlignableSiStripDet, and AlignableTracker.

Definition at line 291 of file AlignableComposite.cc.

References components(), filterCSVwithJSON::copy, i, and Alignments::m_align.

{

  // Recursively call alignments, until we get to an AlignableDetUnit
  Alignables comp = this->components();

  Alignments* m_alignments = new Alignments();

  // Add components recursively
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
    {
      Alignments* tmpAlignments = (*i)->alignments();
      std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), 
                 std::back_inserter(m_alignments->m_align) );
          delete tmpAlignments;
    }

  
  return m_alignments;

}
virtual Alignables AlignableComposite::components ( ) const [inline, virtual]
void AlignableComposite::dump ( void  ) const [virtual]

Recursive printout of alignable structure.

Implements Alignable.

Reimplemented in AlignableCSCEndcap, AlignableCSCRing, AlignableCSCStation, AlignableDTBarrel, AlignableDTStation, and AlignableDTWheel.

Definition at line 268 of file AlignableComposite.cc.

References alignableObjectId(), components(), Alignable::globalPosition(), Alignable::globalRotation(), and i.

{

  // A simple printout method. Could be specialized in the implementation classes.

  Alignables comp = this->components();

  // Dump this
  edm::LogInfo("AlignableDump") 
    << " Alignable of type " << this->alignableObjectId() 
    << " has " << comp.size() << " components" << std::endl
    << " position = " << this->globalPosition() << ", orientation:" << std::endl
    << this->globalRotation();

  // Dump components
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
    (*i)->dump();

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

Move with respect to the global reference frame.

Implements Alignable.

Definition at line 64 of file AlignableComposite.cc.

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

Referenced by moveComponentsLocal().

{
  
  // Move components
  Alignables comp = this->components();
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
    (**i).move( displacement);

  // Move surface
  this->addDisplacement( displacement );
  theSurface.move( displacement );

}
void AlignableComposite::moveComponentLocal ( const int  i,
const LocalVector localDisplacement 
) [virtual]

Move a single component with respect to the local reference frame.

Definition at line 88 of file AlignableComposite.cc.

References components(), Exception, i, Alignable::size(), and Alignable::surface().

{

  if (i >= size() ) 
    throw cms::Exception("LogicError")
      << "AlignableComposite index (" << i << ") out of range";

  Alignables comp = this->components();
  comp[i]->move( this->surface().toGlobal( localDisplacement ) );

}
void AlignableComposite::moveComponentsLocal ( const LocalVector localDisplacement) [virtual]

Move with respect to the local reference frame.

Definition at line 80 of file AlignableComposite.cc.

References move(), and Alignable::surface().

{

  this->move( this->surface().toGlobal(localDisplacement) );

}
void AlignableComposite::recursiveComponents ( Alignables result) const [virtual]

Provide all components, subcomponents etc. (cf. description in base class)

Implements Alignable.

Definition at line 48 of file AlignableComposite.cc.

References align::AlignableDet, alignableObjectId(), and components().

{

  Alignables components = this->components();
  if (this->alignableObjectId() == align::AlignableDet 
      && components.size() <= 1) { // Non-glued AlignableDets (still) contain themselves
    return; // (would be better to implement AlignableDet::recursiveComponents!)
  }
  for (Alignables::const_iterator iter = components.begin();
       iter != components.end(); ++iter) {
    result.push_back(*iter); // could use std::copy(..), but here we build a real hierarchy
    (*iter)->recursiveComponents(result);
  }
}
void AlignableComposite::rotateInGlobalFrame ( const RotationType rotation) [virtual]

Rotation interpreted in global reference frame.

Rotation intepreted such, that the orientation of the rotation axis is w.r.t. to the global coordinate system. This, however, does NOT mean the center of the rotation. This is simply taken as the center of the Alignable-object

Implements Alignable.

Definition at line 106 of file AlignableComposite.cc.

References Alignable::addRotation(), PV3DBase< T, PVType, FrameType >::basicVector(), components(), Alignable::globalPosition(), i, TkRotation< T >::multiplyInverse(), GloballyPositioned< T >::rotate(), and Alignable::theSurface.

{
  
  Alignables comp = this->components();
  
  PositionType myPosition = this->globalPosition();
  
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
    {
      
      // It is much simpler to calculate the local position given in coordinates 
      // of the GLOBAL frame and then just apply the rotation matrix given in the 
      // GLOBAL frame as well. ONLY this is somewhat tricky... as Teddy's frames 
      // don't like this kind of mixing...
      
      // Rotations are defined for "Basic3DVector" types, without any FrameTAG,
      // because Rotations usually switch between different frames. You get
      // this by using the method .basicVector()
    
      // localPosition = globalPosition (Component) - globalPosition(Composite)
      // moveVector = rotated localPosition  - original localposition
      // LocalVector localPositionVector = (**i).globalPosition()-myPosition;
    
    
      // Local Position given in coordinates of the GLOBAL Frame
      const GlobalVector localPositionVector = (**i).globalPosition() - myPosition;
      GlobalVector::BasicVectorType lpvgf = localPositionVector.basicVector();

      // rotate with GLOBAL rotation matrix  and subtract => moveVector in 
      // global Coordinates
      // apparently... you have to use the inverse of the rotation here
      // (rotate the VECTOR rather than the frame) 
      GlobalVector moveVector( rotation.multiplyInverse(lpvgf) - lpvgf );
    
    
      (**i).move( moveVector );
      (**i).rotateInGlobalFrame( rotation );

    }

  this->addRotation( rotation );
  
  theSurface.rotate( rotation );

}
void AlignableComposite::setAlignmentPositionError ( const AlignmentPositionError ape,
bool  propagateDown 
) [virtual]

Set the AlignmentPositionError (if this Alignable is a Det) and, if (propagateDown), to all the components of the composite

Implements Alignable.

Reimplemented in AlignableDet.

Definition at line 154 of file AlignableComposite.cc.

References components(), and i.

Referenced by KalmanAlignmentAlgorithm::setAPEToZero().

{

  // Since no geomDet is attached, alignable composites do not have an APE
  // The APE is, therefore, just propagated down
  if (!propagateDown) return;

  Alignables comp = this->components();
  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
    (*i)->setAlignmentPositionError(ape, propagateDown);
  }
}
void AlignableComposite::setSurface ( const AlignableSurface s) [inline, protected]
void AlignableComposite::setSurfaceDeformation ( const SurfaceDeformation deformation,
bool  propagateDown 
) [virtual]

Set the surface deformation parameters - if (!propagateDown) do not affect daughters.

Implements Alignable.

Definition at line 240 of file AlignableComposite.cc.

References components(), and i.

{
  // Only DetUnits have surface deformations.
  // The parameters are, therefore, just propagated down.
  if (!propagateDown) return;

  Alignables comp(this->components());
  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
    (*i)->setSurfaceDeformation(deformation, propagateDown);
  }
}
int AlignableComposite::surfaceDeformationIdPairs ( std::vector< std::pair< int, SurfaceDeformation * > > &  result) const [virtual]

Return surface deformations.

Implements Alignable.

Definition at line 339 of file AlignableComposite.cc.

References components(), prof2calltree::count, i, and query::result.

{

  Alignables comp = this->components();

  int count = 0;

  // Add components recursively
  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i) {
    count += (*i)->surfaceDeformationIdPairs(result);
  }
  
  return count;

}

Member Data Documentation

Definition at line 110 of file AlignableComposite.h.

Referenced by addComponent(), components(), and ~AlignableComposite().