CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

AlignableSiStripDet Class Reference

#include <AlignableSiStripDet.h>

Inheritance diagram for AlignableSiStripDet:
AlignableDet AlignableComposite Alignable

List of all members.

Public Member Functions

 AlignableSiStripDet (const GluedGeomDet *geomDet)
 Constructor.
virtual Alignmentsalignments () const
 first consistify with component detunits, then call method from AlignableDet
virtual ~AlignableSiStripDet ()
 reduntantly make destructor virtual

Private Member Functions

void consistifyAlignments ()
 make alignments consistent with daughters

Private Attributes

const BoundstheMonoBounds
StripGeomDetTypetheMonoType
const BoundstheStereoBounds
StripGeomDetTypetheStereoType

Detailed Description

An alignable for GluedDets in Strip tracker, taking care of consistency with AlignableDet components.

First implementation April/May 2008

Author:
Gero Flucke, Hamburg University
Date:
2009/04/16 16:53:06
Revision:
1.5

Definition at line 23 of file AlignableSiStripDet.h.


Constructor & Destructor Documentation

AlignableSiStripDet::AlignableSiStripDet ( const GluedGeomDet geomDet)

Constructor.

Definition at line 29 of file AlignableSiStripDet.cc.

References AlignableComposite::components(), Exception, GeomDet::geographicalId(), GluedGeomDet::monoDet(), and GluedGeomDet::stereoDet().

  : AlignableDet(gluedDet, true), // true: adding DetUnits
    theMonoBounds  (gluedDet->monoDet()  ->surface().bounds().clone()),
    theStereoBounds(gluedDet->stereoDet()->surface().bounds().clone()),
    theMonoType  (static_cast<const StripGeomDetUnit*>(gluedDet->monoDet())  ->specificType()),
    theStereoType(static_cast<const StripGeomDetUnit*>(gluedDet->stereoDet())->specificType())
{
  // It is not allowed to store a pointer to GeomDet within objects with a life time
  // longer than an Event: 
  // GeomDet comes from TrackerGeometry that is created from GeometricDet that depends on
  // IdealGeometryRecord from EventSetup, so it could change in next event!
  //  ==> Need to store directly what I need from it. 
  // Unfortunately the current way with references for the type does not solve that,
  // either. But currently no way out, see header file.

  // check order mono/stereo
  const Alignables units(this->components());
  if (units.size() != 2
      || gluedDet->monoDet()->geographicalId() != units[0]->geomDetId()
      || gluedDet->stereoDet()->geographicalId() != units[1]->geomDetId()) {
    throw cms::Exception("LogicError")
      << "[AlignableSiStripDet] " << "Either != 2 components or "
      << "mono/stereo in wrong order for consistifyAlignments.";
  }
}
AlignableSiStripDet::~AlignableSiStripDet ( ) [virtual]

reduntantly make destructor virtual

Definition at line 56 of file AlignableSiStripDet.cc.

References theMonoBounds, and theStereoBounds.

{
  delete theMonoBounds;
  delete theStereoBounds;
}

Member Function Documentation

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

first consistify with component detunits, then call method from AlignableDet

Reimplemented from AlignableDet.

Definition at line 63 of file AlignableSiStripDet.cc.

References consistifyAlignments().

{
  const_cast<AlignableSiStripDet*>(this)->consistifyAlignments();

  return this->AlignableDet::alignments();
}
void AlignableSiStripDet::consistifyAlignments ( ) [private]

make alignments consistent with daughters

Definition at line 71 of file AlignableSiStripDet.cc.

References Alignable::addDisplacement(), Alignable::addRotation(), newFWLiteAna::build, AlignableComposite::components(), BoundingBox::corners(), Alignable::globalPosition(), Alignable::globalRotation(), i, evf::evtn::offset(), L1TEmulatorMonitor_cff::p, GloballyPositioned< T >::position(), MediumProperties::radLen(), Alignable::rotation(), GloballyPositioned< T >::rotation(), theMonoBounds, Alignable::theRotation, theStereoBounds, Alignable::theSurface, PV3DBase< T, PVType, FrameType >::x(), MediumProperties::xi(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by alignments().

{
  // make alignments consistent with daughters, calling method from geometry

  // The aim of all this gymnastics is to have the alignments calculated the same way as
  // in PlaneBuilderForGluedDet::plane(const std::vector<const GeomDetUnit*> &detComps);
  // 
  // So we take the (new) position and orientation from the AligableDetUnits,
  // but bounds and GeomDetType from original GeomDetUnits to create new a new glued
  // surface.

  const PositionType oldPos(theSurface.position()); // From old surface for keeping...
  const RotationType oldRot(theSurface.rotation()); // ...track of changes.

  const Alignables aliUnits(this->components()); // order mono==0, stereo==1 checked in ctr.
  
  BoundPlane::BoundPlanePointer monoPlane
    = BoundPlane::build(aliUnits[0]->globalPosition(), aliUnits[0]->globalRotation(),
                        *theMonoBounds);

  BoundPlane::BoundPlanePointer stereoPlane
    = BoundPlane::build(aliUnits[1]->globalPosition(), aliUnits[1]->globalRotation(),
                        *theStereoBounds);
  
  Surface::PositionType::BasicVectorType posSum = monoPlane->position().basicVector();
  posSum += stereoPlane->position().basicVector();
  Surface::PositionType meanPos(posSum/(float)aliUnits.size());
  Surface::RotationType rotation =  monoPlane->rotation();
  
  BoundPlane::BoundPlanePointer tmpPlane = BoundPlane::build(meanPos, rotation, OpenBounds());

  const MediumProperties* mp = monoPlane->mediumProperties();
  MediumProperties newmp(0,0);
  if (mp != 0) newmp = MediumProperties(mp->radLen()*2.0,mp->xi()*2.0);

  std::vector<GlobalPoint> corners;
  std::vector<GlobalPoint> monoDC = BoundingBox().corners(*monoPlane);
  corners.insert(corners.end(), monoDC.begin(), monoDC.end());
  std::vector<GlobalPoint> stereoDC = BoundingBox().corners(*stereoPlane);
  corners.insert(corners.end(), stereoDC.begin(), stereoDC.end());

  float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
  for (std::vector<GlobalPoint>::const_iterator i=corners.begin();
       i!=corners.end();
       ++i) {
    LocalPoint p = tmpPlane->toLocal(*i);
    if (p.x() < xmin) xmin = p.x();
    if (p.x() > xmax) xmax = p.x();
    if (p.y() < ymin) ymin = p.y();
    if (p.y() > ymax) ymax = p.y();
    if (p.z() < zmin) zmin = p.z();
    if (p.z() > zmax) zmax = p.z();
  }
 
  LocalVector localOffset((xmin+xmax)/2., (ymin+ymax)/2., (zmin+zmax)/2.);
  GlobalVector offset(tmpPlane->toGlobal(localOffset));

  theSurface = AlignableSurface(BoundPlane(meanPos+offset, rotation, 
                                           RectangularPlaneBounds((xmax-xmin)/2, (ymax-ymin)/2, (zmax-zmin)/2),
                                           &newmp));
  
  // But do not forget to keep track of movements/rotations:
  const GlobalVector theMovement(theSurface.position().basicVector() - oldPos.basicVector());
  // Seems to be correct down to delta angles 4.*1e-8:
  const RotationType theRotation(oldRot.multiplyInverse(theSurface.rotation()));
  this->addDisplacement(theMovement);
  this->addRotation(theRotation);
  
//   this->dumpCompareEuler(oldRot, theSurface.rotation());

//   if (movement.mag2()) { // > 1.e-10) { 
//     edm::LogWarning("Alignment") << "@SUB=consistifyAlignments" 
//                               << "Delta: " << movement.x() << " " << movement.y() << " " << movement.z()
//                               << "\nPos: " << oldPos.perp() << " " << oldPos.phi() << " " << oldPos.z();
//   }
}

Member Data Documentation

The following four members are needed to recalculate the surface in consistifyAlignments, to get rid of a GluedDet* which is disregarded since it could become an invalid pointer in the next event (theoretically...). But this solution is not better, the references for the types would become invalid together with the GeomDets they are taken from. StripGeomDetType has neither clone() and nor a decent copy constructor, so I cannot go the the same way as for the bounds. Sigh!

Definition at line 45 of file AlignableSiStripDet.h.

Referenced by consistifyAlignments(), and ~AlignableSiStripDet().

Definition at line 47 of file AlignableSiStripDet.h.

Definition at line 46 of file AlignableSiStripDet.h.

Referenced by consistifyAlignments(), and ~AlignableSiStripDet().

Definition at line 48 of file AlignableSiStripDet.h.