CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions

PlaneBuilderForGluedDet Class Reference

#include <PlaneBuilderForGluedDet.h>

List of all members.

Public Types

typedef
ReferenceCountingPointer
< Plane
ResultType

Public Member Functions

ResultType plane (const std::vector< const GeomDetUnit * > &dets) const

Private Member Functions

std::pair
< RectangularPlaneBounds
*, GlobalVector
computeRectBounds (const std::vector< const GeomDetUnit * > &dets, const Plane &plane) const
Surface::RotationType computeRotation (const std::vector< GeomDetUnit * > &dets, const Surface::PositionType &meanPos) const

Detailed Description

Builds the minimal rectangular box that contains all input GeomDetUnits fully.

Definition at line 16 of file PlaneBuilderForGluedDet.h.


Member Typedef Documentation

Warning, remember to assign this pointer to a ReferenceCountingPointer! Should be changed to return a ReferenceCountingPointer<BoundPlane>

Definition at line 21 of file PlaneBuilderForGluedDet.h.


Member Function Documentation

std::pair< RectangularPlaneBounds *, GlobalVector > PlaneBuilderForGluedDet::computeRectBounds ( const std::vector< const GeomDetUnit * > &  dets,
const Plane plane 
) const [private]

Definition at line 36 of file PlaneBuilderForGluedDet.cc.

References BoundingBox::corners(), i, evf::evtn::offset(), AlCaHLTBitMon_ParallelJobs::p, query::result, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), SiStripMonitorClusterAlca_cfi::xmax, SiStripMonitorClusterAlca_cfi::xmin, PV3DBase< T, PVType, FrameType >::y(), SiStripMonitorClusterAlca_cfi::ymax, SiStripMonitorClusterAlca_cfi::ymin, PV3DBase< T, PVType, FrameType >::z(), SiStripMonitorClusterAlca_cfi::zmax, and SiStripMonitorClusterAlca_cfi::zmin.

Referenced by plane().

{
  // go over all corners and compute maximum deviations from mean pos.
  std::vector<GlobalPoint> corners;
  for( std::vector<const GeomDetUnit*>::const_iterator idet = dets.begin(), dend = dets.end();
       idet != dend; ++idet )
  {
    const Plane& bplane = dynamic_cast<const Plane&>(( *idet )->surface());
    std::vector<GlobalPoint> dc = BoundingBox().corners( bplane );
    corners.insert( corners.end(), dc.begin(), dc.end());
  }
  
  float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
  for( std::vector<GlobalPoint>::const_iterator i = corners.begin(), cend = corners.end();
       i != cend; ++i )
  {
    LocalPoint p = plane.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( plane.toGlobal( localOffset ));

  std::pair<RectangularPlaneBounds*, GlobalVector> result(new RectangularPlaneBounds(( xmax - xmin ) / 2, ( ymax - ymin ) / 2, ( zmax - zmin ) / 2 ), offset );

  return result;
}
Surface::RotationType PlaneBuilderForGluedDet::computeRotation ( const std::vector< GeomDetUnit * > &  dets,
const Surface::PositionType meanPos 
) const [private]

Definition at line 70 of file PlaneBuilderForGluedDet.cc.

References Vector3DBase< T, FrameTag >::cross(), n, plane(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{
  // choose first mono out-pointing rotation
  // the rotations of GluedDets coincide with the mono part
  // Simply take the x,y of the first Det if z points out,
  // or -x, y if it doesn't
  const BoundPlane& plane = dynamic_cast<const BoundPlane&>( dets.front()->surface());
  //GlobalVector n = plane.normalVector();

  GlobalVector xAxis;
  GlobalVector yAxis;
  GlobalVector planeYAxis = plane.toGlobal( LocalVector( 0, 1, 0 ));
  if( planeYAxis.z() < 0 )
    yAxis = -planeYAxis;
  else
    yAxis =  planeYAxis;

  GlobalVector planeXAxis = plane.toGlobal( LocalVector( 1, 0, 0 ));
  GlobalVector n = planeXAxis.cross( planeYAxis );

  if( n.x() * meanPos.x() + n.y() * meanPos.y() > 0 )
  {
    xAxis = planeXAxis;
  }
  else
  {
    xAxis = -planeXAxis;
  }

  return Surface::RotationType( xAxis, yAxis );
}
PlaneBuilderForGluedDet::ResultType PlaneBuilderForGluedDet::plane ( const std::vector< const GeomDetUnit * > &  dets) const

Definition at line 11 of file PlaneBuilderForGluedDet.cc.

References computeRectBounds(), end, i, MediumProperties::radLen(), idealTransformation::rotation, and MediumProperties::xi().

Referenced by TrackerGeomBuilderFromGeometricDet::buildGeomDet(), and computeRotation().

{
  // find mean position
  typedef Surface::PositionType::BasicVectorType Vector;
  Vector posSum( 0, 0, 0 );
  for( std::vector<const GeomDetUnit*>::const_iterator i = dets.begin(), end = dets.end(); i != end; ++i )
  {
    posSum += (**i).surface().position().basicVector();
  }
  Surface::PositionType meanPos( posSum / float( dets.size()));
  
  Surface::RotationType rotation =  dets.front()->surface().rotation();
  //  Surface::RotationType rotation = computeRotation( dets, meanPos);
  Plane tmpPlane = Plane( meanPos, rotation);

  // Take the medium properties from the first DetUnit 
  const MediumProperties &  mp = dets.front()->surface().mediumProperties();
  MediumProperties newmp( mp.radLen() * 2.0, mp.xi() * 2.0 );

  std::pair<RectangularPlaneBounds*, GlobalVector> bo = computeRectBounds( dets, tmpPlane);
  return new Plane( meanPos+bo.second, rotation, newmp, bo.first);
}