test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions
PlaneBuilderForGluedDet Class Reference

#include <PlaneBuilderForGluedDet.h>

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< const 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, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), hlt_dqm_clientPB-live_cfg::xmax, hlt_dqm_clientPB-live_cfg::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().

37 {
38  // go over all corners and compute maximum deviations from mean pos.
39  std::vector<GlobalPoint> corners;
40  for( std::vector<const GeomDetUnit*>::const_iterator idet = dets.begin(), dend = dets.end();
41  idet != dend; ++idet )
42  {
43  const Plane& bplane = dynamic_cast<const Plane&>(( *idet )->surface());
44  std::vector<GlobalPoint> dc = BoundingBox().corners( bplane );
45  corners.insert( corners.end(), dc.begin(), dc.end());
46  }
47 
48  float xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0);
49  for( std::vector<GlobalPoint>::const_iterator i = corners.begin(), cend = corners.end();
50  i != cend; ++i )
51  {
52  LocalPoint p = plane.toLocal( *i );
53  if( p.x() < xmin ) xmin = p.x();
54  if( p.x() > xmax ) xmax = p.x();
55  if( p.y() < ymin ) ymin = p.y();
56  if( p.y() > ymax ) ymax = p.y();
57  if( p.z() < zmin ) zmin = p.z();
58  if( p.z() > zmax ) zmax = p.z();
59  }
60 
61  LocalVector localOffset(( xmin + xmax ) / 2., ( ymin + ymax ) / 2., ( zmin + zmax ) / 2. );
62  GlobalVector offset( plane.toGlobal( localOffset ));
63 
64  std::pair<RectangularPlaneBounds*, GlobalVector> result(new RectangularPlaneBounds(( xmax - xmin ) / 2, ( ymax - ymin ) / 2, ( zmax - zmin ) / 2 ), offset );
65 
66  return result;
67 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
int i
Definition: DBlmapReader.cc:9
T y() const
Definition: PV3DBase.h:63
Definition: Plane.h:17
tuple result
Definition: mps_fire.py:84
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:24
T x() const
Definition: PV3DBase.h:62
Surface::RotationType PlaneBuilderForGluedDet::computeRotation ( const std::vector< const GeomDetUnit * > &  dets,
const Surface::PositionType meanPos 
) const
private

Definition at line 70 of file PlaneBuilderForGluedDet.cc.

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

71 {
72  // choose first mono out-pointing rotation
73  // the rotations of GluedDets coincide with the mono part
74  // Simply take the x,y of the first Det if z points out,
75  // or -x, y if it doesn't
76  const BoundPlane& plane = dynamic_cast<const BoundPlane&>( dets.front()->surface());
77  //GlobalVector n = plane.normalVector();
78 
79  GlobalVector xAxis;
80  GlobalVector yAxis;
81  GlobalVector planeYAxis = plane.toGlobal( LocalVector( 0, 1, 0 ));
82  if( planeYAxis.z() < 0 )
83  yAxis = -planeYAxis;
84  else
85  yAxis = planeYAxis;
86 
87  GlobalVector planeXAxis = plane.toGlobal( LocalVector( 1, 0, 0 ));
88  GlobalVector n = planeXAxis.cross( planeYAxis );
89 
90  if( n.x() * meanPos.x() + n.y() * meanPos.y() > 0 )
91  {
92  xAxis = planeXAxis;
93  }
94  else
95  {
96  xAxis = -planeXAxis;
97  }
98 
99  return Surface::RotationType( xAxis, yAxis );
100 }
Local3DVector LocalVector
Definition: LocalVector.h:12
T y() const
Definition: PV3DBase.h:63
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:62
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().

12 {
13  // find mean position
15  Vector posSum( 0, 0, 0 );
16  for( std::vector<const GeomDetUnit*>::const_iterator i = dets.begin(), end = dets.end(); i != end; ++i )
17  {
18  posSum += (**i).surface().position().basicVector();
19  }
20  Surface::PositionType meanPos( posSum / float( dets.size()));
21 
22  Surface::RotationType rotation = dets.front()->surface().rotation();
23  // Surface::RotationType rotation = computeRotation( dets, meanPos);
24  Plane tmpPlane = Plane( meanPos, rotation);
25 
26  // Take the medium properties from the first DetUnit
27  const MediumProperties & mp = dets.front()->surface().mediumProperties();
28  MediumProperties newmp( mp.radLen() * 2.0, mp.xi() * 2.0 );
29 
30  std::pair<RectangularPlaneBounds*, GlobalVector> bo = computeRectBounds( dets, tmpPlane);
31  return new Plane( meanPos+bo.second, rotation, newmp, bo.first);
32 }
int i
Definition: DBlmapReader.cc:9
float radLen() const
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Definition: Plane.h:17
std::pair< RectangularPlaneBounds *, GlobalVector > computeRectBounds(const std::vector< const GeomDetUnit * > &dets, const Plane &plane) const
#define end
Definition: vmac.h:37
float xi() const